com.objectplanet.chart.ext
Class GaugeChart

java.lang.Object
  extended by java.awt.Component
      extended by com.objectplanet.chart.ext.GaugeChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GaugeChart
extends java.awt.Component

Author:
Philipp Kolibaba.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int GAUGE_ALIGNMENT_BOTTOM
           
static int GAUGE_ALIGNMENT_CENTER
           
static int GAUGE_ALIGNMENT_LEFT
           
static int GAUGE_ALIGNMENT_RIGHT
           
static int GAUGE_ALIGNMENT_TOP
           
static int GRADIENT_PAINT_DIAGONAL1
          Gradient paint from top left to bottom right
static int GRADIENT_PAINT_DIAGONAL2
          Gradient paint from bottom left to top right
static int GRADIENT_PAINT_HORIZONTAL
          Horizontal gradient paint
static int GRADIENT_PAINT_VERTICAL
          Vertical gradient paint
static int POINTER_STYLE_ARROW
          Used to display pointer as an arrow
static int POINTER_STYLE_LINE
          Used to display pointer as a line
static int POINTER_STYLE_TRIANGLE
          Used to display pointer as a triangle
static int RANGE_LABEL_BORDER
          Range labels display within the border.
static int RANGE_LABEL_INSIDE
          Range labels display inside the gauge.
static int RANGE_LABEL_OUTSIDE
          Range labels display outside the gauge.
static int TICK_STYLE_DIAMOND
          Range tick style diamond
static int TICK_STYLE_ROUND
          Range tick style round
static int TICK_STYLE_THICK
          Range tick style thik strip
static int TICK_STYLE_THIN
          Range tick style thin strip
 
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
GaugeChart()
          Creates a gauge chart.
 
Method Summary
 void addImage(java.lang.String name, java.awt.Image image)
          Adds an image to the chart.
 void addItemListener(java.awt.event.ItemListener l)
          Adds an item listener to the chart.
 void autoRepaint()
          Calls repaint() if the automaticRepaintOn is turned on.
protected  int checkSelection(java.awt.Point point)
          This method is called when the user releases the mouse and checks if the given point is inside a series.
 java.awt.Image createImage(int width, int height)
          Creates an offscreen image.
 java.lang.String formatRangeNumber(int index, double value)
          Formats a floating number to the number of decimals given for the specified range.
 java.awt.Color getBackground2()
          Gets the secondary background of the chart component.
 java.awt.Color getBorderColor(int index)
          Gets color of the specified border.
 java.awt.Color getBorderColor2(int index)
          Gets second color of the specified border.
 int getBorderWidth(int index)
          Gets width of the specified border.
 java.awt.Color getChartBackground()
          Gets the color of the chart background itself.
 java.awt.Color getChartBackground2()
          Gets the secondary background of the chart grid itself.
 java.awt.Color getChartForeground()
          Gets the color of the chart foreground itself.
 java.awt.Color getEdgeColor()
           
 int getEndAngle()
          Gets the end angle of the gauge.
 java.awt.Color getFloatingLabelColor()
          Gets color of the floating labels
 java.awt.Font getFont(java.lang.String label)
          Gets the font for the specified label.
 int getGaugeAlignment()
          Gets gauge alignment inside the component
 java.awt.Image getImage(java.lang.String name)
          Gets the image with the specified name.
protected  java.awt.Dimension getImageSize(java.lang.String name)
          Calculates the size of an image.
 java.lang.String getLabel(java.lang.String name)
          Gets the specified label from the chart.
 java.awt.Color getLegendColor(int index)
          Gets legend entry's color value by it's index.
 java.awt.Color[] getLegendColors()
          Gets the legend colors.
 int getLegendColumns()
          Gets the number of columns used to display the legend labels.
 java.lang.String getLegendImage(int index)
          Gets a legend entry's image name.
 java.lang.String[] getLegendLabels()
          Gets the legend labels.
 int getLegendPosition()
          Gets the legend position.
 double getLowerRange()
          Gets the lower value of the range.
 java.awt.Dimension getMinimumSize()
          This method returns the minimum size of the chart.
 double getPointer(int index)
          Gets value of the pointer with specified index.
 java.awt.Color getPointerColor(int index)
          Gets color of the pointer with specified index.
 java.lang.String getPointerLabel(int index)
          Gets labels associated with pointer with specified index.
 float getPointerSize(int index)
          Gets size of the pointer with specified index.
 double getPointerStyle(int index)
          Gets style of the pointer with specified index.
 java.awt.Dimension getPreferredSize()
          This method is called by the awt, and returns the preferred size of the chart.
 double getRange()
          Gets the upper value of the range.
 java.awt.Color getRangeColor(int range)
          Returns color of the given range.
 int getRangeDecimalCount(int index)
          Gets the number of decimals used in the range values.
 int getRangeEndAngle()
          Gets the end angle of the range.
 java.awt.Color getRangeHighlight()
          Gets the range highlight color.
 double getRangeInterval()
          Gets the interval between the ticks on the specified range.
 java.awt.Color getRangeLabelColor(int range)
          Returns color of the range labels.
 int getRangeLabelStyle()
          Gets style of the range labels.
 int getRangeStartAngle()
          Gets the start angle of the range.
 int getRangeTickSize()
          Gets size of the range ticks.
 int getRangeTickStyle()
          Gets style of the range ticks.
 java.awt.Color getSectorColor(int index)
          Gets color of the sector with specified index.
 double[] getSectorHighlight(int index)
          Gets the start and the end values of the specified sector.
 int getSelectedElement(java.awt.Point point, Legend legend)
          This method is called when the user releases the mouse and checks if the given point is inside a sample.
 int getStartAngle()
          Gets the start angle of the gauge.
 java.lang.String getTitle()
          Gets the chart title.
