JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class DefaultLegendPopulatorRenderer

java.lang.Object
  |
  +--com.klg.jclass.swing.gauge.DefaultLegendPopulatorRenderer
All Implemented Interfaces:
JCLegendPopulator, JCLegendRenderer, Serializable

public class DefaultLegendPopulatorRenderer
extends Object
implements JCLegendRenderer, JCLegendPopulator, Serializable

This is the default implmentation 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.util.legend.JCLegend legend
          The JCLegend for which this class will populate and render JCLegendItems
protected  String legendTitle
           
protected  Color outlineColor
          The outline color to use when drawing this legend item's symbol
protected  Vector ranges
          The Vector of ranges which are used to create corresponding JCLegendItems
 
Constructor Summary
DefaultLegendPopulatorRenderer(com.klg.jclass.util.legend.JCLegend legend, Vector ranges)
          Creates a Populator and Renderer for a JCLegend.
 
Method Summary
protected  com.klg.jclass.util.legend.JCLegendItem createLegendItem(String name, int symbolSize, int width, int height, Color c)
          Creates a legend item.
 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)
          Used for implementing custom text draws for a legend item.
 List getLegendItems(FontMetrics fm)
          Creates legend items for each range listed in the ranges list.
 String getLegendTitle()
          Returns this legend's title.
 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)
          Since the title is just another JCLegendItem we need a way to identify it as the title.
 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 setLegendTitle(String legendTitle)
          Sets the legend's title.
 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

ranges

protected Vector ranges
The Vector of ranges which are used to create corresponding JCLegendItems


legend

protected com.klg.jclass.util.legend.JCLegend legend
The JCLegend for which this class will populate and render JCLegendItems


outlineColor

protected Color outlineColor
The outline color to use when drawing this legend item's symbol


legendTitle

protected String legendTitle
Constructor Detail

DefaultLegendPopulatorRenderer

public DefaultLegendPopulatorRenderer(com.klg.jclass.util.legend.JCLegend legend,
                                      Vector ranges)
Creates a Populator and Renderer for a JCLegend.

Parameters:
legend - The JCLegend for which this class will populate and render JCLegendItems
ranges - The Vector of ranges which are used to create corresponding JCLegendItems
Method Detail

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:
a List of List objects, with each internal List object containing the list of JCLegendItem objects that make up one column of the legend

createLegendItem

protected com.klg.jclass.util.legend.JCLegendItem createLegendItem(String name,
                                                                   int symbolSize,
                                                                   int width,
                                                                   int height,
                                                                   Color c)
Creates a legend item.

Parameters:
name - The name of the item
symbolSize - The symbol size
width - The width of the item
height - The height of the item
c - The color of the item

isTitleItem

public boolean isTitleItem(com.klg.jclass.util.legend.JCLegendItem item)
Since the title is just another JCLegendItem we need a way to identify it as the title. This method indicates if an item is a title. In this case a null itemInfo indicates that this is a title.

Specified by:
isTitleItem in interface JCLegendPopulator
Parameters:
item - The item to check
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 - 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

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

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)
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 - the JCLegendItem object representing the legend item to draw.
Returns:
The current outline color

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 -

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 -
thisItem -

getLegendTitle

public String getLegendTitle()
Returns this legend's title.

Returns:
the title

setLegendTitle

public void setLegendTitle(String legendTitle)
Sets the legend's title.

Parameters:
legendTitle - The legend's title

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