com.objex.panywhere
Class SubtextLegend

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

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

SubtextLegend stores, manages and renders subtext legend items. A single line is drawn per generation for each subtext legend item contained in this legend. The subtext legend lines are drawn to the left and below
the left most person in each generation. Rendering subtext legend can be switched on or off by setting the ProgenyAnywhere.setShowSubtextLegend(Boolean) property.

See Also:
Serialized Form

Nested Class Summary
static class SubtextLegend.SUBTEXT_LEGEND_ITEM_SET
           
 
Field Summary
static java.lang.String PROP_SAMPLE_PROPERTY
           
static int SUPTEXT_Y_VALUE
          The distance of the supertext line closest to the icon from the top left corner of the icon
 
Constructor Summary
SubtextLegend()
          Creates a new SubtextLegend instance
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addSubtextLegendItem(SubtextLegendItem a_item)
          Add a new subtext legend item to the subtext legend.
 void addSubtextListener(SubtextListener listener)
          Add the listener to receive subtext change events
 void clearLegend()
          Clears the subtext legend, deleting all the items
 int count(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET a_subtext_legend_set)
           
protected  void fireSubtextLegendItemAdded(SubtextEvent evt)
          Fires subtextLegendItemAdded(SubtextEvent) method to propagate the event generated when a new subtext legend item is added
protected  void fireSubtextLegendItemRemoved(SubtextEvent evt)
          Fires subtextLegendItemRemoved(SubtextEvent) method of all SubtextListener's to propagate the event generated when a subtext legend item is removed
 double getHeight()
          Returns the maximum height of the subtext legend.
 int getItemCount(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET a_subtext_legend_set)
           
 SubtextLegendItem getLegendItem(int ai_order)
           
 java.util.List<SubtextLegendItem> getLegendItemsAfter(int ai_order)
           
 java.util.List<SubtextLegendItem> getLegendItemsBefore(int ai_order)
           
 java.lang.String getSampleProperty()
           
 SubtextLegendItem getSubtextLegendItem(int ai_fieldid)
           
 java.util.Map<java.lang.Integer,SubtextLegendItem> getSubtextLegendItems()
           
 java.util.Map<java.lang.Integer,SubtextLegendItem> getSubtextLegendItems(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET ab_subtext_set)
           
 java.util.Iterator<SubtextLegendItem> getSubtextLegendIterator()
          Return an iterable list of all subtext legend items in this subtext legend.
 java.util.Iterator<SubtextLegendItem> getSubtextLegendIterator(boolean ab_ordered, SubtextLegend.SUBTEXT_LEGEND_ITEM_SET ab_subtext_set)
          Return an iterable list of all subtext legend items in this subtext legend.
 double getWidth()
          Returns the maximum width of the subtext legend.
protected  boolean hasSubtextItemsWidthMultiRows(SubtextLegendItem a_legend_item, java.util.List<Subtext> a_subtext_items)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 SubtextLegendItem removeSubtextLegendItem(int ai_fieldid)
          Removes the subtext legend item for the specified fieldid
 SubtextLegendItem removeSubtextLegendItemAt(int ai_order)
          emoves the subtext legend item whose order (SubtextLegendItem.getOrder()) or row number (SubtextLegendItem.getRow()) equals the specified order
 void removeSubtextListener(SubtextListener listener)
          Remove the subtext legend listener
 void render(java.awt.Graphics2D g2d, DrawingContext dc, double ad_genY, double ad_rightMargin, MarkerLegend a_marker_legend, java.util.List<Subtext> a_subtext_items_list)
          Paints the subtext legend items and marker legend items below and to the left of the leftmost person in each generation
protected  void renderMarkerLegend(MarkerLegend a_marker_legend, java.awt.Graphics2D g2d, double starty, DrawingContext dc, double ad_rightMargin, int ai_subtext_count)
          Paints the marker legend items to the left of the leftmost person in each generation
protected  void renderSupertext(java.awt.Graphics2D g2d, DrawingContext dc, double ad_supertext_genY, double ad_rightMargin)
          Paints the subtext legend items and marker legend items below and to the left of the leftmost person in each generation
 void setHeight(double ai_height)
          Sets the maximum height of the subtext legend.
 void setSampleProperty(java.lang.String value)
           
 void setSubtextLegendItems(java.util.Map<java.lang.Integer,SubtextLegendItem> a_items)
          Sets the new list of subtext legend Items
 void setWidth(double ai_width)
          Sets the maximum width of the subtext legend.
 void updateMultiRowLegendItems(java.util.List<Subtext> a_subtext_items)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPTEXT_Y_VALUE

public static final int SUPTEXT_Y_VALUE
The distance of the supertext line closest to the icon from the top left corner of the icon

See Also:
Constant Field Values

PROP_SAMPLE_PROPERTY

public static final java.lang.String PROP_SAMPLE_PROPERTY
See Also:
Constant Field Values
Constructor Detail