static java.lang.String getVersion()
          Returns the current version of the charts.
 boolean isFloatingLabelsOn()
           
 boolean isLegendOn()
          Checks if the legend is turned on.
 boolean isLegendReverseOn()
          Returns true if the inverted legend is on.
 boolean isPointerLabelsOn()
          Checks if the pointer labels are turned on.
 boolean isRangeLabelsOn(int range)
          Returns true if the range labels are turned on, false otherwise.
 boolean isServletModeOn()
          Checks if the servlet mode is turned on.
 boolean isTitleOn()
          Checks if the title is turned on.
 java.awt.Image loadImage(java.lang.String name)
          Loads an image from the disk.
 void paint(java.awt.Graphics g)
          This method is overridden to paint the chart using double buffering.
protected  void paintLabel(java.awt.Graphics g, java.lang.String label, int label_x, int label_y, java.awt.Dimension size, int style, int angle, boolean underlined)
          Paints a normal, multiline, and angled label.
protected  void paintLegend(java.awt.Graphics g, Legend legend, java.awt.Rectangle bounds, java.lang.String[] labels)
          Paints the legend.
protected  void paintLegendElement(java.awt.Graphics g, Legend legend, int index, int xpos, int ypos, java.lang.String label, java.awt.FontMetrics fm)
          Paints the particular legend element.
protected  void processEvent(java.awt.AWTEvent event)
          Handles the chart events.
 void removeBorder(int index)
          Removes border with the specified index.
 void removeExternalGraphics()
          Removes external graphics context if there is one.
 void removeItemListener(java.awt.event.ItemListener l)
          Removes the specified item listener from the chart.
 void removePointer(int index)
          Removes pointer with the specified index.
 void render(java.awt.Graphics g)
          Renders the bar chart according to the current chart attributes and which charts features are turned on or off.
 void render(java.awt.Graphics g, boolean offscreenOn)
          Renders the gauge chart according to the current gauge attributes and which charts features are turned on or off.
protected  void renderOffScreen(java.awt.Graphics g)
          A subclass should override this method to paint on top of the chart before it is painted to the AWT component.
 void setBackground(java.awt.Color color)
          Sets the chart component background color, outside the gauge.
 void setBackground2(java.awt.Color color)
          Sets the secondary chart component background color, outside the chart grid.
 void setBorder(int index, int width)
          Sets a border with the specified width (0-based).
 void setBorderColor(int index, java.awt.Color color)
          Sets color for the specified border.
 void setBorderColor(int index, java.awt.Color color, java.awt.Color color2)
          Sets colors for the specified border.
 void setChartBackground(java.awt.Color color)
          Sets the background color of the chart itself.
 void setChartBackground2(java.awt.Color color)
          Sets the secondary background color of the chart itself.
 void setChartForeground(java.awt.Color color)
          Sets the foreground color of the chart itself.
 void setEdgeColor(java.awt.Color edgeColor)
           
 void setEndAngle(int angle)
          Sets the end angle of the gauge.
 void setExternalGraphics(java.awt.Graphics g, java.awt.Image image)
          Sets an external graphics context to paint with.
 void setFloatingLabelColor(java.awt.Color color)
          Sets color of the floating labels
 void setFloatingLabelsOn(boolean on)
          Turns floating labels over the range and pointers on or off.
 void setFont(java.lang.String label, java.awt.Font font)
          Sets the font for the specified label.
 void setForeground(java.awt.Color color)
          Sets the color of the labels.
 void setGaugeAlignment(int alignment)
          Sets gauge alignment inside the component: GAUGE_ALIGNMENT_CENTER | GAUGE_ALIGNMENT_TOP | GAUGE_ALIGNMENT_BOTTOM= 2 | GAUGE_ALIGNMENT_RIGHT = 3 | GAUGE_ALIGNMENT_LEFT
 void setLabel(java.lang.String name, java.lang.String label)
          Sets the specified label in the chart.
 void setLegendColor(int index, java.awt.Color color)
          Sets a legend entry color.
 void setLegendColors(java.awt.Color[] colors)
          Sets the legend colors.
 void setLegendColumns(int columns)
          Sets the number of columns that should be used to display legend labels.
 void setLegendImage(int index, java.lang.String name)
          Sets an image to be used in front of the legend label.
 void setLegendLabels(java.lang.String[] labels)
          Sets the legend labels.
 void setLegendOn(boolean on)
          Turns on or off the label legend.
 void setLegendPosition(int position)
          Sets the legend position.
 void setLegendReverseOn(boolean on)
          Set on or off the inverted legend.
 void setLowerRange(double value)
          Sets the lower value of the range.
 void setPointer(int index, double value)
          Sets a pointer with the specified index (0-based).
 void setPointerColor(int index, java.awt.Color color)
          Sets color for a pointer with the specified index (0-based).
 void setPointerLabel(int index, java.lang.String label)
          Sets labels for the pointer with specified index (0-based).
 void setPointerLabels(java.lang.String[] labels)
          Sets the pointer labels.
 void setPointerLabelsOn(boolean on)
          Turns on or off the pointerLabels.
 void setPointerSize(int index, float size)
          Sets style for the pointer with specified index (0-based).
 void setPointerStyle(int index, int style)
          Sets style for the pointer with specified index (0-based).
 void setPreferredSize(int width, int height)
          Sets the preferred size of the chart.
 void setRange(double value)
          Sets the upper value of the range.
 void setRangeColor(int range, java.awt.Color color)
          Sets color of the range.
 void setRangeDecimalCount(int index, int count)
          Sets the number of decimals to use in the range label values.
 void setRangeEndAngle(int angle)
          Sets the end angle of the range.
 void setRangeHighlight(java.awt.Color color)
          Sets the range highlight color
 void setRangeInterval(double interval)
          Sets interval between the ticks on the specified range.
 void setRangeLabelColor(int range, java.awt.Color color)
          Sets color of the range labels.
 void setRangeLabelsOn(int range, boolean on)
          Turns labels of the given range on or off.
 void setRangeLabelStyle(int style)
          Sets style of the range labels.
 void setRangeStartAngle(int angle)
          Sets the start angle of the range.
 void setRangeTickSize(int size)
          Sets size of the range ticks.
 void setRangeTickStyle(int style)
          Sets style of the range ticks.
 void setSectorColor(int index, java.awt.Color color)
          Sets color for a specified highlight sector.
 void setSectorHighlight(int index, double start, double end)
          Sets a highlighted sector with the specified start and end values in the gauge's range.
 void setServletModeOn(boolean on)
          Turns on or off servlet mode.
 void setStartAngle(int angle)
          Sets the start angle of the gauge.
 void setTitle(java.lang.String title)
          Sets the chart title.
 void setTitleOn(boolean on)
          Turns on or off the chart title.
 void update(java.awt.Graphics g)
          This method is overridden to avoid flicker when the chart is repainted.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GAUGE_ALIGNMENT_BOTTOM

