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

Legend stores, manages and renders symbols legend items. A single square icon with a specific quadrant painted a certain color, is drawn on the symbols legend for each legend item. Rendering legend can be switched on or off by setting the Pedigree.setShowlegend(Boolean) property.

See Also:
LegendItem, Serialized Form

Constructor Summary
Legend()
          Creates a new Legend Instance
 
Method Summary
 void addLegendItem(int ai_legendid, LegendItem aItem)
          Add a new legend item to the legend.
 void addLegendSymbol(int ai_id, 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(int ai_id, 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(int ai_id, 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(int ai_id, 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)
           
 void addSymbolsLegendListener(SymbolsLegendListener listener)
          Use method to register an interest in receiving LegendChangeEvents
 void clearLegend()
          Clears the legend that is currently on the pedigree.
 int count()
           
protected  void fireLegendItemAdded(LegendChangeEvent evt)
          Fires legendItemAdded method of all symbols legend listeners
protected  void fireLegendItemChanged(LegendChangeEvent evt)
          Fires legendItemChanged method of all symbols legend listeners
protected  void fireLegendItemRemoved(LegendChangeEvent evt)
          Fires legendItemRemoved method of all symbols legend listeners
protected  void fireLegendItemWillChange(LegendChangeEvent evt)
          Fires legendItemWillChange method of all symbols legend listeners
 double getLegendHeight()
           
 LegendItem getLegendItem(int ai_id)
          Retrieves a legend item whose Legend ID is specified.
 java.util.Map<java.lang.Integer,LegendItem> getLegendItems()
          Get a map of the items contained in the symbols legend.
 java.util.Map<java.lang.Integer,LegendItem> getLegendItems(boolean ab_include_hidden_items)
          Gets the current Pedigree Legend
 java.util.Iterator<LegendItem> getLegendItemsIterator()
           
 java.util.Iterator<LegendItem> getLegendItemsIterator(boolean ab_include_hidden_items)
           
 java.util.Iterator<LegendItem> getLegendItemsIterator(boolean ab_include_hidden_items, boolean ab_reverseidorder)
           
 double getLegendPosX()
           
 double getLegendPosY()
           
 double getLegendWidth()
           
 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.
 boolean isShowHiddenItems()
           
 void removeLegendItem(int ai_id)
          Remove the LegendItem whose ID is as_id from the Legend.
 void removePropertyChangeListener(java.beans.PropertyChangeListener lstnr)
           
 void removeSubtextListener(SymbolsLegendListener listener)
          Used to removed SymbolsLegendListeners
 void setLegendHeight(double height)
          Sets the legend height.
 void setLegendItems(java.util.Map<java.lang.Integer,LegendItem> aLegendItems)
          Sets the symbols legend for the pedigree
 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.
 void setShowHiddenItems(boolean rhs)
          Updates the value for property "showHiddenItems".
 
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)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener lstnr)

setLegendItems

public void setLegendItems(java.util.Map<java.lang.Integer,LegendItem> aLegendItems)
Sets the symbols legend for the pedigree

Parameters:
aLegendItems - The new map of legend items

addLegendItem

public void addLegendItem(int ai_legendid,
                          LegendItem aItem)
Add a new legend item to the legend. Fires a LegendChangeEvent if item is added successfully

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

removeLegendItem

public void removeLegendItem(int ai_id)
Remove the LegendItem whose ID is as_id from the Legend. Fires a LegendChangeEvent if item is removed successfully

Parameters:
ai_id - The ID of the legendItem to be deleted. I

getLegendItems

public java.util.Map<java.lang.Integer,LegendItem> getLegendItems()
Get a map of the items contained in the symbols legend. If the property isShowHiddenItems() is true then only the legend items whose LegendItem.isVisible() property is set are returned.

Returns:
A map of the items contained in the symbols legend

getLegendItems

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

Returns:
A map of the items contained in the symbols legend. If @param ab_include_hidden_items is FALSE then all legend items are returned. Otherwise only the visible legend items are returned
See Also:
getLegendItems()

getLegendItem

public LegendItem getLegendItem(int ai_id)
Retrieves a legend item whose Legend ID is specified.

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

addLegendSymbol

public void addLegendSymbol(int ai_id,
                            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. If a Legend Item with given ID already exists, it will be replaced with the new legend Item

Parameters:
ai_id - 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(int ai_id,
                            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. If a Legend Item with given ID already exists, it will be replaced with the new legend Item

Parameters:
ai_id - 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(int ai_id,
                            java.lang.String quadrant,
                            java.awt.Color qColor)
Creates and adds a legend Item object whose color and quadrant details are as specified. If a Legend Item with given ID already exists, it will be replaced with the new legend Item

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

addLegendSymbol

public void addLegendSymbol(int ai_id,
                            java.lang.String quadrant,
                            int qColorRGB)
Creates and adds a legend Item object whose color and quadrant details are as specified. If a Legend Item with given ID already exists, it will be replaced with the new legend Item

Parameters:
ai_id - The id desired for the legend Item
quadrant - The quadrant to set
qColorRGB - The rgb value to use in setting the color for the quadrant.

getLegMaxLen

public 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 excluding non-visible items

getLegendItemsIterator

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

getLegendItemsIterator

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

getLegendItemsIterator

public java.util.Iterator<LegendItem> getLegendItemsIterator(boolean ab_include_hidden_items,
                                                             boolean ab_reverseidorder)

addSymbolsLegendListener

public void addSymbolsLegendListener(SymbolsLegendListener listener)
Use method to register an interest in receiving 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 legendItemAdded method of all symbols legend listeners

Parameters:
evt - The LegendChangeEvent for which the event is being fired

fireLegendItemRemoved

protected void fireLegendItemRemoved(LegendChangeEvent evt)
Fires legendItemRemoved method of all symbols legend listeners

Parameters:
evt - The LegendChangeEvent for which the event is being fired

fireLegendItemWillChange

protected void fireLegendItemWillChange(LegendChangeEvent evt)
Fires legendItemWillChange method of all symbols legend listeners

Parameters:
evt - The LegendChangeEvent for which the event is being fired

fireLegendItemChanged

protected void fireLegendItemChanged(LegendChangeEvent evt)
Fires legendItemChanged method of all symbols legend listeners

Parameters:
evt - The LegendChangeEvent for which the event is being fired

isShowHiddenItems

public boolean isShowHiddenItems()
Returns:
The value for property "showHiddenItems". When this value is set to TRUE, al llegend items including ones that are hidden will be included in lists and will also be displayed on the pedigree legend, otherwise hidden items are not shown on the legend nor are they included in the lists and/or iterators of the legend items in this legend.

setShowHiddenItems

public void setShowHiddenItems(boolean rhs)
Updates the value for property "showHiddenItems". When this value is set to TRUE, al llegend items including ones that are hidden will be included in lists and will also be displayed on the pedigree legend, otherwise hidden items are not shown on the legend nor are they included in the lists and/or iterators of the legend items in this legend.

Parameters:
rhs - The new value for property showHiddenItems.