JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d
Class JCChart3dLegendManager

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

public class JCChart3dLegendManager
extends Object
implements JCLegendRenderer, JCLegendPopulator, Serializable

This is the default implementation of both JCLegendPopulator and JCLegendRenderer. These interfaces, respectively, control the creation and display characteristics of the JCLegendItems.

See Also:
JCLegend.setLegendPopulator(com.klg.jclass.util.legend.JCLegendPopulator), JCLegend.setLegendRenderer(com.klg.jclass.util.legend.JCLegendRenderer), Serialized Form

Field Summary
protected  com.klg.jclass.chart3d.JCChart3d chart3d
          The 3d chart instance containing the legend.
protected  int fieldGap
          The gap between fields in JCMultiColumnStrings.
protected  com.klg.jclass.util.legend.JCLegend legend
          The legend being managed by this class.
protected  Vector legendItems
          List of legend items to be passed to the legend.
protected  int[] maxFieldWidths
          The max value of each field used in a JCMultiColumnString object.
protected  Color outlineColor
          User-specified outline color for legend items.
protected static int STYLE_BOX_RANGE
           
protected static int STYLE_CNTN_H
           
protected static int STYLE_CNTN_V
           
protected static int STYLE_CONTOUR
           
protected static int STYLE_LINE_RANGE
           
protected static int STYLE_NONE
           
protected static int STYLE_SYMBOL_RANGE
           
 
Constructor Summary
JCChart3dLegendManager(com.klg.jclass.chart3d.JCChart3d chart3d, com.klg.jclass.util.legend.JCLegend legend)
          Creates a Populator and Renderer for a JCLegend.
 