public static final int GAUGE_ALIGNMENT_BOTTOM
See Also:
Constant Field Values

GAUGE_ALIGNMENT_CENTER

public static final int GAUGE_ALIGNMENT_CENTER
See Also:
Constant Field Values

GAUGE_ALIGNMENT_LEFT

public static final int GAUGE_ALIGNMENT_LEFT
See Also:
Constant Field Values

GAUGE_ALIGNMENT_RIGHT

public static final int GAUGE_ALIGNMENT_RIGHT
See Also:
Constant Field Values

GAUGE_ALIGNMENT_TOP

public static final int GAUGE_ALIGNMENT_TOP
See Also:
Constant Field Values

GRADIENT_PAINT_DIAGONAL1

public static final int GRADIENT_PAINT_DIAGONAL1
Gradient paint from top left to bottom right

See Also:
Constant Field Values

GRADIENT_PAINT_DIAGONAL2

public static final int GRADIENT_PAINT_DIAGONAL2
Gradient paint from bottom left to top right

See Also:
Constant Field Values

GRADIENT_PAINT_HORIZONTAL

public static final int GRADIENT_PAINT_HORIZONTAL
Horizontal gradient paint

See Also:
Constant Field Values

GRADIENT_PAINT_VERTICAL

public static final int GRADIENT_PAINT_VERTICAL
Vertical gradient paint

See Also:
Constant Field Values

POINTER_STYLE_ARROW

public static final int POINTER_STYLE_ARROW
Used to display pointer as an arrow

See Also:
Constant Field Values

POINTER_STYLE_LINE

public static final int POINTER_STYLE_LINE
Used to display pointer as a line

See Also:
Constant Field Values

POINTER_STYLE_TRIANGLE

public static final int POINTER_STYLE_TRIANGLE
Used to display pointer as a triangle

See Also:
Constant Field Values

RANGE_LABEL_BORDER

public static final int RANGE_LABEL_BORDER
Range labels display within the border.

See Also:
Constant Field Values

RANGE_LABEL_INSIDE

public static final int RANGE_LABEL_INSIDE
Range labels display inside the gauge.

See Also:
Constant Field Values

RANGE_LABEL_OUTSIDE

public static final int RANGE_LABEL_OUTSIDE
Range labels display outside the gauge.

See Also:
Constant Field Values

TICK_STYLE_DIAMOND

public static final int TICK_STYLE_DIAMOND
Range tick style diamond

See Also:
Constant Field Values

TICK_STYLE_ROUND

public static final int TICK_STYLE_ROUND
Range tick style round

See Also:
Constant Field Values

TICK_STYLE_THICK

public static final int TICK_STYLE_THICK
Range tick style thik strip

