com.jinsight.jetchart
Class ScatterGraph

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended bycom.jinsight.jetchart.GradientPanel
                  extended bycom.jinsight.jetchart.GenericGraph
                      extended bycom.jinsight.jetchart.ScatterGraph
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ScatterGraph
extends GenericGraph

The ScatterGraph class implements the graphic context of scatter series. The data points of scatter series are associated with two values, plotted against a horizontal and a vertical scales and based on a cartesian coordinates system.
A chart context implemented by the ScatterGraph class can be dragged or resized. To drag a chart, just place the mouse cursor on the chart area, then click and hold the left button while dragging. To resize chart, double-click mouse on the chart area and then click and hold the left button while dragging. A double-click alternates between dragging and resizing chart.

See Also:
GenericGraph, ScatterSerie, GenericGraph.setDraggingEnabled(boolean), Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int GRAPH_AREA
          Constant used to clip the background area where an image can be painted or the gradient colors effect can be displayed.
static int PARENT_AREA
          Constant used to set the chart container bounds as the area where a background image can be painted or the gradient colors effect can be displayed.
 
Fields inherited from class com.jinsight.jetchart.GenericGraph
CENTER, TILE, TOP_LEFT
 
Fields inherited from class com.jinsight.jetchart.GradientPanel
BOTTOM_TO_TOP, LEFT_TO_RIGHT, RIGHT_TO_LEFT, TOP_TO_BOTTOM
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ScatterGraph()
          Creates a ScatterGraph object.
 
Method Summary
 void addSerie(ScatterSerie serie)
           
 void addTargetLine(TargetLine tl)
          Adds a target line.
protected  void finalize()
           
 Grid getGrid()
          Returns a reference to the grid object.
 GridCrossedLines getGridCrossedLines()
          Returns a reference to the GridCrossedLines object.
 Scale getHScale()
          Returns a reference to the horizontal scale object.
 SeriesBase getHSeriesBase()
          Returns a reference to the horizontal series base object.
 Quadrant getQuadrant(int quadrantNr)
          Returns a reference to one of the four available Quadrant objects.
 YAxis getRYAxis()
          Returns a reference to the vertical axis placed to the right of the chart area.
 ScatterGraphEventListener getScatterGraphEventListener()
          Returns a reference to a ScatterGraphEventListener object.
 XAxis getTXAxis()
          Returns a reference to horizontal axis placed at the top of the chart area.
 Scale getVScale()
          Returns a reference to the vertical scale object.
 SeriesBase getVSeriesBase()
          Returns a reference to the vertical series base object.
 Wall getWall()
          Returns a reference to the Wall object.
 XAxis getXAxis()
          Returns a reference to the horizontal axis placed at the bottom of the chart area.
 YAxis getYAxis()
          Returns a reference to the vertical axis placed to the left of the chart area.
 void paint(java.awt.Graphics gr)
          Overrides the Component class paint() method.
 void readXMLData(java.io.Reader reader)
          Reads chart properties from an xml character stream.
 void refresh()
          Refreshes chart.
 void removeAllSeries()
          Removes all series from the graphic context.
 void removeAllTargetLines()
          Removes all target lines.
 void removeSerie(ScatterSerie serie)
           
 void removeTargetLine(TargetLine tl)
          Removes a target line.
 void setBackgroundImageArea(int backgroundImageArea)
          Sets the area on which a background image is painted.
 void setDateGraphEnabled(boolean isDateGraphEnabled)
          Enables/disables a date graph.
 void setGradientColorsArea(int gradientColorsArea)
          Sets the area on which the gradient colors effect is displayed.
 void setZoomAreaColor(java.awt.Color zoomAreaColor)
          Sets the color to paint chart area selected for zooming.
 void setZoomEnabled(boolean isZoomEnabled)
          Enables/disables zoom.
 void update(java.awt.Graphics gr)
          Overrides the Component class update() method, to avoid flickering.
 
Methods inherited from class com.jinsight.jetchart.GenericGraph
addLegend, addNote, addSerie, addSerieListener, getBottomTitle, getLeftTitle, getLegend, getLegend, getRightTitle, getSeries, getToolTip, isPainted, processMouseEvent, processMouseMotionEvent, removeAllNotes, removeLegend, removeNote, removeSerie, removeSerieListener, set3DEnabled, setBackgroundImage, setBorderColor, setBorderEnabled, setBorderThickness, setBottomMargin, setBufferedImageEnabled, setConnection, setDefaultCursor, setDraggingBoxColor, setDraggingEnabled, setDriver, setLabelsQuery, setLeftMargin, setLegendEnabled, setOffScreenGraphEnabled, setRightMargin, setTitle, setTitleFont, setTitleForeground, setTitleGap, setTopMargin, setValueFormat
 
