JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart
Class JCChartLegendManager

java.lang.Object
  |
  +--com.klg.jclass.chart.JCChartLegendManager
All Implemented Interfaces:
JCLegendPopulator, JCLegendRenderer, Serializable

public class JCChartLegendManager
extends Object
implements JCLegendPopulator, JCLegendRenderer, Serializable

JCChartLegend manages the populating and rendering of legend items in a JClass Chart.

See Also:
Serialized Form

Field Summary
protected  com.klg.jclass.chart.CachedViewProps[] cachedView
          Cached data views, series, and related data used by legend drawing.
protected  com.klg.jclass.chart.JCChart chart
          The JCChart instance for which this class is managing.
protected  List legendItems
          Legend vector -- contains all items in the legend, organized into subvectors representing one column (usually defined by one data view) of the legend.
 
Constructor Summary
JCChartLegendManager(com.klg.jclass.chart.JCChart c)
          Internal constructor for legend.
 
Method Summary
protected  void calcSymbolSize(com.klg.jclass.util.legend.JCLegendItem newItem, com.klg.jclass.chart.JCChartStyle style, int chartType)
          Calculates the appropriate symbol size to be used for a legend item.
 void drawLegendItem(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          JCLegendRenderer method that is not used for this implementation.
 void drawLegendItemSymbol(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          Draws one legend item based on the size and position given in it's JCLegendItem instance.
 void drawLegendItemText(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          Used for implementing custom text draws for a legend item.
 List getLegendItems(FontMetrics fm)
          Creates the list of legend items from the chart's data views and populates the legend with it.
 Color getOutlineColor(com.klg.jclass.util.legend.JCLegendItem thisItem)
          Retrieves the appropriate outline color for this legend item's symbol.
protected  boolean isFirst(int chartType)
          This method returns true if the first visible data view is of the specified chart type.
 boolean isTitleItem(com.klg.jclass.util.legend.JCLegendItem item)
          Checks if the legend item is a title.
 void setFillGraphics(Graphics gc, com.klg.jclass.util.legend.JCLegendItem thisItem)
          Sets the supplied Graphics object with the appropriate drawing properties for this legend item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

legendItems

protected List legendItems
Legend vector -- contains all items in the legend, organized into subvectors representing one column (usually defined by one data view) of the legend.


cachedView

protected transient com.klg.jclass.chart.CachedViewProps[] cachedView
Cached data views, series, and related data used by legend drawing. These must be the same as those used in legend population.


chart

protected com.klg.jclass.chart.JCChart chart
The JCChart instance for which this class is managing.

Constructor Detail

JCChartLegendManager

public JCChartLegendManager(com.klg.jclass.chart.JCChart c)
Internal constructor for legend.

Parameters:
c - internal constructor
Method Detail

isFirst

protected boolean isFirst(int chartType)
This method returns true if the first visible data view is of the specified chart type.

Parameters:
chartType -
Returns:
true is the first visible data view is of the specified chart type; false otherwise

getLegendItems

public List getLegendItems(FontMetrics fm)
Creates the list of legend items from the chart's data views and populates the legend with it.

Specified by:
getLegendItems in interface JCLegendPopulator
Parameters:
fm - the FontMetrics for this legend
Returns:
the list of legend items

calcSymbolSize

protected void calcSymbolSize(com.klg.jclass.util.legend.JCLegendItem newItem,
                              com.klg.jclass.chart.JCChartStyle style,
                              int chartType)
Calculates the appropriate symbol size to be used for a legend item. Also notes the appropriate draw type.

Parameters:
newItem - the legend item in question
style - the style object used by this legend item
chartType - the chart type associated with this legend item

drawLegendItem

public void drawLegendItem(Graphics gc,
                           Font useFont,
                           com.klg.jclass.util.legend.JCLegendItem thisItem)
JCLegendRenderer method that is not used for this implementation. Just return.

Specified by:
drawLegendItem in interface JCLegendRenderer
Parameters:
gc - the graphics context
useFont - the font used for this legend
thisItem - the legend item to draw (a JCLegendItem instance)

drawLegendItemSymbol

public void drawLegendItemSymbol(Graphics gc,
                                 Font useFont,
                                 com.klg.jclass.util.legend.JCLegendItem thisItem)
Draws one legend item based on the size and position given in it's JCLegendItem instance. The symbol to be drawn is derived from the chart type and the symbol style for the series.

Specified by:
drawLegendItemSymbol in interface JCLegendRenderer
Parameters:
gc - the graphics context
useFont - the font used for this legend
thisItem - the legend item to draw (a JCLegendItem instance)

drawLegendItemText

public void drawLegendItemText(Graphics gc,
                               Font useFont,
                               com.klg.jclass.util.legend.JCLegendItem thisItem)
Used for implementing custom text draws for a legend item. This method is called when a legend item's contents field contains an object other than a String object.

Specified by:
drawLegendItemText in interface JCLegendRenderer
Parameters:
gc - Graphics object used to draw the legend
useFont - the font being used in this legend
thisItem - the JCLegendItem object representing the legend item to draw

getOutlineColor

public Color getOutlineColor(com.klg.jclass.util.legend.JCLegendItem thisItem)
Retrieves the appropriate outline color for this legend item's symbol. In Chart, this is the chart area's foreground color.

Specified by:
getOutlineColor in interface JCLegendRenderer
Parameters:
thisItem - the legend item in question
Returns:
the appropriate color to use to outline the legend symbol

setFillGraphics

public void setFillGraphics(Graphics gc,
                            com.klg.jclass.util.legend.JCLegendItem thisItem)
Sets the supplied Graphics object with the appropriate drawing properties for this legend item. The actual draw will be done by the legend class.

Specified by:
setFillGraphics in interface JCLegendRenderer
Parameters:
gc - the Graphics object to change
thisItem - the legend item in question

isTitleItem

public boolean isTitleItem(com.klg.jclass.util.legend.JCLegendItem item)
Checks if the legend item is a title. In this implementation, title items have a null series and no symbol attached.

Specified by:
isTitleItem in interface JCLegendPopulator
Parameters:
item - the legend item in question
Returns:
true if the legend item is a title.

Copyright © 2004 Quest Software Inc..
All rights reserved.