See Also:
Constant Field Values

TICK_STYLE_THIN

public static final int TICK_STYLE_THIN
Range tick style thin strip

See Also:
Constant Field Values
Constructor Detail

GaugeChart

public GaugeChart()
Creates a gauge chart.

Method Detail

addImage

public void addImage(java.lang.String name,
                     java.awt.Image image)
Adds an image to the chart.

Parameters:
name - The unique name of the image
image - The image to add, use null to remove the image.

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Adds an item listener to the chart. Any listener registered will be notified when a series is selected or deselected. The event sent will be the ItemEvent event. Use the ItemEvent.getStateChange() to see if the event was a selection or deselection. Use the ItemEvent.getItem()to get the series index selected or deselected.

Parameters:
l - The item listener to add.
See Also:
removeItemListener(java.awt.event.ItemListener)

autoRepaint

public void autoRepaint()
Calls repaint() if the automaticRepaintOn is turned on.


checkSelection

protected int checkSelection(java.awt.Point point)
This method is called when the user releases the mouse and checks if the given point is inside a series. The default behaviour is to check for selection on the legend if the legend is turned on. If any subclass wants to add selection behaviour, override this and call super.checkSelection().

Parameters:
point - The point to check for.
Returns:
The series selected, or -1 if none was selected.

createImage

public java.awt.Image createImage(int width,
                                  int height)
Creates an offscreen image.

Overrides:
createImage in class java.awt.Component
Parameters:
width - The width of the image in pixels.
height - The height of the image in pixels.

formatRangeNumber

public java.lang.String formatRangeNumber(int index,
                                          double value)
Formats a floating number to the number of decimals given for the specified range. The formatted number will have the integer part paired in three and three.

Parameters:
index - The range index.
value - The value to format.
Returns:
A string with the formatted number.

getBackground2

public java.awt.Color getBackground2()
Gets the secondary background of the chart component.


getBorderColor

public java.awt.Color getBorderColor(int index)
Gets color of the specified border.

Parameters:
index - The index of the border (0-based).
Returns:
Color of the specified border or default color if no color is set for this border.

getBorderColor2

public java.awt.Color getBorderColor2(int index)
Gets second color of the specified border.

Parameters:
index - The index of the border (0-based).
Returns:
Color of the specified border

getBorderWidth

public int getBorderWidth(int index)
Gets width of the specified border.

Parameters:
index - The index of the border (0-based).
Returns:
Width of the specified border.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getChartBackground

public java.awt.Color getChartBackground()
Gets the color of the chart background itself.


getChartBackground2

public java.awt.Color getChartBackground2()
Gets the secondary background of the chart grid itself.


getChartForeground

public java.awt.Color getChartForeground()
Gets the color of the chart foreground itself.


getEdgeColor

public java.awt.Color getEdgeColor()

getEndAngle

public int getEndAngle()
Gets the end angle of the gauge.

Returns:
The end angle.

getFloatingLabelColor

public java.awt.Color getFloatingLabelColor()
Gets color of the floating labels

Returns:

getFont

public java.awt.Font getFont(java.lang.String label)
Gets the font for the specified label. If no specific font is specified for this label, it returns the font returned by getFont().

Parameters:
label - The name of the label.
Returns:
The font (never null).

getGaugeAlignment

public int getGaugeAlignment()
Gets gauge alignment inside the component

Returns:
gauge alignment inside the component

getImage

public java.awt.Image getImage(java.lang.String name)
Gets the image with the specified name.

Parameters:
name - The name of the image.
Returns:
The image, or null if no image was found.

getImageSize

protected java.awt.Dimension getImageSize(java.lang.String name)
Calculates the size of an image. If there is no image for this index, 0 is returned.

Parameters:
name - The name of the image to check size for.
Returns:
The size of an image.

getLabel

public java.lang.String getLabel(java.lang.String name)
Gets the specified label from the chart.

Parameters:
name - The name of the label.
Returns:
The label, or null if not found.
See Also:
setLabel(java.lang.String, java.lang.String)

getLegendColor

public java.awt.Color getLegendColor(int index)
Gets legend entry's color value by it's index.

Parameters:
index - The index of the legend entry to get color from.
Returns:
Color of the given legend entry.

getLegendColors

public java.awt.Color[] getLegendColors()
Gets the legend colors.

Returns:
The array with legend colors.

getLegendColumns

public int getLegendColumns()
Gets the number of columns used to display the legend labels.

Returns:
Number of legend columns.

getLegendImage

public java.lang.String getLegendImage(int index)
Gets a legend entry's image name.

Parameters:
index - The index of the legend entry.
Returns:
The name of the image, or null if the default legend box is used.

getLegendLabels

public java.lang.String[] getLegendLabels()
Gets the legend labels. The array returned is the original, so don't change anything in it if you don't know what you are doing.

Returns:
An array containing the labels.
See Also:
setLegendLabels(java.lang.String[])

getLegendPosition

public int getLegendPosition()
Gets the legend position.

Returns:
TOP, BOTTOM, LEFT, or RIGHT.

getLowerRange

public double getLowerRange()
Gets the lower value of the range.


getMinimumSize

