lt.monarch.chart.legend
Class ColorScaleLegend

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

public class ColorScaleLegend
extends AbstractLegend

ColorScaleLegend view. Maintains a list of legend entries and renders a legend.

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
 
Nested classes/interfaces inherited from class lt.monarch.chart.engine.AbstractLegend
AbstractLegend.LegendEntryEntity
 
Field Summary
Modifier and Type Field and Description
protected  Alignment horizontalLabelAlignment
          Horizontal label alignment
protected  lt.monarch.chart.legend.ColorScaleLegend.MouseEvents mouseEvents
          Mouse event listener
protected  java.util.ArrayList<LegendEntry> sortedEntries
          Sorted legend entries, which requires special treatment to be represented correctly
protected  Alignment verticalLabelAlignment
          Vertical label alignment
 
Fields inherited from class lt.monarch.chart.engine.AbstractLegend
actualSize, currentSelection, cursorChanged, dimension, drawBounds, entries, labelSorting, lastPt, layout, margin, mouseClick, moveCursor, orientation, scrollRange, style, tempCursor, textPainter, textStyle, wordWrappingEnabled
 
Fields inherited from class lt.monarch.chart.AbstractView
layoutInvalid, paintStyle
 
Constructor Summary
Constructor and Description
ColorScaleLegend()
          Creates an empty ColorScaleLegend object
ColorScaleLegend(Chart chart)
          Creates a ColorScaleLegend object and initializes it with data from the chart object
ColorScaleLegend(LegendEntry[] entries)
          Creates a ColorScaleLegend object and initializes it with the entry list
 
Method Summary
Modifier and Type Method and Description
protected  void activate()
          Activates the legend.
 void addEntries(LegendEntry[] ll)
          Adds a list of entries the the legend at once.
 void addEntry(LegendEntry entry)
          Adds a new entry to the legend.
 void addEntry(java.lang.String text, LegendSymbol symbol)
          Constructs and adds a new entry to the legend.
 void addSeparator()
          Adds a separator to the legend.
 void addSeparator(java.lang.String label)
          Adds a separator to the legend.
protected  void deactivate()
          Deactivates the legend.
 java.util.List<LegendEntry> getContainingObjects()
          Returns all containing legend entries
protected  java.awt.Dimension[] getEntryDimensions(AbstractGraphics g)
          Computes and returns dimensions of legend entries.
 Alignment getLabelHAlignment()
          Returns horizontal alignment for ColorScaleLegend labels.
 Alignment getLabelVAlignment()
          Returns vertical alignment for ColorScaleLegend labels.
protected  int getMaxKeyWidth(AbstractGraphics g)
          Returns the width of the widest legend symbol.
 java.awt.Dimension getPreferredSize(AbstractGraphics g)
          Gets the preferred size of this legend.
protected  void layout(AbstractGraphics g)
          Layouts the legend.
protected  void paint(AbstractGraphics g)
          Paints the legend in the specified Graphics context.
 void setLabelAlignment(Alignment hAlign, Alignment vAlign)
          Sets alignment for ColorScaleLegend labels.
 
Methods inherited from class lt.monarch.chart.engine.AbstractLegend
dispose, getEntries, getEntry, getLabelSorting, getLayout, getOrientation, getStyle, getTextStyle, getWordWrappingEnabled, initCursor, isHorizontallyExpandable, isVerticallyExpandable, readObject, removeAllEntries, removeEntry, setCurrentSelection, setHorizontalAlignment, setLabelSorting, setLayout, setOrientation, setPreferredSize, setPreferredSize, setVerticalAlignment, setWordWrappingEnabled, sortLabels
 
Methods inherited from class lt.monarch.chart.AbstractView
addViewListener, clone, container, finalize, getAlignmentX, getAlignmentY, getBounds, getChartObjectBounds, getContainer, getGraphicsType, getHeight, getMaximumSize, getMinimumSize, getPaintMode, getPaintStyle, getParent, getSize, getSize, getStyle, getWidth, getX, getY, invalidate, isLayoutValid, 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

sortedEntries

protected java.util.ArrayList<LegendEntry> sortedEntries
Sorted legend entries, which requires special treatment to be represented correctly


mouseEvents

protected lt.monarch.chart.legend.ColorScaleLegend.MouseEvents mouseEvents
Mouse event listener


horizontalLabelAlignment

protected Alignment horizontalLabelAlignment
Horizontal label alignment


verticalLabelAlignment

protected Alignment verticalLabelAlignment
Vertical label alignment

Constructor Detail

ColorScaleLegend

public ColorScaleLegend()
Creates an empty ColorScaleLegend object


ColorScaleLegend

public ColorScaleLegend(Chart chart)
Creates a ColorScaleLegend object and initializes it with data from the chart object

Parameters:
chart - chart object to be used

ColorScaleLegend

public ColorScaleLegend(LegendEntry[] entries)
Creates a ColorScaleLegend object and initializes it with the entry list

Parameters:
entries - legend entries
Method Detail

addEntry

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

Specified by:
addEntry in class AbstractLegend
Parameters:
entry - new legend entry

addEntry

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

Specified by:
addEntry in class AbstractLegend
Parameters:
text - legend entry label
symbol - legend entry symbol

addEntries

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

Specified by:
addEntries in class AbstractLegend
Parameters:
ll - array of legend entries

addSeparator

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

Specified by:
addSeparator in class AbstractLegend

addSeparator

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

Specified by:
addSeparator in class AbstractLegend
Parameters:
label - Separator label

getMaxKeyWidth

protected int getMaxKeyWidth(AbstractGraphics g)
Returns the width of the widest legend symbol.

Parameters:
g - the Graphics context in which legend will be painted
Returns:
the width of the widest legend entry

getEntryDimensions

protected java.awt.Dimension[] getEntryDimensions(AbstractGraphics g)
Computes and returns dimensions of legend entries.

Parameters:
g - the Graphics context in which legend will be painted
Returns:
an array of Dimension objects, representing dimensions of the legend entries

getPreferredSize

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

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

layout

protected void layout(AbstractGraphics g)
Layouts the legend.

Overrides:
layout in class AbstractView<LegendPaintTags>
Parameters:
g - the Graphics context in which legend will be painted

setLabelAlignment

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

Overrides:
setLabelAlignment in class AbstractLegend
Parameters:
hAlign - - horizontal alignment value.
vAlign - - vertical alignment value.

getLabelVAlignment

public Alignment getLabelVAlignment()
Returns vertical alignment for ColorScaleLegend labels.

Overrides:
getLabelVAlignment in class AbstractLegend
Returns:
vertical alignment value.

getLabelHAlignment

public Alignment getLabelHAlignment()
Returns horizontal alignment for ColorScaleLegend labels.

Overrides:
getLabelHAlignment in class AbstractLegend
Returns:
horizontal alignment value.

paint

protected void paint(AbstractGraphics g)
Paints the legend in the specified Graphics context.

Specified by:
paint in class AbstractView<LegendPaintTags>
Parameters:
g - the Graphics context in which to paint legend

activate

protected void activate()
Activates the legend.

Overrides:
activate in class AbstractView<LegendPaintTags>

deactivate

protected void deactivate()
Deactivates the legend.

Overrides:
deactivate in class AbstractView<LegendPaintTags>

getContainingObjects

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

Specified by:
getContainingObjects in interface View
Overrides:
getContainingObjects in class AbstractLegend
Returns:
list of LegendEntry