Methods inherited from class com.jinsight.jetchart.GradientPanel
setGradientColors, setGradientOrientation
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PARENT_AREA

public static final int PARENT_AREA
Constant used to set the chart container bounds as the area where a background image can be painted or the gradient colors effect can be displayed.

See Also:
Constant Field Values

GRAPH_AREA

public static final int GRAPH_AREA
Constant used to clip the background area where an image can be painted or the gradient colors effect can be displayed. The clipped area is delimited by the vertical and horizontal axis coordinates.

See Also:
Constant Field Values
Constructor Detail

ScatterGraph

public ScatterGraph()
Creates a ScatterGraph object. Default constructor.

Method Detail

addSerie

public void addSerie(ScatterSerie serie)

removeSerie

public void removeSerie(ScatterSerie serie)

removeAllSeries

public void removeAllSeries()
Description copied from class: GenericGraph
Removes all series from the graphic context.

Overrides:
removeAllSeries in class GenericGraph

addTargetLine

public void addTargetLine(TargetLine tl)
Adds a target line.

Parameters:
tl - A TargetLine object.
See Also:
TargetLine

removeTargetLine

public void removeTargetLine(TargetLine tl)
Removes a target line.

Parameters:
tl - A TargetLine object.
See Also:
TargetLine

removeAllTargetLines

public void removeAllTargetLines()
Removes all target lines.

See Also:
TargetLine

getXAxis

public XAxis getXAxis()
Returns a reference to the horizontal axis placed at the bottom of the chart area.

Returns:
XAxis object.
See Also:
XAxis

getTXAxis

public XAxis getTXAxis()
Returns a reference to horizontal axis placed at the top of the chart area. The top x axis is only displayed if the horizontal scale position is set to Scale.TOP or Scale.TOP_BOTTOM.

Returns:
XAxis object.
See Also:
XAxis, getHScale(), Scale

getYAxis

public YAxis getYAxis()
Returns a reference to the vertical axis placed to the left of the chart area.

Returns:
YAxis object.
See Also:
YAxis

getRYAxis

public YAxis getRYAxis()
Returns a reference to the vertical axis placed to the right of the chart area. The right y axis is only displayed if the vertical scale position is set to Scale.RIGHT or Scale.LEFT_RIGHT.

Returns:
YAxis object.
See Also:
YAxis, getVScale(), Scale

getGrid

public Grid getGrid()
Returns a reference to the grid object.

Returns:
Grid object.
See Also:
Grid

getGridCrossedLines

public GridCrossedLines getGridCrossedLines()
Returns a reference to the GridCrossedLines object.

Returns:
GridCrossedLines object.
See Also:
GridCrossedLines

getVScale

public Scale getVScale()
Returns a reference to the vertical scale object.

Returns:
Scale object.
See Also:
Scale

getHScale

public Scale getHScale()
Returns a reference to the horizontal scale object.

Returns:
Scale object.
See Also:
Scale

getVSeriesBase

public SeriesBase getVSeriesBase()
Returns a reference to the vertical series base object.

Returns:
SeriesBase object.
See Also:
SeriesBase

getHSeriesBase

public SeriesBase getHSeriesBase()
Returns a reference to the horizontal series base object.

Returns:
SeriesBase object.
See Also:
SeriesBase

getWall

public Wall getWall()
Returns a reference to the Wall object. If enabled, a Wall object is painted on the background of the graph area, delimited by the horizontal and vertical axis.

Returns:
Wall object.
See Also:
Wall

getQuadrant

public Quadrant getQuadrant(int quadrantNr)
Returns a reference to one of the four available Quadrant objects.

Parameters:
quadrantNr - An integer number, ranging from 1 to 4.
See Also:
Quadrant

getScatterGraphEventListener

public ScatterGraphEventListener getScatterGraphEventListener()
Returns a reference to a ScatterGraphEventListener object. This object is created and owned by a ScatterGraph instance, and implements both MouseListener and MouseMotionListener interfaces to handle mouse events fired by the ScatterGraph class.

See Also:
ScatterGraphEventListener

readXMLData

public void readXMLData(java.io.Reader reader)
                 throws java.io.IOException
Description copied from class: GenericGraph
Reads chart properties from an xml character stream. The incoming data must follow some rules regarding the xml elements to be parsed. Currently, only chart labels and series values are supported. Future versions of JetChart will support a complete set of xml elements to specify all chart properties. The structure of the xml character stream is the following:

