lt.monarch.chart.engine
Class AbstractLegend

java.lang.Object
  extended by lt.monarch.chart.AbstractView<LegendPaintTags>
      extended by lt.monarch.chart.engine.AbstractLegend
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, StyleEditorEntity, View, ExpandableDecoration
Direct Known Subclasses:
ColorScaleLegend, Legend

public abstract class AbstractLegend
extends AbstractView<LegendPaintTags>
implements ExpandableDecoration

Abstract legend, which implements basic legend functions

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
 class AbstractLegend.LegendEntryEntity
          The legend entry chart entity.
 
Field Summary
Modifier and Type Field and Description
protected  java.awt.Dimension actualSize
          Actual size
protected  LegendEntry currentSelection
          Current selection
protected  boolean cursorChanged
          Cursor was changed
protected  java.awt.Dimension dimension
          Preferred size
protected  Rectangle2D drawBounds
          Drawing bounds
protected  java.util.ArrayList<LegendEntry> entries
          Legend entries
protected  Alignment horizontalLabelAlignment
          Horizontal label alignment
protected  SortDirection labelSorting
          Enables sorting of the labels
protected  java.awt.Point lastPt
          Last point
protected  LegendLayout layout
          Legend layout
protected  int margin
          Margin
protected  java.awt.Point mouseClick
          Mouse click point
protected  java.awt.Cursor moveCursor
          Moving cursor
protected  Orientation orientation
          Orientation of the legend
protected  double scrollRange
          Scrolling range
 Style style
          Style of the legend.
protected  java.awt.Cursor tempCursor
          Temporary cursor
protected  AbstractTextPainter textPainter
          Text painter
protected  TextStyle<LegendPaintTags> textStyle
          Legend text style
protected  Alignment verticalLabelAlignment
          Vertical label alignment
protected  boolean wordWrappingEnabled
          Word wrapping is enabled
 
Fields inherited from class lt.monarch.chart.AbstractView
layoutInvalid, paintStyle
 
Constructor Summary
Constructor and Description
AbstractLegend()
          Default abstract legend constructor
 
Method Summary
Modifier and Type Method and Description
abstract  void addEntries(LegendEntry[] ll)
          Adds a list of entries the the legend at once.
abstract  void addEntry(LegendEntry entry)
          Adds a new entry to the legend.
abstract  void addEntry(java.lang.String text, LegendSymbol symbol)
          Constructs and adds a new entry to the legend.
abstract  void addSeparator()
          Adds a separator to the legend.
abstract  void addSeparator(java.lang.String label)
          Adds a separator to the legend.
 void dispose()
          Cleans this legend object.
 java.util.List<LegendEntry> getContainingObjects()
          Returns all containing legend entries
 java.util.Enumeration<LegendEntry> getEntries()
          Gets entries of the legend.
 LegendEntry getEntry(int index)
          Returns a Legend entry at specified position.
 Alignment getLabelHAlignment()
          Returns horizontal alignment of labels.
 SortDirection getLabelSorting()
          Gets sorting option for the labels
 Alignment getLabelVAlignment()
          Returns vertical alignment of labels.
 LegendLayout getLayout()
          Returns style of legend layout.
 Orientation getOrientation()
          Returns orientation of legend layout.
abstract  java.awt.Dimension getPreferredSize(AbstractGraphics g)
          Gets the preferred size of this legend.
 AbstractStyle getStyle(StyleType styleType)
          Gets style object for the stylesheet attributes specified by style type.
 TextStyle<LegendPaintTags> getTextStyle()
          Gets text style object, which is used to set text properties
 boolean getWordWrappingEnabled()
          Returns whether or not word wrapping for text of legend entries is enabled.
 void initCursor()
          Initialize cursor
 boolean isHorizontallyExpandable()
          Should return true if width of this view, when persisting in top or bottom position inside DecoratedView, should be expanded to maximum space available.
 boolean isVerticallyExpandable()
          Should return true if height of this view, when persisting in left or right position inside DecoratedView, should be expanded to maximum space available.
protected  void readObject(java.io.ObjectInputStream in)
           
 void removeAllEntries()
          Removes all legend entries
 void removeEntry(LegendEntry entry)
          Removes legend entry.
 void setCurrentSelection(LegendEntry selection)
          Selects the specified legend entry.
 void setHorizontalAlignment(Alignment align)
          Sets Legend entries text vertical alignment.
 void setLabelAlignment(Alignment hAlign, Alignment vAlign)
          Sets alignment for labels.
 void setLabelSorting(SortDirection labelSorting)
          Sets sorting option for the labels
 void setLayout(LegendLayout layout)
          Sets the legend layout.
 void setOrientation(Orientation orientation)
          Sets legend orientation.
 void setPreferredSize(java.awt.Dimension dimension)
          Sets preferred size
 void setPreferredSize(int width, int height)
          Sets the preferred size of the receiving view.
 void setVerticalAlignment(Alignment align)
          Sets Legend entries text vertical alignment.
 void setWordWrappingEnabled(boolean enable)
          Enables/disabled word wrapping in text of legend entries.