public java.awt.Dimension getMinimumSize()
This method returns the minimum size of the chart. The default chart size is 100 by 70 pixels.

Overrides:
getMinimumSize in class java.awt.Component

getPointer

public double getPointer(int index)
Gets value of the pointer with specified index.

Parameters:
index - The index of the pointer (0-based).
Returns:
Value of the specified pointer.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getPointerColor

public java.awt.Color getPointerColor(int index)
Gets color of the pointer with specified index.

Parameters:
index - The index of the pointer (0-based).
Returns:
Color value of the specified pointer.

getPointerLabel

public java.lang.String getPointerLabel(int index)
Gets labels associated with pointer with specified index.

Parameters:
index - The index of the pointer (0-based).
Returns:
The labels associated with the pointer.

getPointerSize

public float getPointerSize(int index)
Gets size of the pointer with specified index.

Parameters:
index - The index of the pointer (0-based).
Returns:
The size of the pointer (a float value from 0.0 to 2.0, where the standart value is 1.0)

getPointerStyle

public double getPointerStyle(int index)
Gets style of the pointer with specified index.

Parameters:
index - The index of the pointer (0-based).
Returns:
Style value of the specified pointer. (POINTER_TYPE_LINE == 0, POINTER_TYPE_TRIANGLE == 1, POINTER_TYPE_ARROW == 2).
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getPreferredSize

public java.awt.Dimension getPreferredSize()
This method is called by the awt, and returns the preferred size of the chart. The default size of the chart is 300 by 200 pixels.

Overrides:
getPreferredSize in class java.awt.Component

getRange

public double getRange()
Gets the upper value of the range.


getRangeColor

public java.awt.Color getRangeColor(int range)
Returns color of the given range.

Parameters:
range - Index of the range.
Returns:
Color of the range.

getRangeDecimalCount

public int getRangeDecimalCount(int index)
Gets the number of decimals used in the range values.

Parameters:
index - The index of the range.

getRangeEndAngle

public int getRangeEndAngle()
Gets the end angle of the range.

Returns:
The end angle.

getRangeHighlight

public java.awt.Color getRangeHighlight()
Gets the range highlight color.


getRangeInterval

public double getRangeInterval()
Gets the interval between the ticks on the specified range.

Returns:
Interval between the range ticks.

getRangeLabelColor

public java.awt.Color getRangeLabelColor(int range)
Returns color of the range labels.

Parameters:
range - Index of the range.
Returns:
Color of the range labels.

getRangeLabelStyle

public int getRangeLabelStyle()
Gets style of the range labels.

Returns:
Style of the range labels (RANGE_LABEL_INSIDE = 0 | RANGE_LABEL_OUTSIDE = 1 | RANGE_LABEL_BORDER = 2).

getRangeStartAngle

public int getRangeStartAngle()
Gets the start angle of the range.

Returns:
The start angle.

getRangeTickSize

public int getRangeTickSize()
Gets size of the range ticks.

Returns:
Size of the range ticks.

getRangeTickStyle

public int getRangeTickStyle()
Gets style of the range ticks.

Returns:
Style of the range ticks (RANGE_LABEL_INSIDE = 0 | RANGE_LABEL_OUTSIDE = 1 | RANGE_LABEL_BORDER = 2).

getSectorColor

public java.awt.Color getSectorColor(int index)
Gets color of the sector with specified index.

Parameters:
index - The index of the highlighted sector (0-based).
Returns:
Color of the specified sector or default sector color if no color is set for this sector.

getSectorHighlight

public double[] getSectorHighlight(int index)
Gets the start and the end values of the specified sector.

Parameters:
index - The index of the highlighted sector (0-based).
Returns:
Array of two values where the first is start value and the second is end value.
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

getSelectedElement

public int getSelectedElement(java.awt.Point point,
                              Legend legend)
This method is called when the user releases the mouse and checks if the given point is inside a sample. The default behavior is to check for selection on the legend if the legend is turned on. If the number of series is 1, the selected label in the legend corresponds to the respective sample in the chart. If the number of series is more than 1, the returned sample will have the series index set, but the sample index will be set to -1. If any subclass wants to add selection behavior, override this and call super.checkSelection().

Parameters:
point - The point to check for.
legend - The legend to paint.
Returns:
The sample selected, or null if none was selected.

getStartAngle

public int getStartAngle()
Gets the start angle of the gauge.

Returns:
The start angle.

getTitle

public java.lang.String getTitle()
Gets the chart title.

See Also:
setTitle(java.lang.String)

getVersion

public static java.lang.String getVersion()
Returns the current version of the charts.


isFloatingLabelsOn

public boolean isFloatingLabelsOn()
Returns:
Returns true if the floating labels over the range and pointersare turned on, false otherwise.

isLegendOn

public boolean isLegendOn()
Checks if the legend is turned on.

Returns:
True for on, false for off.

isLegendReverseOn

public boolean isLegendReverseOn()
Returns true if the inverted legend is on.

Returns:
Number of legend columns.

isPointerLabelsOn

public boolean isPointerLabelsOn()
Checks if the pointer labels are turned on.

Returns:
True if on, false if off.

isRangeLabelsOn

