lt.monarch.chart.mapper
Class LabelAxisMapper

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

public class LabelAxisMapper
extends CountableAxisMapper

Label axis mapper.

See Also:
Serialized Form

Constructor Summary
Constructor and Description
LabelAxisMapper()
          Constructs a new LabelAxisMapper.
LabelAxisMapper(java.lang.Object[] keys)
          Constructs a new LabelAxisMapper with the specified set of labels.
LabelAxisMapper(java.lang.Object[] keys, AxisMapperRange range)
          Constructs a new LabelAxisMapper with the specified set of labels and specified visible range.
 
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.
 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.
 java.lang.Object mapBack(double pos)
          Finds a label on the axis nearest to the specified position.
 void registerKey(java.lang.Object key)
          Registers the specified key in the mapper.
 void registerKeys(java.lang.Object[] keys)
          Registers the specified key list to the mapper.
 void unregisterAll()
          Unregisters all keys from the mapper.
 void unregisterKey(java.lang.Object key)
          Unregisters specified key from the mapper.
 void unregisterKeys(java.lang.Object[] keys)
          Unregisters specified 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

LabelAxisMapper

public LabelAxisMapper()
Constructs a new LabelAxisMapper.


LabelAxisMapper

public LabelAxisMapper(java.lang.Object[] keys)
Constructs a new LabelAxisMapper with the specified set of labels.

Parameters:
keys - the labels array

LabelAxisMapper

public LabelAxisMapper(java.lang.Object[] keys,
                       AxisMapperRange range)
Constructs a new LabelAxisMapper with the specified set of labels and specified visible range.

Parameters:
keys - the labels array
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.

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.

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

registerKey

public void registerKey(java.lang.Object key)
Registers the specified key in the mapper. The specified label will appear on the axis. All axis mapper listeners are notified that mapping changed.

Parameters:
key - the key to register

unregisterKey

public void unregisterKey(java.lang.Object key)
Unregisters specified key from the mapper. The specified label is removed from axis. All axis mapper listeners are notified that mapping has changed.

Parameters:
key - a key that should be unregistered

unregisterKeys

public void unregisterKeys(java.lang.Object[] keys)
Unregisters specified keys from the mapper. The specified labels are removed from axis. All axis mapper listeners are notified that mapping has changed.

Parameters:
keys - the array of keys that should be unregistered.

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(java.lang.Object[] keys)
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 - array 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.

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