protected  void sortLabels()
          Sorts legend entry labels
 
Methods inherited from class lt.monarch.chart.AbstractView
activate, addViewListener, clone, container, deactivate, finalize, getAlignmentX, getAlignmentY, getBounds, getChartObjectBounds, getContainer, getGraphicsType, getHeight, getMaximumSize, getMinimumSize, getPaintMode, getPaintStyle, getParent, getSize, getSize, getStyle, getWidth, getX, getY, invalidate, isLayoutValid, layout, paint, removeViewListener, render, repaint, repaint, setAlignmentX, setAlignmentY, setBounds, setBounds, setContainer, setLocation, setMaximumSize, setMinimumSize, setPaintMode, setSize, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

style

public final Style style
Style of the legend. It must override style from AbstractView, since otherwise the background of AbstractView is rendered as well.


textStyle

protected TextStyle<LegendPaintTags> textStyle
Legend text style


entries

protected java.util.ArrayList<LegendEntry> entries
Legend entries


layout

protected LegendLayout layout
Legend layout


horizontalLabelAlignment

protected Alignment horizontalLabelAlignment
Horizontal label alignment


verticalLabelAlignment

protected Alignment verticalLabelAlignment
Vertical label alignment


orientation

protected Orientation orientation
Orientation of the legend


actualSize

protected java.awt.Dimension actualSize
Actual size


drawBounds

protected Rectangle2D drawBounds
Drawing bounds


margin

protected int margin
Margin


scrollRange

protected double scrollRange
Scrolling range


mouseClick

protected java.awt.Point mouseClick
Mouse click point


lastPt

protected java.awt.Point lastPt
Last point


currentSelection

protected LegendEntry currentSelection
Current selection


tempCursor

protected transient java.awt.Cursor tempCursor
Temporary cursor


moveCursor

protected transient java.awt.Cursor moveCursor
Moving cursor


cursorChanged

protected boolean cursorChanged
Cursor was changed


textPainter

protected AbstractTextPainter textPainter
Text painter


wordWrappingEnabled

protected boolean wordWrappingEnabled
Word wrapping is enabled


labelSorting

protected SortDirection labelSorting
Enables sorting of the labels


dimension

protected java.awt.Dimension dimension
Preferred size

Constructor Detail

AbstractLegend

public AbstractLegend()
Default abstract legend constructor

Method Detail

addEntry

public abstract void addEntry(LegendEntry entry)
Adds a new entry to the legend.

Parameters:
entry - new legend entry

addEntry

public abstract void addEntry(java.lang.String text,
                              LegendSymbol symbol)
Constructs and adds a new entry to the legend.

Parameters:
text - legend entry label
symbol - legend entry symbol

addEntries

public abstract void addEntries(LegendEntry[] ll)
Adds a list of entries the the legend at once.

Parameters:
ll - array of legend entries

addSeparator

public abstract void addSeparator()
Adds a separator to the legend.


addSeparator

public abstract void addSeparator(java.lang.String label)
Adds a separator to the legend.

Parameters:
label - Separator label

setPreferredSize

public void setPreferredSize(java.awt.Dimension dimension)
Sets preferred size

Parameters:
dimension - preferred size

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Description copied from class: AbstractView
Sets the preferred size of the receiving view.

Specified by:
setPreferredSize in interface View
Overrides:
setPreferredSize in class AbstractView<LegendPaintTags>
Parameters:
width - the preferred width of the receiving view
height - the preferred height of the receiving view

getPreferredSize

public abstract java.awt.Dimension getPreferredSize(AbstractGraphics g)
Gets the preferred size of this legend.

Specified by:
getPreferredSize in interface View
Overrides:
getPreferredSize in class AbstractView<LegendPaintTags>
Parameters:
g - the Graphics context in which legend will be painted
Returns:
A dimension object indicating this legend's preferred size.

setOrientation

public void setOrientation(Orientation orientation)
Sets legend orientation. Orientation.VERTICAL - entities are arranged into rows. Orientation.HORIZONTAL - entities are arranged into columns.

Parameters:
orientation - - the orientation value

getOrientation

