Class LabelFormatterAutoUnits
- All Implemented Interfaces:
IAxisLabelFormatter
,Serializable
IAxisLabelFormatter
.
The formatted Strings will be divided by a factor according to the automatic chosen unit.
- Version:
- $Revision: 1.22 $
- Author:
- Achim Westermann
- See Also:
-
Field Summary
Fields inherited from class info.monitorenter.gui.chart.labelformatters.ALabelFormatter
m_propertyChangeSupport, UNIT_UNCHANGED
Fields inherited from interface info.monitorenter.gui.chart.IAxisLabelFormatter
PROPERTY_FORMATCHANGE
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that uses a
to add the auto unit feature to.LabelFormatterSimple
LabelFormatterAutoUnits
(ALabelFormatter delegate) Creates an instance that will add "unit-functionality" to the given formatter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(String propertyName, PropertyChangeListener listener) Registers a property change listener that will be informed about changes of the property identified by the givenpropertyName
.format
(double value) Provide a String for the value.IAxis
<?> getAxis()
Intended forAAxis
only.int
Returns the maximum amount of characters that will be returned fromIAxisLabelFormatter.format(double)
.double
Returns the minimum change in the value to format that will cause to return a different formatted String.double
getNextEvenValue
(double value, boolean ceiling) Returns the next "even" value to the given one.getUnit()
ReturnsALabelFormatter.UNIT_UNCHANGED
.void
Void adapter method implementation - optional to override.The reverse operation to
.IAxisLabelFormatter.format(double)
void
removePropertyChangeListener
(String property, PropertyChangeListener listener) Deregisters a property change listener that has been registerd for listening on the given property.void
Intended forAAxis
only.toString()
Methods inherited from class info.monitorenter.gui.chart.labelformatters.ALabelFormatter
equals, hashCode
-
Constructor Details
-
LabelFormatterAutoUnits
public LabelFormatterAutoUnits()Default constructor that uses a
to add the auto unit feature to.LabelFormatterSimple
-
LabelFormatterAutoUnits
Creates an instance that will add "unit-functionality" to the given formatter.- Parameters:
delegate
- the formatter that will be decorated with units.
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:IAxisLabelFormatter
Registers a property change listener that will be informed about changes of the property identified by the givenpropertyName
.- Specified by:
addPropertyChangeListener
in interfaceIAxisLabelFormatter
- Overrides:
addPropertyChangeListener
in classALabelFormatter
- Parameters:
propertyName
- the name of the property the listener is interested inlistener
- a listener that will only be informed if the property identified by the argumentpropertyName
changes- See Also:
-
format
Description copied from interface:IAxisLabelFormatter
Provide a String for the value. Subclasses should override the label formatting here. The raw value is passed here to allow a general treatment. Transformations of this raw value should be done here (e.g. division by multiples of 1000 for scientific unit system display, date formatting,...).- Parameters:
value
- the value to format.- Returns:
- the formatted value.
- See Also:
-
getAxis
Description copied from class:ALabelFormatter
Intended forAAxis
only.- Overrides:
getAxis
in classALabelFormatter
- Returns:
- Returns the axis.
- See Also:
-
getMaxAmountChars
public int getMaxAmountChars()Description copied from class:ALabelFormatter
Returns the maximum amount of characters that will be returned fromIAxisLabelFormatter.format(double)
.- Specified by:
getMaxAmountChars
in interfaceIAxisLabelFormatter
- Overrides:
getMaxAmountChars
in classALabelFormatter
- Returns:
- the maximum amount of characters that will be returned from
IAxisLabelFormatter.format(double)
. - See Also:
-
getMinimumValueShiftForChange
public double getMinimumValueShiftForChange()Description copied from interface:IAxisLabelFormatter
Returns the minimum change in the value to format that will cause to return a different formatted String.To achieve two different formatted Strings to be returned from the format method the corresponding values given to the format method have to differ at least by this value.
Some implementations (e.g. a formatter for date) have to use their own format method an increas a value to determine when the first change will occur. This is expensive and it's recommended that this action is performed once only and the result is stored. Additionally this routine has to start with an "even" (see
IAxisLabelFormatter.getNextEvenValue(double, boolean)
) value to get a correct result (the distance from even number to even number).- Returns:
- the minimum change in the value to format that will cause to return a different formatted String.
- See Also:
-
getNextEvenValue
public double getNextEvenValue(double value, boolean ceiling) Description copied from interface:IAxisLabelFormatter
Returns the next "even" value to the given one. "Even" means that the format method will exactly return the String for the value and not cut or round any information. A label String created with an "even" number will be exactly at the position it describes.- Parameters:
value
- the value to get the next "even" value for.ceiling
- if true, the next higher number will returned, else the next lower one.- Returns:
- the next "even" value to the given one.
- See Also:
-
getUnit
Description copied from class:ALabelFormatter
ReturnsALabelFormatter.UNIT_UNCHANGED
.- Specified by:
getUnit
in interfaceIAxisLabelFormatter
- Overrides:
getUnit
in classALabelFormatter
- Returns:
ALabelFormatter.UNIT_UNCHANGED
- See Also:
-
initPaintIteration
public void initPaintIteration()Description copied from class:ALabelFormatter
Void adapter method implementation - optional to override.- Specified by:
initPaintIteration
in interfaceIAxisLabelFormatter
- Overrides:
initPaintIteration
in classALabelFormatter
- See Also:
-
parse
Description copied from interface:IAxisLabelFormatter
The reverse operation to
.IAxisLabelFormatter.format(double)
The given argument has to be in the format that will be generated by that method or exceptions may be thrown.
test.parse(test.format(d))== d
has to be true if no rounding occurs by the formatter.- Parameters:
formatted
- aString
in the format that will be produced by method
.IAxisLabelFormatter.format(double)
- Returns:
- the parsed number.
- Throws:
NumberFormatException
- if the format of the argument is invalid.- See Also:
-
removePropertyChangeListener
Description copied from interface:IAxisLabelFormatter
Deregisters a property change listener that has been registerd for listening on the given property.- Specified by:
removePropertyChangeListener
in interfaceIAxisLabelFormatter
- Overrides:
removePropertyChangeListener
in classALabelFormatter
- Parameters:
property
- the property the listener was registered to.listener
- a listener that will only be informed if the property identified by the argumentpropertyName
changes- See Also:
-
setAxis
Description copied from class:ALabelFormatter
Intended forAAxis
only.Do never invoke this! This is only public for package sorting reasons.
- Specified by:
setAxis
in interfaceIAxisLabelFormatter
- Overrides:
setAxis
in classALabelFormatter
- Parameters:
axis
- The m_axis to set.- See Also:
-
toString
-