com.objex.panywhere
Class Legend

java.lang.Object
  extended by com.objex.panywhere.Legend
All Implemented Interfaces:
java.io.Serializable

public class Legend
extends java.lang.Object
implements java.io.Serializable

The Legend containts LegendItems and other properties that are used for painting the Symbols Legend on the Pedigree.

See Also:
Serialized Form

Constructor Summary
Legend()
          Creates a new Legend Instance
 
Method Summary
 void addLegendItem(java.lang.Object lid, LegendItem aItem)
          Add a new legend item to the legend
 void addLegendSymbol(java.lang.String legendID, java.awt.Color q1Color, java.awt.Color q2Color, java.awt.Color q3Color, java.awt.Color q4Color, java.awt.Color ccColor, java.awt.Color csColor)
          Creates and adds a legend Item object whose color and quadrant details are as specified.
 void addLegendSymbol(java.lang.String legendID, java.lang.String quadrant, java.awt.Color qColor)
          Creates and adds a legend Item object whose color and quadrant details are as specified.
 void addLegendSymbol(java.lang.String legendID, java.lang.String text, java.awt.Color q1Color, java.awt.Color q2Color, java.awt.Color q3Color, java.awt.Color q4Color, java.awt.Color ccColor, java.awt.Color csColor, boolean q1Dot, boolean q2Dot, boolean q3Dot, boolean q4Dot, boolean vLine, boolean hLine)
          Creates and adds a legend Item object whose color and quadrant details are as specified.
 void addLegendSymbol(java.lang.String legendID, java.lang.String quadrant, int qColorRGB)
          Creates and adds a legend Item object whose color and quadrant details are as specified.
 void addPropertyChangeListener(java.beans.PropertyChangeListener lstnr)
          Enables users of the Legend Bean to add property listeners
 void addSymbolsLegendListener(SymbolsLegendListener listener)
          Interested classes must use this method to register to receieve LegendChangeEvents
 void clearLegend()
          Clears the legend that is currently on the pedigree.
 int count()
           
protected  void fireLegendItemAdded(LegendChangeEvent evt)
          Fires LegendChangeEvent
protected  void fireLegendItemChanged(LegendChangeEvent evt)
          Fires LegendChangeEvent event
protected  void fireLegendItemRemoved(LegendChangeEvent evt)
          Fires LegendChangeEvent event
protected  void fireLegendItemWillChange(LegendChangeEvent evt)
          Fires LegendChangeEvent event
 double getLegendHeight()
           
 LegendItem getLegendItem(java.lang.String legendID)
          Retrieves a legend item whose Legend ID is specified.
 java.util.Map<java.lang.String,LegendItem> getLegendItems()
          Gets the current Pedigree Legend
 java.util.Iterator<LegendItem> getLegendItemsIterator()
           
 double getLegendPosX()
           
 double getLegendPosY()
           
 double getLegendWidth()
           
protected  double getLegMaxLen(java.awt.Graphics2D g2d, double lox, double symbolw)
          Calculate and return the length of the longest legend item taking into account the legend Item's text and Icon.
 void removeLegendItem(java.lang.Object aItemID)
          Remove the LegendItem whose ID is aItemID from the Legend
 void removePropertyChangeListener(java.beans.PropertyChangeListener lstnr)
          Enables users of the Legend Bean to add property listeners
 void removeSubtextListener(SymbolsLegendListener listener)
          Used to removed SymbolsLegendListeners
 void setLegendHeight(double height)
          Sets the legend height.
 void setLegendItems(java.util.Map<java.lang.String,LegendItem> aLegendItems)
          Sets the legend for this Pedigree to the contents of the supplied hashmap.
 void setLegendPos(double x, double y)
          Sets the XY position of the top left corner of the Legend bounding box.
 void setLegendPosX(double x)
          Sets the X position of the top left corner of the Legend bounding
 void setLegendPosY(double y)
          Sets the Y position of the top left corner of the Legend bounding box
 void setLegendWidth(double width)
          Sets the legend width.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Legend

public Legend()
Creates a new Legend Instance

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener lstnr)
Enables users of the Legend Bean to add property listeners


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener lstnr)
Enables users of the Legend Bean to add property listeners