SubtextLegend

public SubtextLegend()
Creates a new SubtextLegend instance

Method Detail

getSampleProperty

public java.lang.String getSampleProperty()

setSampleProperty

public void setSampleProperty(java.lang.String value)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

getSubtextLegendItem

public SubtextLegendItem getSubtextLegendItem(int ai_fieldid)
Returns:
A subtext legend item corresponding to the fieldid "ai_fieldid" or null if the is no legend item for the specified fieldid

removeSubtextLegendItem

public SubtextLegendItem removeSubtextLegendItem(int ai_fieldid)
Removes the subtext legend item for the specified fieldid

Returns:
The removed subtext legend item or null if none were removed

removeSubtextLegendItemAt

public SubtextLegendItem removeSubtextLegendItemAt(int ai_order)
emoves the subtext legend item whose order (SubtextLegendItem.getOrder()) or row number (SubtextLegendItem.getRow()) equals the specified order

Parameters:
ai_order - The line number in corresponding to the subtext legend item to be removed
Returns:
A subtext legend item or NULL if none exists at the specified ai_order

addSubtextLegendItem

public void addSubtextLegendItem(SubtextLegendItem a_item)
Add a new subtext legend item to the subtext legend. The fieldid for the item must be set before calling this method. This method fires a new SubtextEvent if the item was successfully added

Parameters:
a_item - The subtext legend item to be added. Its fieldid property must be set before this operation is executed.

getWidth

public double getWidth()
Returns the maximum width of the subtext legend. This will typically cover the longest subtext legend item's text when drawn on the Pedigree surface. This method only returns a valid value if the legend has been rendered at least once before or if the method SubtextLegend.setWidth(double) has been executed.


setWidth

public void setWidth(double ai_width)
Sets the maximum width of the subtext legend. This will typically cover the longest subtext legend item's text when drawn on the pedigree canvas.

Parameters:
ai_width - The new maximum width for the subtext legend

getHeight

public double getHeight()
Returns the maximum height of the subtext legend.


setHeight

public void setHeight(double ai_height)
Sets the maximum height of the subtext legend.

Parameters:
ai_height - The new maximum height for the subtext legend

clearLegend

public void clearLegend()
Clears the subtext legend, deleting all the items


count

public int count(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET a_subtext_legend_set)
Parameters:
a_subtext_legend_set - Defines which subset of the subtext legend to inspect or count. Use SUBTEXT_LEGEND_ITEM_SET.SUPERTEXT_ONLY to return or count only supertext items. Use SUBTEXT_LEGEND_ITEM_SET.SUBTEXT_ONLY to return or count only subtext items. Use SUBTEXT_LEGEND_ITEM_SET.ALL to return or count both supertext and subtext items.
Returns:
The current number of subtext legend items. If there some multi-row subtext legend items, the count includes the row count for each such multi-row item. For instance, if there are 5 items in total and there are two multi-row items each with 3 rows, the count will return 3 + (2 * 3) = 9

render

public void render(java.awt.Graphics2D g2d,
                   DrawingContext dc,
                   double ad_genY,
                   double ad_rightMargin,
                   MarkerLegend a_marker_legend,
                   java.util.List<Subtext> a_subtext_items_list)
Paints the subtext legend items and marker legend items below and to the left of the leftmost person in each generation

Parameters:
a_marker_legend - The marker legend if one exists. Marker legend items are always rendered below subtext legend items.
g2d - The graphics context
dc - The drawing context with the control's specific rendering properties. Of particular importance is the Font used for rendering subtext which is obtained from the "dc".
ad_genY - The Y-Coordinate of the leftmost person in the generation for which this subtext legend is being drawn
ad_rightMargin - The X-Coordinate of the leftmost person within the generation for which this subtext legend is being drawn. The subtext legend items will be rendered relative to this X-Coordinate
a_subtext_items_list - The list of subtext items associated with this subtext legend

renderSupertext

protected void renderSupertext(java.awt.Graphics2D g2d,
                               DrawingContext dc,
                               double ad_supertext_genY,
                               double ad_rightMargin)
Paints the subtext legend items and marker legend items below and to the left of the leftmost person in each generation

Parameters:
g2d - The graphics context
dc - The drawing context with the control's specific rendering properties. Of particular importance is the Font used for rendering subtext which is obtained from the "dc".
ad_supertext_genY - The Y-Coordinate of the leftmost person in the generation for which this supertext legend is being drawn
ad_rightMargin - The X-Coordinate of the leftmost person within the generation for which this subtext legend is being drawn. The subtext legend items will be rendered relative to this X-Coordinate

renderMarkerLegend

protected void renderMarkerLegend(MarkerLegend a_marker_legend,
                                  java.awt.Graphics2D g2d,
                                  double starty,
                                  DrawingContext dc,
                                  double ad_rightMargin,
                                  int ai_subtext_count)
