JClass 4.5.0 API
Documentation

com.klg.jclass.swing.gauge
Class DefaultLegendPopulatorRenderer

java.lang.Object
  |
  +--com.klg.jclass.swing.gauge.DefaultLegendPopulatorRenderer

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  JCLegend legend
           
protected  String legendTitle
           
protected  Color outlineColor
           
protected  Vector ranges
           
 
Constructor Summary
DefaultLegendPopulatorRenderer(JCLegend legend, Vector ranges)
          Creates a Populator and Renderer for a JCLegend.
 
Method Summary
protected  JCLegendItem createLegendItem(String name, int symbolSize, int width, int height, Color c)
          Creates a legend item.
 void drawLegendItem(Graphics gc, Font useFont, JCLegendItem thisItem)
          For implementing custom legend item draws.
 void drawLegendItemSymbol(Graphics gc, Font useFont, JCLegendItem thisItem)
          For implementing custom legend item symbol draws.
 List getLegendItems(FontMetrics fm)
          Creates legend items for each range listed in the ranges list.
 String getLegendTitle()
          Returns this legend's title.
 Color getOutlineColor(JCLegendItem thisItem)
          Gets the outline color to use when drawing this legend item's symbol.
 boolean isTitleItem(JCLegendItem item)
          Since the title is just another JCLegendItem we need a way to identify it as the title.
 void setFillGraphics(Graphics gc, 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

legend

protected JCLegend legend

outlineColor

protected Color outlineColor

legendTitle

protected String legendTitle
Constructor Detail

DefaultLegendPopulatorRenderer

public DefaultLegendPopulatorRenderer(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

createLegendItem

protected JCLegendItem createLegendItem(String name,
                                        int symbolSize,
                                        int width,
                                        int height,
                                        Color c)
Creates a legend item.
Parameters:
name -  
symbolSize -  
width -  
height -  
c -  

isTitleItem

public boolean isTitleItem(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 -  
Returns:
true If this item is the legend title

drawLegendItem

public void drawLegendItem(Graphics gc,
                           Font useFont,
                           JCLegendItem thisItem)
For implementing custom legend item draws. For use with CUSTOM_ALL draw type.
Specified by:
drawLegendItem in interface JCLegendRenderer
Parameters:
gc -  
useFont -  
thisItem -  

drawLegendItemSymbol

public void drawLegendItemSymbol(Graphics gc,
                                 Font useFont,
                                 JCLegendItem thisItem)
For implementing custom legend item symbol draws. For use with CUSTOM_SYMBOL draw type.
Specified by:
drawLegendItemSymbol in interface JCLegendRenderer
Parameters:
gc -  
useFont -  
thisItem -  

getOutlineColor

public Color getOutlineColor(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 -  

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,
                            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© 1999-2000 KL Group Inc.
All rights reserved.