com.jinsight.jetchart
Class PolarGraph

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.PolarGraph
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PolarGraph
extends GenericGraph

A polar graph consists of one or more series of data points plotted on a polar coordinate system delimited by a circular area. Each data point position is determined by a pair of values, in the form (r,theta). The first value(r) is a fraction of the radius of the circular area, and the second value(theta) corresponds to the angle the data point forms with the right horizontal radius, starting counterclockwise from the zero degree position.
Among other things, a polar graph is often used to show the position of objects with respect to the cardinal points on a polar coordinate system, where the tips of the top, left, bottom and right radius correspond to the North, West, South and East locations.

See Also:
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
PolarGraph()
          Creates a PolarGraph object.
 
Method Summary
protected  void finalize()
           
 PolarGraphEventListener getPolarGraphEventListener()
          Returns a reference to a PolarGraphEventListener object.
 PolarGrid getPolarGrid()
          Returns a reference to the polar grid object.
 Scale getScale()
          Returns a reference to the Scale object.
 XAxis getXAxis()
          Returns a reference to the horizontal axis.
 YAxis getYAxis()
          Returns a reference to the vertical axis.
 void paint(java.awt.Graphics gr)
          Overrides the Component class paint() method to provide gradient effect.
 void readXMLData(java.io.Reader reader)
          Reads chart properties from an xml character stream.
 void setAngleOffset(int angleOffset)
          Sets the angle offset.
 void setBackgroundImageArea(int backgroundImageArea)
          Sets the area on which a background image is painted.
 void setCenteredImage(java.awt.Image centeredImage)
          Sets an image to be displayed centered on the polar graph.
 void setGradientColorsArea(int gradientColorsArea)
          Sets the area on which the gradient colors effect is displayed.
 void setHalfEnabled(boolean isHalfEnabled)
          Enables/disables half chart.
 void setOuterTexts(java.lang.String[] outerTexts)
          Sets the texts to be displayed around and outside the polar graph.
 void setOuterTextsBackground(java.awt.Color outerTextsBackground)
          Sets the background color of opaque outer texts.
 void setOuterTextsDegrees(int[] outerTextsDegrees)
          Sets the angles the outer texts form with the center of the polar graph.
 void setOuterTextsFont(java.awt.Font outerTextsFont)
          Sets the font of the outer texts.
 void setOuterTextsForeground(java.awt.Color outerTextsForeground)
          Sets the color of the outer texts.
 void setOuterTextsGap(int outerTextsGap)
          Sets the gap between the outer texts and the outer circle of the polar grid.
 void setOuterTextsOpacityEnabled(boolean isOuterTextsOpacityEnabled)
          Enables/disables the opacity of outer texts' backgrounds.
 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, refresh, removeAllNotes, removeAllSeries, 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

PolarGraph

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

Method Detail

setHalfEnabled

public void setHalfEnabled(boolean isHalfEnabled)
Enables/disables half chart. If enabled, a semi-circle is displayed, covering a range from 0 to 180 degrees. This property is disabled by default.

Parameters:
isHalfEnabled - A boolean value(true/false).

setAngleOffset

public void setAngleOffset(int angleOffset)
Sets the angle offset. The angle offset is a value to be added to each data point angle(theta) value, causing the polar coordinates system to be rotated clockwise or counterclockwise. The angle offset is zero by default.

Parameters:
angleOffset -

getXAxis

public XAxis getXAxis()
Returns a reference to the horizontal axis.

Returns:
XAxis object.
See Also:
XAxis

getYAxis

public YAxis getYAxis()
Returns a reference to the vertical axis.

Returns:
YAxis object.
See Also:
YAxis

getPolarGrid

public PolarGrid getPolarGrid()
Returns a reference to the polar grid object.

Returns:
PolarGrid object.
See Also:
PolarGrid

getScale

public Scale getScale()
Returns a reference to the Scale object.

Returns:
Scale object.
See Also:
Scale

setOuterTexts

public void setOuterTexts(java.lang.String[] outerTexts)
Sets the texts to be displayed around and outside the polar graph. The angles the outer texts form with the center of the polar graph must be specified with the method setOuterTextsDegrees, otherwise the outer texts are not displayed. The text can be wrapped into two or more lines by inserting line-break characters(\n).

Parameters:
outerTexts - An array of strings.
See Also:
setOuterTextsDegrees(int[])

setOuterTextsDegrees

public void setOuterTextsDegrees(int[] outerTextsDegrees)
Sets the angles the outer texts form with the center of the polar graph. The arrays accepted by this method and method setOuterTexts are associated by their indexes, so that the outer text with index 0 is assigned the degree with index 0, and so on.

Parameters:
outerTextsDegrees - An array of integer values.
See Also:
setOuterTexts(java.lang.String[])

setOuterTextsFont

public void setOuterTextsFont(java.awt.Font outerTextsFont)
Sets the font of the outer texts. Default font is SansSerif, plain, 10.

Parameters:
outerTextsFont - A Font object
See Also:
setOuterTexts(java.lang.String[]), setOuterTextsForeground(java.awt.Color)

setOuterTextsForeground

public void setOuterTextsForeground(java.awt.Color outerTextsForeground)
Sets the color of the outer texts. Default color is black.

Parameters:
outerTextsForeground - A Color object
See Also:
setOuterTexts(java.lang.String[]), setOuterTextsBackground(java.awt.Color), setOuterTextsFont(java.awt.Font)

setOuterTextsBackground

public void setOuterTextsBackground(java.awt.Color outerTextsBackground)
Sets the background color of opaque outer texts. The background color is only painted if the opacity of outer texts is enabled. Default color is white.

Parameters:
outerTextsBackground - A Color object
See Also:
setOuterTextsForeground(java.awt.Color), setOuterTexts(java.lang.String[]), setOuterTextsOpacityEnabled(boolean)

setOuterTextsOpacityEnabled

public void setOuterTextsOpacityEnabled(boolean isOuterTextsOpacityEnabled)
Enables/disables the opacity of outer texts' backgrounds. Default value is false, all outer texts' backgrounds are transparent.

Parameters:
isOuterTextsOpacityEnabled - A boolean value(true/false)
See Also:
setOuterTexts(java.lang.String[]), setOuterTextsBackground(java.awt.Color)

setOuterTextsGap

public void setOuterTextsGap(int outerTextsGap)
Sets the gap between the outer texts and the outer circle of the polar grid. Default value is 5 pixels.

Parameters:
outerTextsGap - An integer value
See Also:
setOuterTexts(java.lang.String[])

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

setCenteredImage

public void setCenteredImage(java.awt.Image centeredImage)
Sets an image to be displayed centered on the polar graph.

Parameters:
centeredImage - An Image object.

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

getPolarGraphEventListener

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

See Also:
PolarGraphEventListener

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()

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)
Description copied from class: GradientPanel
Overrides the Component class paint() method to provide gradient effect.

Overrides:
paint in class GradientPanel
Parameters:
gr - A Graphics object.

finalize

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