Paints the marker legend items to the left of the leftmost person in each generation

Parameters:
a_marker_legend - The marker legend with a list of all the markers in the haplotype
g2d - The Graphics context
starty - The Y-Coordinate on which the first marker legend item is to be rendered. If no subtext legend items were drawn, this value will be equivalent to Pedigree.getSubtextyvalue()
dc - The drawing context with the control's specific rendering properties. Of particular importance is the Font used for rendering subtext which is obtained from the "dc".
ad_rightMargin - The X-Coordinate of the leftmost person within the generation for which this subtext legend is being drawn. The subtext legend items will be rendered relative to this X-Coordinate
ai_subtext_count - The number of subtext lines that were rendered before the marker legend is drawn. If no subtext legend items were drawn, this value will be zero

addSubtextListener

public void addSubtextListener(SubtextListener listener)
Add the listener to receive subtext change events

Parameters:
listener - The new subtext listener

removeSubtextListener

public void removeSubtextListener(SubtextListener listener)
Remove the subtext legend listener

Parameters:
listener - The SubtextListener to be removed

fireSubtextLegendItemAdded

protected void fireSubtextLegendItemAdded(SubtextEvent evt)
Fires subtextLegendItemAdded(SubtextEvent) method to propagate the event generated when a new subtext legend item is added

Parameters:
evt - The subtext add event

fireSubtextLegendItemRemoved

protected void fireSubtextLegendItemRemoved(SubtextEvent evt)
Fires subtextLegendItemRemoved(SubtextEvent) method of all SubtextListener's to propagate the event generated when a subtext legend item is removed

Parameters:
evt - The subtext add event

getSubtextLegendIterator

public java.util.Iterator<SubtextLegendItem> getSubtextLegendIterator()
Return an iterable list of all subtext legend items in this subtext legend. An empty iterator will be returned if there are no items in this legend. The iterator is in no particular order.


getSubtextLegendIterator

public java.util.Iterator<SubtextLegendItem> getSubtextLegendIterator(boolean ab_ordered,
                                                                      SubtextLegend.SUBTEXT_LEGEND_ITEM_SET ab_subtext_set)
Return an iterable list of all subtext legend items in this subtext legend. An empty iterator will be returned if there are no items in this legend. If ab_odered is TRUE then the list returned is ascending order of the order property of the subtext legend items.

Parameters:
ab_ordered - If TRUE then the list returned is ascending order of the order property of the subtext legend items.
ab_subtext_set - The subset of legend items to be returned as defined by the enum

getSubtextLegendItems

public java.util.Map<java.lang.Integer,SubtextLegendItem> getSubtextLegendItems()
Returns:
A map of subtext legend Items

getSubtextLegendItems

public java.util.Map<java.lang.Integer,SubtextLegendItem> getSubtextLegendItems(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET ab_subtext_set)
Parameters:
ab_subtext_set - The subset of legend items to be returned as defined by the enum
Returns:
A map of subtext legend Items

setSubtextLegendItems

public void setSubtextLegendItems(java.util.Map<java.lang.Integer,SubtextLegendItem> a_items)
Sets the new list of subtext legend Items

Parameters:
a_items - The new map of subtext legend items

getItemCount

public int getItemCount(SubtextLegend.SUBTEXT_LEGEND_ITEM_SET a_subtext_legend_set)
Parameters:
a_subtext_legend_set - Defines which subset of the subtext legend to inspect or count. Use SUBTEXT_LEGEND_ITEM_SET.SUPERTEXT_ONLY to return or count only supertext items. Use SUBTEXT_LEGEND_ITEM_SET.SUBTEXT_ONLY to return or count only subtext items. Use SUBTEXT_LEGEND_ITEM_SET.ALL to return or count both supertext and subtext items.
Returns:
The number of subtext legend items
See Also:
count(SUBTEXT_LEGEND_ITEM_SET)

getLegendItem

public SubtextLegendItem getLegendItem(int ai_order)
Parameters:
ai_order - The line number/order for the subtext legend item to be returned
Returns:
The subtext legend item at the specified order. May return null if no item is found with order property equal to "ai_order"

getLegendItemsAfter

public java.util.List<SubtextLegendItem> getLegendItemsAfter(int ai_order)
Parameters:
ai_order - Subtext legend item width order property greater than ai_order will be returned
Returns:
The list of subtext legend items that have an order/line number greater than ai_order

getLegendItemsBefore

public java.util.List<SubtextLegendItem> getLegendItemsBefore(int ai_order)

updateMultiRowLegendItems

public void updateMultiRowLegendItems(java.util.List<Subtext> a_subtext_items)

hasSubtextItemsWidthMultiRows

protected boolean hasSubtextItemsWidthMultiRows(SubtextLegendItem a_legend_item,
                                                java.util.List<Subtext> a_subtext_items)