setLegendItems

public void setLegendItems(java.util.Map<java.lang.String,LegendItem> aLegendItems)
Sets the legend for this Pedigree to the contents of the supplied hashmap.

Parameters:
aLegendItems - The new legend encapsulated in a hashmap

addLegendItem

public void addLegendItem(java.lang.Object lid,
                          LegendItem aItem)
Add a new legend item to the legend

Parameters:
aItem - The Legend item object to be added
lid - The Legend item id or key

removeLegendItem

public void removeLegendItem(java.lang.Object aItemID)
Remove the LegendItem whose ID is aItemID from the Legend

Parameters:
aItemID - The ID of the legendItem to be deleted. If item exists and is deleted a LegendChangeEvent is created showing that an item has been removed

getLegendItems

public java.util.Map<java.lang.String,LegendItem> getLegendItems()
Gets the current Pedigree Legend

Returns:
A hashmap whose contents is the current Pedigree legend

getLegendItem

public LegendItem getLegendItem(java.lang.String legendID)
Retrieves a legend item whose Legend ID is specified.

Parameters:
legendID - The ID for the legend item to be retrieved.
Returns:
A Legend Item object or null if one is not found.

addLegendSymbol

public void addLegendSymbol(java.lang.String legendID,
                            java.lang.String text,
                            java.awt.Color q1Color,
                            java.awt.Color q2Color,
                            java.awt.Color q3Color,
                            java.awt.Color q4Color,
                            java.awt.Color ccColor,
                            java.awt.Color csColor,
                            boolean q1Dot,
                            boolean q2Dot,
                            boolean q3Dot,
                            boolean q4Dot,
                            boolean vLine,
                            boolean hLine)
Creates and adds a legend Item object whose color and quadrant details are as specified. The legend item once created is added to the Legend. If a Legend Item item with given ID already exists, it will be replaced with the new Symbol or Legend Item This method fails cleanly.

Parameters:
legendID - The id desired for the Legend Item / Symbol
q1Color - Color to set quadrant 1 of the legend symbol
q2Color - Color to set quadrant 2 of the legend symbol
q3Color - Color to set quadrant 3 of the legend symbol
q4Color - Color to set quadrant 4 of the legend symbol
ccColor - Color to set the center dot of the legend symbol
csColor - Color to set the center square of the legend symbol
q1Dot - boolean value indicating whether or not the quadrant 1 dot is set
q2Dot - boolean value indicating whether or not the quadrant 2 dot is set
q3Dot - boolean value indicating whether or not the quadrant 3 dot is set
q4Dot - boolean value indicating whether or not the quadrant 4 dot is set
vLine - boolean value indicating whether or not the vertical line is set
hLine - boolean value indicating whether or not the horizontal line is set

addLegendSymbol

public void addLegendSymbol(java.lang.String legendID,
                            java.awt.Color q1Color,
                            java.awt.Color q2Color,
                            java.awt.Color q3Color,
                            java.awt.Color q4Color,
                            java.awt.Color ccColor,
                            java.awt.Color csColor)
Creates and adds a legend Item object whose color and quadrant details are as specified. The legend item once created is added to the Legend. If the operation is unsuccessfu, nothing is done and the method will return cleanly and safely. If a Legend Item item with given ID already exists, it will be replaced with the new Symbol or Legend Item

Parameters:
legendID - The id desired for the Legend Item / Symbol
q1Color - Color to set quadrant 1 of the legend symbol
q2Color - Color to set quadrant 2 of the legend symbol
q3Color - Color to set quadrant 3 of the legend symbol
q4Color - Color to set quadrant 4 of the legend symbol
ccColor - Color to set the center dot of the legend symbol
csColor - Color to set the center square of the legend symbol

addLegendSymbol

public void addLegendSymbol(java.lang.String legendID,
                            java.lang.String quadrant,
                            java.awt.Color qColor)
Creates and adds a legend Item object whose color and quadrant details are as specified. The legend item once created is added to the Legend. The method fails cleanly and safely. If a Legend Item with given ID already exists, it will be replaced with the new Symbol or Legend Item.