public boolean isRangeLabelsOn(int range)
Returns true if the range labels are turned on, false otherwise.

Parameters:
range - Index of the range.
Returns:
True if the range labels are turned on, false otherwise.

isServletModeOn

public boolean isServletModeOn()
Checks if the servlet mode is turned on.

Returns:
True for on, false for off.

isTitleOn

public boolean isTitleOn()
Checks if the title is turned on.

Returns:
True if on, false if off.

loadImage

public java.awt.Image loadImage(java.lang.String name)
Loads an image from the disk.

Parameters:
name - The file name of the image.
Returns:
The image loaded, or null if not found or it failed.

paint

public final void paint(java.awt.Graphics g)
This method is overridden to paint the chart using double buffering. This is done to avoid flickering.

Overrides:
paint in class java.awt.Component

paintLabel

protected void paintLabel(java.awt.Graphics g,
                          java.lang.String label,
                          int label_x,
                          int label_y,
                          java.awt.Dimension size,
                          int style,
                          int angle,
                          boolean underlined)
Paints a normal, multiline, and angled label. The lines are broken with \n.

Parameters:
g - The graphics context used to paint with.
label - The label to paint.
label_x - The x position of the label.
label_y - The y position of the label.
size - The size of the unrotated label.
style - -1 for left, 0 for center, 1 for right.
angle - The degrees to turn the label (only 0, 90, 180, 270 works fine).
underlined - If true the label is underlined (can be used for URLs, ony for non-angled labels).

paintLegend

protected void paintLegend(java.awt.Graphics g,
                           Legend legend,
                           java.awt.Rectangle bounds,
                           java.lang.String[] labels)
Paints the legend.

Parameters:
g - The graphics context used to paint with.
legend - The legend to paint.
bounds - The chart grid bounds.
labels - The labels of the legend.

paintLegendElement

protected void paintLegendElement(java.awt.Graphics g,
                                  Legend legend,
                                  int index,
                                  int xpos,
                                  int ypos,
                                  java.lang.String label,
                                  java.awt.FontMetrics fm)
Paints the particular legend element.

Parameters:
g - The graphics context used to paint with.
legend - The legend to paint.
index - The index of element inside the legend.
xpos - The x position if the element.
ypos - The y position if the element.
label - The legend label.
fm - The font metrics used to paint label with.

processEvent

protected void processEvent(java.awt.AWTEvent event)
Handles the chart events.

Overrides:
processEvent in class java.awt.Component
Parameters:
event - The event to process.

removeBorder

public void removeBorder(int index)
Removes border with the specified index.

Parameters:
index - The index of the border (0-based).
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

removeExternalGraphics

public void removeExternalGraphics()
Removes external graphics context if there is one.

See Also:
setExternalGraphics(java.awt.Graphics, java.awt.Image)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes the specified item listener from the chart.

Parameters:
l - The item listener to remove.
See Also:
addItemListener(java.awt.event.ItemListener)

removePointer

public void removePointer(int index)
Removes pointer with the specified index.

Parameters:
index - The index of the pointer (0-based).
Throws:
java.lang.IllegalArgumentException - if the index is invalid.

render

public void render(java.awt.Graphics g)
Renders the bar chart according to the current chart attributes and which charts features are turned on or off.


render

public final void render(java.awt.Graphics g,
                         boolean offscreenOn)
Renders the gauge chart according to the current gauge attributes and which charts features are turned on or off.


renderOffScreen

protected void renderOffScreen(java.awt.Graphics g)
A subclass should override this method to paint on top of the chart before it is painted to the AWT component. This is done to avoid flicker of graphics painted by these subclasses.

Parameters:
g - The graphics context used to paint with.

setBackground

public void setBackground(java.awt.Color color)
Sets the chart component background color, outside the gauge.

Overrides:
setBackground in class java.awt.Component
Parameters:
color - The color to use.

setBackground2

public void setBackground2(java.awt.Color color)
Sets the secondary chart component background color, outside the chart grid. the secondary background can be used in order to display gradient background. Use the setChartBackground() method to set the chart grid color.

Parameters:
color - The color to use.
See Also:
setChartBackground(java.awt.Color)

setBorder

public void setBorder(int index,
                      int width)
Sets a border with the specified width (0-based).

Parameters:
index - The index of the border.
width - The width of the border

setBorderColor

public void setBorderColor(int index,
                           java.awt.Color color)
Sets color for the specified border.

Parameters:
index - The index of the border.
color - The color of the border.

setBorderColor

public void setBorderColor(int index,
                           java.awt.Color color,
                           java.awt.Color color2)
Sets colors for the specified border. This method should be used in order to display gradient borders.

Parameters:
index - The index of the border.
color - The first color of the border.

setChartBackground

public void setChartBackground(java.awt.Color color)
Sets the background color of the chart itself. Use setBackground() to set the background color outside the gauge itself.

Parameters:
color - The color to use.

setChartBackground2

public void setChartBackground2(java.awt.Color color)
Sets the secondary background color of the chart itself. The secondary background can be used in order to display gradient chart grid background.

Parameters:
color - The color to use.

setChartForeground