<chart>
  <labels>
     l1
     l2
     l3
     l4

  </labels>
  <series id="1">
    <values>
       80
       100
       70
       60

    </values>
  </series>
  <series id="2">
    <multiplevalues qty="4" delimiter="|">
       10|20|15|35
       22|38|12|40
       17|50|20|13
       25|14|38|55

    </multiplevalues>
  </series>
</chart>

In the xml sequence above, we can see the following xml elements and attributes:

<chart> - This is the root element, and it must be closed at the end of the xml file.

<labels> - Used to list textual data representing the chart labels.

<series> - Encloses the properties of a series. The id attribute is used to identify the series within the chart context. It is compared with the value returned by the AbstractSerie.getId() method, and if they match, the properties read from this xml file are assigned to the identified series.

<values> - Used to list textual data representing a series values.

<multiplevalues> - Used to set values of series that display data points associated with multiple values, like ohlc series, for example. The qty attribute is mandatory, and it is used to set the exact number of values expected from each line listed within the <multiplevalues> tag. The delimiter attribute is optional. It is used by the xml parser to tokenize values. If not informed, a space character is used.

Every opened xml element must be closed, otherwise the xml parser raises an exception.

Overrides:
readXMLData in class GenericGraph
Parameters:
reader - The reader from which to retrieve the XML data.
Throws:
java.io.IOException - If an error occured while reading the input.
See Also:
AbstractSerie.getId()

setBackgroundImageArea

public void setBackgroundImageArea(int backgroundImageArea)
Sets the area on which a background image is painted. Default area is the parent container bounds. If this method is passed GRAPH_AREA, the background image area is delimited by the vertical and horizontal axis coordinates.

Parameters:
backgroundImageArea - An integer value.
See Also:
PARENT_AREA, GRAPH_AREA

setGradientColorsArea

public void setGradientColorsArea(int gradientColorsArea)
Sets the area on which the gradient colors effect is displayed. Default area is the parent container bounds. If this method is passed GRAPH_AREA, the area is delimited by the vertical and horizontal axis coordinates.

Parameters:
gradientColorsArea - An integer value.
See Also:
PARENT_AREA, GRAPH_AREA

setDateGraphEnabled

public void setDateGraphEnabled(boolean isDateGraphEnabled)
Enables/disables a date graph. A date graph displays time series, which are the same scatter series supported by this chart context, but the x values are treated as milliseconds plotted against a horizontal scale that represents a line of time, showing timestamps rather than raw values. Positive values correspond to milliseconds since January 1, 1970, 00:00:00 GMT, and negative values are milliseconds before that date.
A date graph is disabled by default.

Parameters:
isDateGraphEnabled - a boolean value(true/false).
See Also:
ScatterSerie.setDateValues(java.lang.String[]), ScatterSerie.setDateFormat(java.lang.String)

setZoomEnabled

public void setZoomEnabled(boolean isZoomEnabled)
Enables/disables zoom. If chart dragging is enabled, this parameter has no effect. To select an area for zooming, just click mouse button and drag cursor to delimit the area to be zoomed. While dragging mouse, the selected area is transparently painted. After releasing mouse button, the selected area is zoomed. To zoom-out chart, simply click mouse right button and chart returns to normal view.

Parameters:
isZoomEnabled - A boolean value(true/false).
See Also:
GenericGraph.setDraggingEnabled(boolean), setZoomAreaColor(java.awt.Color)

setZoomAreaColor

public void setZoomAreaColor(java.awt.Color zoomAreaColor)
Sets the color to paint chart area selected for zooming. The selected area is painted in 'XOR' mode, which combines a given color with the background color, resulting in a transparent effect.

Parameters:
zoomAreaColor - A Color object.
See Also:
setZoomEnabled(boolean)

refresh

public void refresh()
Refreshes chart. The first time a chart is displayed, some private methods of several classes are invoked to calculate margins, scale values, etc., and these processes are executed just one time, unless any change that affects chart data or appearance takes place.

Overrides:
refresh in class GenericGraph

update

public void update(java.awt.Graphics gr)
Overrides the Component class update() method, to avoid flickering.

Parameters:
gr - A Graphics object, where painting is done. This object is automatically created by the AWT classes and passed to the update() method, which in turn sends it to the paint() method.
See Also:
paint(java.awt.Graphics)

paint

public void paint(java.awt.Graphics gr)
Overrides the Component class paint() method. Chart plotting starts in this method, basically by delegating the painting process to each one of the objects of the chart context.

Overrides:
paint in class GradientPanel
Parameters:
gr - A Graphics object.
See Also:
update(java.awt.Graphics)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class GenericGraph
Throws:
java.lang.Throwable