Parameters:
legendID - The id desired for the Legend Item / Symbol
quadrant - The quadrant whose color is to be set
qColor - The color object to set for the quadrant.

addLegendSymbol

public void addLegendSymbol(java.lang.String legendID,
                            java.lang.String quadrant,
                            int qColorRGB)
Creates and adds a legend Item object whose color and quadrant details are as specified. The legend item once created is added to the Legend. The method fails cleanly and safely. If a Legend Item with given ID already exists, it will be replaced with the new Symbol or Legend Item

Parameters:
legendID - The id desired for the Legend Item / Symbol
quadrant - The quadrant to set
qColorRGB - The rgb value to use in setting the color for the quadrant.

getLegMaxLen

protected double getLegMaxLen(java.awt.Graphics2D g2d,
                              double lox,
                              double symbolw)
Calculate and return the length of the longest legend item taking into account the legend Item's text and Icon. LegendText is converted into a text layout object using the default AffineTransform object with scale of (0, 0). The current graphics font is used to construct the TextLayout object from which the text width will be derived

Parameters:
g2d - Graphics
lox - The X Coordinate of the Legend Bounding Rectangle's top left corner (legend position )
symbolw - The Legend Icon width

getLegendHeight

public double getLegendHeight()
Returns:
The current height of the legend bounding box

setLegendHeight

public void setLegendHeight(double height)
Sets the legend height. If the new height is such that the legend symbols can be stacked one below the other, the legend is drawn downwards until the area designated by height is filled before printing rightwards.

Parameters:
height - The new height

getLegendWidth

public double getLegendWidth()
Returns:
The current width of the legend bounding box. This will be wide enough to accomodate all the columns occupied by the current legend.

setLegendWidth

public void setLegendWidth(double width)
Sets the legend width. If the legend with and height are such that not all legend symbols will fit, the width will be re-adjusted to fit all the legend items within the current legend height.

Parameters:
width - The new legend width

setLegendPos

public void setLegendPos(double x,
                         double y)
Sets the XY position of the top left corner of the Legend bounding box.

Parameters:
x - The new legend X position
y - The new legend Y position

setLegendPosY

public void setLegendPosY(double y)
Sets the Y position of the top left corner of the Legend bounding box

Parameters:
y - The new legend Y position

setLegendPosX

public void setLegendPosX(double x)
Sets the X position of the top left corner of the Legend bounding

Parameters:
x - The new legend X position

getLegendPosY

public double getLegendPosY()
Returns:
The current Y position of the legend bounding box

getLegendPosX

public double getLegendPosX()
Returns:
The current X position of the legend bounding box

clearLegend

public void clearLegend()
Clears the legend that is currently on the pedigree. Normally called to change the legend and put a new one.


count

public int count()
Returns:
The current number of Legend Items in the Legend

getLegendItemsIterator

public java.util.Iterator<LegendItem> getLegendItemsIterator()
Returns:
An iterator of all the legend items in this legend

addSymbolsLegendListener

public void addSymbolsLegendListener(SymbolsLegendListener listener)
Interested classes must use this method to register to receieve LegendChangeEvents

Parameters:
listener - The SymbolsLegendListener object to be added or registered

removeSubtextListener

public void removeSubtextListener(SymbolsLegendListener listener)
Used to removed SymbolsLegendListeners

Parameters:
listener - The SymbolsLegendListener

fireLegendItemAdded

protected void fireLegendItemAdded(LegendChangeEvent evt)
Fires LegendChangeEvent

Parameters:
evt - The LegendChangeEvent

fireLegendItemRemoved

protected void fireLegendItemRemoved(LegendChangeEvent evt)
Fires LegendChangeEvent event

Parameters:
evt - The LegendChangeEvent

fireLegendItemWillChange

protected void fireLegendItemWillChange(LegendChangeEvent evt)
Fires LegendChangeEvent event

Parameters:
evt - The LegendChangeEvent

fireLegendItemChanged

protected void fireLegendItemChanged(LegendChangeEvent evt)
Fires LegendChangeEvent event

Parameters:
evt - The LegendChangeEvent