lt.monarch.chart.mapper
Class GroupedLabelsAxisMapper

java.lang.Object
  extended by lt.monarch.chart.mapper.AbstractAxisMapper
      extended by lt.monarch.chart.mapper.CountableAxisMapper
          extended by lt.monarch.chart.mapper.GroupedLabelsAxisMapper
All Implemented Interfaces:
java.io.Serializable, AxisMapper

public class GroupedLabelsAxisMapper
extends CountableAxisMapper

See Also:
Serialized Form

Constructor Summary
Constructor and Description
GroupedLabelsAxisMapper(LabelsGroup labelsGroup)
          Constructs a new GroupedLabelsAxisMapper with the specified LabelsGroup.
GroupedLabelsAxisMapper(LabelsGroup labelsGroup, AxisMapperRange range)
          Constructs a new GroupedLabelsAxisMapper with the specified LabelsGroup.
 
Method Summary
Modifier and Type Method and Description
 java.lang.String formatKey(java.lang.Object key)
          Returns a string representation of the specified key.
 int getLabelCount()
          Gets a number of registered keys (of all levels).
 double getPreferredHeight(AbstractGraphics g, AbstractTextPainter textPainter)
          Gets preferred height.
 double getPreferredWidth(AbstractGraphics g, AbstractTextPainter textPainter)
          Gets preferred width.
 java.lang.Object[] getRegisteredKeys()
          Returns array of currently registered keys.
 AxisScale getScale()
          Returns a scale object for this axis.
 AxisMapperRange getViewRange()
          Gets an AxisMapperRange object representing visible axis range.
 double map(java.lang.Object key)
          Finds a position on axis visible range for the specified label (grouped labels level 1).
 java.lang.Object mapBack(double pos)
          Finds a label on the axis nearest to the specified position (grouped labels level 1).
 void registerKeys(LabelsGroup labelsGroup)
          Registers the specified key list to the mapper.
 void unregisterAll()
          Unregisters all keys from the mapper.
 
Methods inherited from class lt.monarch.chart.mapper.CountableAxisMapper
getTextHeigh, getTextWidth
 
Methods inherited from class lt.monarch.chart.mapper.AbstractAxisMapper
addListener, fireMappingChanged, getProjectionRange, removeListener, setProjectionRange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupedLabelsAxisMapper

public GroupedLabelsAxisMapper(LabelsGroup labelsGroup)
Constructs a new GroupedLabelsAxisMapper with the specified LabelsGroup.

Parameters:
labelsGroup - the container of all grouped labels

GroupedLabelsAxisMapper

public GroupedLabelsAxisMapper(LabelsGroup labelsGroup,
                               AxisMapperRange range)
Constructs a new GroupedLabelsAxisMapper with the specified LabelsGroup. specified visible range.

Parameters:
labelsGroup - the container of all grouped labels
range - the visible axis range
Method Detail

getViewRange

public AxisMapperRange getViewRange()
Gets an AxisMapperRange object representing visible axis range. The object can be used to set visible axis range.

Returns:
AxisMapperRange object representing visible axis range

map

public double map(java.lang.Object key)
Finds a position on axis visible range for the specified label (grouped labels level 1).

Parameters:
key - the label to map
Returns:
label position on the axis visible range

mapBack

public java.lang.Object mapBack(double pos)
Finds a label on the axis nearest to the specified position (grouped labels level 1).

Specified by:
mapBack in interface AxisMapper
Overrides:
mapBack in class AbstractAxisMapper
Parameters:
pos - position on the axis visible part
Returns:
label nearest to the specified position
See Also:
AxisMapper.mapBack(double)

getScale

public AxisScale getScale()
Returns a scale object for this axis.

Returns:
a scale object for this axis

unregisterAll

public void unregisterAll()
Unregisters all keys from the mapper. All labels are removed from axis. All axis mapper listeners are notified that mapping has changed.


registerKeys

public void registerKeys(LabelsGroup labelsGroup)
Registers the specified key list to the mapper. The specified labels will appear on the axis. All axis mapper listeners are notified that mapping changed.

Parameters:
keys - list of keys to register

formatKey

public java.lang.String formatKey(java.lang.Object key)
Returns a string representation of the specified key. Key's toString method is used to create the string representation.

Parameters:
key - the key to format
Returns:
string representation of the specified key

getRegisteredKeys

public java.lang.Object[] getRegisteredKeys()
Returns array of currently registered keys.

Specified by:
getRegisteredKeys in class CountableAxisMapper
Returns:
array of registered keys.

getLabelCount

public int getLabelCount()
Gets a number of registered keys (of all levels).

Specified by:
getLabelCount in class CountableAxisMapper
Returns:
number of registered keys

getPreferredHeight

public double getPreferredHeight(AbstractGraphics g,
                                 AbstractTextPainter textPainter)
Description copied from interface: AxisMapper
Gets preferred height.

Parameters:
g - graphics context
textPainter - text painter mode
Returns:
preferred height

getPreferredWidth

public double getPreferredWidth(AbstractGraphics g,
                                AbstractTextPainter textPainter)
Description copied from interface: AxisMapper
Gets preferred width.

Parameters:
g - graphics context
textPainter - text painter mode
Returns:
preferred width