public void setChartForeground(java.awt.Color color)
Sets the foreground color of the chart itself. Use setForeground() to set the color of the title, value labels, and other text.

Parameters:
color - The color to use.

setEdgeColor

public void setEdgeColor(java.awt.Color edgeColor)

setEndAngle

public void setEndAngle(int angle)
Sets the end angle of the gauge. The 0 angle corresponds to the lowest point of the gauge, 90 to the leftmost, 180 - uppermost, 270 - rightmost.

Parameters:
angle - The end angle.

setExternalGraphics

public void setExternalGraphics(java.awt.Graphics g,
                                java.awt.Image image)
Sets an external graphics context to paint with. The size of the image must at least as large as the largest chart that will be displayed.

Parameters:
g - The graphics context used for painting.
image - The image to which graphics context belongs. See here for an example.

setFloatingLabelColor

public void setFloatingLabelColor(java.awt.Color color)
Sets color of the floating labels

Parameters:
color -

setFloatingLabelsOn

public void setFloatingLabelsOn(boolean on)
Turns floating labels over the range and pointers on or off.

Parameters:
on - True if the floating labels should be turned on, false otherwise.

setFont

public void setFont(java.lang.String label,
                    java.awt.Font font)
Sets the font for the specified label. To remove the font and use the default one, pass in the font as null.

Parameters:
label - "titleFont" or "rangeLabelFont".
font - The font to set for the label.

setForeground

public void setForeground(java.awt.Color color)
Sets the color of the labels.

Overrides:
setForeground in class java.awt.Component
Parameters:
color - The color to use.

setGaugeAlignment

public void setGaugeAlignment(int alignment)
Sets gauge alignment inside the component: GAUGE_ALIGNMENT_CENTER | GAUGE_ALIGNMENT_TOP | GAUGE_ALIGNMENT_BOTTOM= 2 | GAUGE_ALIGNMENT_RIGHT = 3 | GAUGE_ALIGNMENT_LEFT

Parameters:
gaugeAlignment - Gauge alignment inside the component.

setLabel

public void setLabel(java.lang.String name,
                     java.lang.String label)
Sets the specified label in the chart.

Parameters:
name - The name of the label.
label - The label to use, null for no label.

setLegendColor

public void setLegendColor(int index,
                           java.awt.Color color)
Sets a legend entry color.

Parameters:
index - The index of the legend entry to set Color for.
color - The color to set for the legend entry.
See Also:
setLegendColors(java.awt.Color[]), setLegendImage(int, java.lang.String)

setLegendColors

public void setLegendColors(java.awt.Color[] colors)
Sets the legend colors. By default the legend colors are taken from the sample colors.

Parameters:
colors - The array with legend colors.
Throws:
java.lang.IllegalArgumentException - if the colors is null.
See Also:
setLegendColors(java.awt.Color[]), setLegendImage(int, java.lang.String)

setLegendColumns

public void setLegendColumns(int columns)
Sets the number of columns that should be used to display legend labels.

Parameters:
columns - Number of columns to display legends on. If columns is set to 0, the default legend rendering is used.

setLegendImage

public void setLegendImage(int index,
                           java.lang.String name)
Sets an image to be used in front of the legend label. The image itself must be added prior to calling this method using the addImage() method.

Parameters:
index - The index of the legend entry to set the image for.
name - The image to use, null for the default legend box.
See Also:
addImage(java.lang.String, java.awt.Image)

setLegendLabels

public void setLegendLabels(java.lang.String[] labels)
Sets the legend labels. If the number of series, the default legend labels are the sampleLabels and if the number of series is larger than 1, the legend labels are the series labels. This method overrides the default legend labels. To use the series label when only one series, call setLegendLabels(getSeriesLabels());

Parameters:
labels - The labels to use, null for default behavior.

setLegendOn

public void setLegendOn(boolean on)
Turns on or off the label legend. The label legend displays the label for each of the samples with each sample keyed by its color code. The legend can be displayed on the top, bottom, left, or right of the chart.

Parameters:
on - True if the legend should be displayed.
See Also:
setLegendPosition(int)

setLegendPosition

public void setLegendPosition(int position)
Sets the legend position. The legend can be displayed at the top, bottom, left, or right side of the chart.

Parameters:
position - TOP, BOTTOM, LEFT, or RIGHT.
Throws:
java.lang.IllegalArgumentException - If the position is invalid.

setLegendReverseOn

public void setLegendReverseOn(boolean on)
Set on or off the inverted legend. Default legend entry order is from top to bottom and from left to right.

Parameters:
on - If true the legend entryes are displayed from bottom to top and from right to left.

setLowerRange

public void setLowerRange(double value)
Sets the lower value of the range.

Parameters:
value - The range value to set.

setPointer

public void setPointer(int index,
                       double value)
Sets a pointer with the specified index (0-based).

Parameters:
index - The index of the pointer (0-based).
value - The value of the pointer.

setPointerColor

public void setPointerColor(int index,
                            java.awt.Color color)
Sets color for a pointer with the specified index (0-based).

Parameters:
index - The index of the pointer (0-based).
color - The color of the pointer.

setPointerLabel

public void setPointerLabel(int index,
                            java.lang.String label)