Method Summary
protected  void calcTextWidthsFromFields(int numTextFields, List legendItems, com.klg.jclass.chart3d.JCChart3dLegendTemplate threeDLegend, FontMetrics fm)
          Runs through the given list of legend items and adjusts text sizes for the number of fields being used by JCMultiFieldString objects.
 void drawLegendItem(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          For implementing custom legend item draws.
 void drawLegendItemSymbol(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          For implementing custom legend item symbol draws.
 void drawLegendItemText(Graphics gc, Font useFont, com.klg.jclass.util.legend.JCLegendItem thisItem)
          For implementing custom legend item text draws.
protected  Vector filterLevels(com.klg.jclass.chart3d.Chart3dDataView view, int legendStyle, com.klg.jclass.chart3d.JCChart3dLegendTemplate threeDLegend, com.klg.jclass.chart3d.JCContour contour)
          Filters the contour levels into a list that can be used to create legend item labels.
 int getFieldGap()
          Gets the value being used as a gap between fields in JCMultiColumnString objects.
 List getLegendItems(FontMetrics fm)
          Creates legend items for each range listed in the ranges list.
protected  Object getNonScatterLabel(int legendStyle, com.klg.jclass.chart3d.JCChart3dNumberFormat formatter, int nfrac, Vector levels, List userLabels, int index, com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator labelGenerator)
          Gets the label for a legend item in a non-Scatter legend.
 Color getOutlineColor(com.klg.jclass.util.legend.JCLegendItem thisItem)
          Gets the outline color to use when drawing this legend item's symbol.
 boolean isTitleItem(com.klg.jclass.util.legend.JCLegendItem item)
          Indicates if an item is a title, creating a way to identify it from all the other JCLegendItems.
protected  int populate3dLegendItem(com.klg.jclass.util.legend.JCLegendItem item, FontMetrics fm, Object label, int drawType, Dimension symbolDim, Object itemInfo, int numTextFields)
          Populates a legend item for the 3d legend.
 void setFieldGap(int gap)
          Sets the value to use as a gap between fields in JCMultiColumnString objects.
 void setFillGraphics(Graphics gc, com.klg.jclass.util.legend.JCLegendItem thisItem)
          Sets the provided Graphics object with the appropriate settings to use when drawing this legend item's symbol.
 void setOutlineColor(Color outlineColor)
          Sets the outline color to use when drawing this legend item's symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chart3d

protected com.klg.jclass.chart3d.JCChart3d chart3d
The 3d chart instance containing the legend.


legend

protected com.klg.jclass.util.legend.JCLegend legend
The legend being managed by this class.


outlineColor

protected Color outlineColor
User-specified outline color for legend items.


legendItems

protected Vector legendItems
List of legend items to be passed to the legend.


fieldGap

protected int fieldGap
The gap between fields in JCMultiColumnStrings.


maxFieldWidths

protected int[] maxFieldWidths
The max value of each field used in a JCMultiColumnString object.


STYLE_NONE

protected static final int STYLE_NONE
See Also:
Constant Field Values

STYLE_BOX_RANGE

protected static final int STYLE_BOX_RANGE
See Also:
Constant Field Values

STYLE_LINE_RANGE

protected static final int STYLE_LINE_RANGE
See Also:
Constant Field Values

STYLE_SYMBOL_RANGE

protected static final int STYLE_SYMBOL_RANGE
See Also:
Constant Field Values

STYLE_CONTOUR

protected static final int STYLE_CONTOUR
See Also:
Constant Field Values

STYLE_CNTN_H

protected static final int STYLE_CNTN_H
See Also:
Constant Field Values

STYLE_CNTN_V

protected static final int STYLE_CNTN_V
See Also:
Constant Field Values
Constructor Detail

JCChart3dLegendManager

public JCChart3dLegendManager(com.klg.jclass.chart3d.JCChart3d chart3d,
                              com.klg.jclass.util.legend.JCLegend legend)
Creates a Populator and Renderer for a JCLegend.

Parameters:
chart3d -
legend - the JCLegend that this class will populate and render JCLegendItems for
Method Detail

setFieldGap

public void setFieldGap(int gap)
Sets the value to use as a gap between fields in JCMultiColumnString objects.

Parameters:
gap - the field gap

getFieldGap

public int getFieldGap()
Gets the value being used as a gap between fields in JCMultiColumnString objects.

Returns:
the field gap

getLegendItems

public List getLegendItems(FontMetrics fm)
Creates legend items for each range listed in the ranges list. This uses the range name and range foreground color to create the JCLegendItems.

Specified by:
getLegendItems in interface JCLegendPopulator
Parameters:
fm - FontMetrics - information about the font in which legend text will be written
Returns:

filterLevels

protected Vector filterLevels(com.klg.jclass.chart3d.Chart3dDataView view,
                              int legendStyle,
                              com.klg.jclass.chart3d.JCChart3dLegendTemplate threeDLegend,
                              com.klg.jclass.chart3d.JCContour contour)
Filters the contour levels into a list that can be used to create legend item labels.

Parameters:
view -
legendStyle - style of this legend; one of STYLE_CNTN_H, STYLE_CNTN_V, STYLE_CONTOUR, STYLE_BOX_RANGE, or STYLE_LINE_RANGE
threeDLegend - the legend class if it implements the JCChart3DLegendTemplate interface
contour - the JCContour object representing the contour levels
Returns:

getNonScatterLabel

protected Object getNonScatterLabel(int legendStyle,
                                    com.klg.jclass.chart3d.JCChart3dNumberFormat formatter,
                                    int nfrac,
                                    Vector levels,
                                    List userLabels,
                                    int index,
                                    com.klg.jclass.chart3d.JCChart3dLegendLabelGenerator labelGenerator)
Gets the label for a legend item in a non-Scatter legend.

Parameters:
legendStyle - style of this legend; one of STYLE_CNTN_H, STYLE_CNTN_V, STYLE_CONTOUR, STYLE_BOX_RANGE, or STYLE_LINE_RANGE
formatter - class used to format labels from numbers
nfrac - the number of fractional digits in the formatted label
levels - the array of range levels (used for default labels)
userLabels - a List of user-set labels; possibly null
index - the index of the current range level
labelGenerator - user-set generator for custom labels; possibly null
Returns:
the label to use for this legend item

populate3dLegendItem

protected int populate3dLegendItem(com.klg.jclass.util.legend.JCLegendItem item,
                                   FontMetrics fm,
                                   Object label,
                                   int drawType,
                                   Dimension symbolDim,
                                   Object itemInfo,
                                   int numTextFields)
Populates a legend item for the 3d legend. If the label is a JCMultiFieldString, it notes the number of fields and returns the value. Item text dimensions are determined from the label parameter with passed fontmetrics. Other parameters are passed to the legend item as is.

Parameters:
item - the legend item to populate
fm - the font metrics to use for sizing the passed legend label
label - the label to use for the contents of this legend item
drawType - the draw type to use for this legend item
symbolDim - the symbol dimensions to use for this legend item
itemInfo - the itemInfo field to use for this legend item
numTextFields - the maximum number of fields contained in any JCMultiFieldString objects used so far
Returns:
if using JCMultiFieldString objects for labels, this value will be the maximum number of fields used so far; if not using such any such objects, the return value is -1

calcTextWidthsFromFields

protected void calcTextWidthsFromFields(int numTextFields,
                                        List legendItems,
                                        com.klg.jclass.chart3d.JCChart3dLegendTemplate threeDLegend,
                                        FontMetrics fm)
Runs through the given list of legend items and adjusts text sizes for the number of fields being used by JCMultiFieldString objects.

Parameters:
numTextFields - the maximum number of text fields being used by JCMultiFieldString objects in this legend
legendItems - the list of legend items
threeDLegend - the legend class if it implements the JCChart3DLegendTemplate interface
fm -

isTitleItem

public boolean isTitleItem(com.klg.jclass.util.legend.JCLegendItem item)
Indicates if an item is a title, creating a way to identify it from all the other JCLegendItems. In this case, a null itemInfo indicates that this is a title.

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

drawLegendItem

public void drawLegendItem(Graphics gc,
                           Font useFont,
                           com.klg.jclass.util.legend.JCLegendItem thisItem)
For implementing custom legend item draws. For use with CUSTOM_ALL draw type.

Specified by:
drawLegendItem in interface JCLegendRenderer
Parameters:
gc - tbe graphics object used to draw
useFont - the font to use
thisItem - the item to draw

drawLegendItemSymbol

public void drawLegendItemSymbol(Graphics gc,
                                 Font useFont,
                                 com.klg.jclass.util.legend.JCLegendItem thisItem)
For implementing custom legend item symbol draws. For use with CUSTOM_SYMBOL draw type.

Specified by:
drawLegendItemSymbol in interface JCLegendRenderer
Parameters:
gc - tbe graphics object used to draw
useFont - the font to use
thisItem - the item to draw

drawLegendItemText

public void drawLegendItemText(Graphics gc,
                               Font useFont,
                               com.klg.jclass.util.legend.JCLegendItem thisItem)
For implementing custom legend item text draws. For use when the legend item's contents field holds an object other than a String object.

Specified by:
drawLegendItemText in interface JCLegendRenderer
Parameters:
gc - tbe graphics object used to draw
useFont - the font to use
thisItem - the item to draw

getOutlineColor

public Color getOutlineColor(com.klg.jclass.util.legend.JCLegendItem thisItem)
Gets the outline color to use when drawing this legend item's symbol. If null, the legend will use its own foreground color.

Specified by:
getOutlineColor in interface JCLegendRenderer
Parameters:
thisItem - which item to get outline color from
Returns:

setOutlineColor

public void setOutlineColor(Color outlineColor)
Sets the outline color to use when drawing this legend item's symbol. If null, legend will use its own foreground color. The default is black.

Parameters:
outlineColor - the new outline color

setFillGraphics

public void setFillGraphics(Graphics gc,
                            com.klg.jclass.util.legend.JCLegendItem thisItem)
Sets the provided Graphics object with the appropriate settings to use when drawing this legend item's symbol. In this case it sets the gc color to the range's foreground color.

Specified by:
setFillGraphics in interface JCLegendRenderer
Parameters:
gc - the graphics object to set
thisItem - the item to get information from

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