public Orientation getOrientation()
Returns orientation of legend layout.

Returns:
orientation of legend layout.

setLayout

public void setLayout(LegendLayout layout)
Sets the legend layout.

Parameters:
layout - - legend layout type.

getLayout

public LegendLayout getLayout()
Returns style of legend layout.

Returns:
legend layout style

initCursor

public void initCursor()
Initialize cursor


setWordWrappingEnabled

public void setWordWrappingEnabled(boolean enable)
Enables/disabled word wrapping in text of legend entries. By default word wrapping is disabled.

Parameters:
enable - true for enabling, false for disabling.

getWordWrappingEnabled

public boolean getWordWrappingEnabled()
Returns whether or not word wrapping for text of legend entries is enabled.

Returns:
true if enabled, false if disabled.

isHorizontallyExpandable

public boolean isHorizontallyExpandable()
Description copied from interface: ExpandableDecoration
Should return true if width of this view, when persisting in top or bottom position inside DecoratedView, should be expanded to maximum space available.

Specified by:
isHorizontallyExpandable in interface ExpandableDecoration
Returns:
true if view's width should be expanded to maximum, false other wise.

isVerticallyExpandable

public boolean isVerticallyExpandable()
Description copied from interface: ExpandableDecoration
Should return true if height of this view, when persisting in left or right position inside DecoratedView, should be expanded to maximum space available.

Specified by:
isVerticallyExpandable in interface ExpandableDecoration
Returns:
true if view's height should be expanded to maximum, false other wise.

readObject

protected void readObject(java.io.ObjectInputStream in)
                   throws java.io.IOException
Throws:
java.io.IOException

setHorizontalAlignment

public void setHorizontalAlignment(Alignment align)
Sets Legend entries text vertical alignment.

Parameters:
align - value of vertical alignment. Possible values are: TextPainter.CENTER, TextPainter.TOP, TextPainter.BOTTOM.

setVerticalAlignment

public void setVerticalAlignment(Alignment align)
Sets Legend entries text vertical alignment.

Parameters:
align - value of vertical alignment. Possible values are: TextPainter.CENTER, TextPainter.TOP, TextPainter.BOTTOM.

setLabelAlignment

public void setLabelAlignment(Alignment hAlign,
                              Alignment vAlign)
Sets alignment for labels.

Parameters:
hAlign - - horizontal alignment value.
vAlign - - vertical alignment value.

getLabelVAlignment

public Alignment getLabelVAlignment()
Returns vertical alignment of labels.

Returns:
vertical alignment value.

getLabelHAlignment

public Alignment getLabelHAlignment()
Returns horizontal alignment of labels.

Returns:
horizontal alignment value.

removeAllEntries

public void removeAllEntries()
Removes all legend entries


getEntries

public java.util.Enumeration<LegendEntry> getEntries()
Gets entries of the legend.

Returns:
entries of the legend

removeEntry

public void removeEntry(LegendEntry entry)
Removes legend entry.

Parameters:
entry - legend entry

getEntry

public LegendEntry getEntry(int index)
Returns a Legend entry at specified position.

Parameters:
index - position of element in Legend entries array.
Returns:
Legend entry at specified index.

dispose

public void dispose()
Cleans this legend object. After this legend object is unusable and can be garbage collected.

Specified by:
dispose in interface View
Overrides:
dispose in class AbstractView<LegendPaintTags>

setCurrentSelection

public void setCurrentSelection(LegendEntry selection)
Selects the specified legend entry.

Parameters:
selection - the legend entry to select

getTextStyle

public TextStyle<LegendPaintTags> getTextStyle()
Gets text style object, which is used to set text properties

Returns:
the text style object

getLabelSorting

public SortDirection getLabelSorting()
Gets sorting option for the labels

Returns:
gets value what sorting is enabled

setLabelSorting

public void setLabelSorting(SortDirection labelSorting)
Sets sorting option for the labels

Parameters:
labelSorting - set ASCENDING or DESCENDING if labels should be sorted

sortLabels

protected void sortLabels()
Sorts legend entry labels


getStyle

public AbstractStyle getStyle(StyleType styleType)
Description copied from interface: StyleEditorEntity
Gets style object for the stylesheet attributes specified by style type.

Specified by:
getStyle in interface StyleEditorEntity
Overrides:
getStyle in class AbstractView<LegendPaintTags>
Parameters:
styleType - style type attributes
Returns:
the style object

getContainingObjects

public java.util.List<LegendEntry> getContainingObjects()
Returns all containing legend entries

Specified by:
getContainingObjects in interface View
Returns:
list of LegendEntry