Sets labels for the pointer with specified index (0-based).

Parameters:
index - The index of the pointer (0-based).
labels - The labels associated with the pointer.

setPointerLabels

public void setPointerLabels(java.lang.String[] labels)
Sets the pointer labels.

Parameters:
labels - The labels to use.

setPointerLabelsOn

public void setPointerLabelsOn(boolean on)
Turns on or off the pointerLabels. The pointer labels are displayed on the legend and floating over the pointer.

Parameters:
on - True for on, false for off.

setPointerSize

public void setPointerSize(int index,
                           float size)
Sets style for the pointer with specified index (0-based).

Parameters:
index - The index of the pointer (0-based).
size - The size of the pointer (a float value from 0.0 to 2.0, where the standart value is 1.0)

setPointerStyle

public void setPointerStyle(int index,
                            int style)
Sets style for the pointer with specified index (0-based).

Parameters:
index - The index of the pointer (0-based).
style - The type of the pointer (POINTER_TYPE_LINE, POINTER_TYPE_TRIANGLE, POINTER_TYPE_ARROW).

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Sets the preferred size of the chart. This is the size used with layout managers that do not stretch the component.

Parameters:
width - The preferred width.
height - The preferred height.

setRange

public void setRange(double value)
Sets the upper value of the range.

Parameters:
value - The range value to set.

setRangeColor

public void setRangeColor(int range,
                          java.awt.Color color)
Sets color of the range. By default the range is painted with chart foreground color.

Parameters:
range - Index of the range.
color - Color of the range.

setRangeDecimalCount

public void setRangeDecimalCount(int index,
                                 int count)
Sets the number of decimals to use in the range label values.

Parameters:
index - The index of the range (0 or 1).
count - The number of decimals to use.

setRangeEndAngle

public void setRangeEndAngle(int angle)
Sets the end angle of the range. The 0 angle corresponds to the lowest point of the range, 90 to the leftmost, 180 - uppermost, 270 - rightmost.

Parameters:
angle - The end angle.

setRangeHighlight

public void setRangeHighlight(java.awt.Color color)
Sets the range highlight color

Parameters:
color - The color highlight the range with

setRangeInterval

public void setRangeInterval(double interval)
Sets interval between the ticks on the specified range.

Parameters:
interval - The interval between the to range ticks.

setRangeLabelColor

public void setRangeLabelColor(int range,
                               java.awt.Color color)
Sets color of the range labels. By default the range labels are painted with the same color as the range ticks.

Parameters:
range - Index of the range.
color - Color of the range labels.

setRangeLabelsOn

public void setRangeLabelsOn(int range,
                             boolean on)
Turns labels of the given range on or off.

Parameters:
range - Index of the range.
on - True if the reange labels should be turned on, false otherwise.

setRangeLabelStyle

public void setRangeLabelStyle(int style)
Sets style of the range labels.

Parameters:
style - The style of the range labels (RANGE_LABEL_INSIDE | RANGE_LABEL_OUTSIDE | RANGE_LABEL_BORDER).

setRangeStartAngle

public void setRangeStartAngle(int angle)
Sets the start angle of the range. The 0 angle corresponds to the lowest point of the gauge, 90 to the leftmost, 180 - uppermost, 270 - rightmost.

Parameters:
angle - The start angle.

setRangeTickSize

public void setRangeTickSize(int size)
Sets size of the range ticks.

Parameters:
style - The size of the range ticks.

setRangeTickStyle

public void setRangeTickStyle(int style)
Sets style of the range ticks.

Parameters:
style - The style of the range ticks (RANGE_LABEL_INSIDE | RANGE_LABEL_OUTSIDE | RANGE_LABEL_BORDER).

setSectorColor

public void setSectorColor(int index,
                           java.awt.Color color)
Sets color for a specified highlight sector.

Parameters:
index - The index of the sector.
color - The color of the sector.

setSectorHighlight

public void setSectorHighlight(int index,
                               double start,
                               double end)
Sets a highlighted sector with the specified start and end values in the gauge's range.

Parameters:
index - The index of the sector.
start - The start value of the sector.
end - The end value of the sector.

setServletModeOn

public void setServletModeOn(boolean on)
Turns on or off servlet mode. In servlet mode double buffering and label cashing is turned off.

Parameters:
on - True for servlet mode on, false for servlet mode off.

setStartAngle

public void setStartAngle(int angle)
Sets the start angle of the gauge. The 0 angle corresponds to the lowest point of the gauge, 90 to the leftmost, 180 - uppermost, 270 - rightmost.

Parameters:
angle - The start angle.

setTitle

public void setTitle(java.lang.String title)
Sets the chart title. The chart title is displayed at the chart's top.

Parameters:
title - The title to set.
See Also:
getTitle(), setTitleOn(boolean)

setTitleOn

public void setTitleOn(boolean on)
Turns on or off the chart title. The chart title is displayed at the top of the chart.

Parameters:
on - True for on, false for off.
See Also:
setTitle(java.lang.String)

update

public final void update(java.awt.Graphics g)
This method is overridden to avoid flicker when the chart is repainted.

Overrides:
update in class java.awt.Component