Interface IAxisLabelFormatter
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
ALabelFormatter
,LabelFormatterAutoUnits
,LabelFormatterDate
,LabelFormatterNumber
,LabelFormatterSimple
,LabelFormatterUnit
public interface IAxisLabelFormatter extends java.io.Serializable
An interface used by Axis to format labels and determine the maximum width for the labels.In order to get as much labels as possible on the Chart2D's axes, an Axis should be configured in a way that reduces the return value of the method
getMaxAmountChars()
.- Version:
- $Revision: 1.5 $
- Author:
- Achim Westermann
- See Also:
AAxis
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_FORMATCHANGE
Constant for
fired when the configuration changes.PropertyChangeEvent
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Registers a property change listener that will be informed about changes of the property identified by the givenpropertyName
.java.lang.String
format(double value)
Provide a String for the value.int
getMaxAmountChars()
Returns the maximum amount of characters that will be returned fromformat(double)
.double
getMinimumValueShiftForChange()
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.AUnit
getUnit()
Returns the unit that is currently used by this formatter.void
initPaintIteration()
java.lang.Number
parse(java.lang.String formatted)
The reverse operation to
.format(double)
void
removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
Deregisters a property change listener that has been registerd for listening on the given property.void
setAxis(IAxis<?> axis)
Allows theAAxis
to register itself with the given formatter so that it may get information about the data (e.g.
-
-
-
Field Detail
-
PROPERTY_FORMATCHANGE
static final java.lang.String PROPERTY_FORMATCHANGE
Constant for
fired when the configuration changes.PropertyChangeEvent
- See Also:
- Constant Field Values
-
-
Method Detail
-
addPropertyChangeListener
void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Registers a property change listener that will be informed about changes of the property identified by the givenpropertyName
.- 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
-
format
java.lang.String format(double value)
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.
-
getMaxAmountChars
int getMaxAmountChars()
Returns the maximum amount of characters that will be returned fromformat(double)
.- Returns:
- the maximum amount of characters that will be returned from
format(double)
.
-
getMinimumValueShiftForChange
double getMinimumValueShiftForChange()
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
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.
-
getNextEvenValue
double getNextEvenValue(double value, boolean ceiling)
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.
-
getUnit
AUnit getUnit()
Returns the unit that is currently used by this formatter.- Returns:
- the unit that is currently used by this formatter.
-
initPaintIteration
void initPaintIteration()
-
parse
java.lang.Number parse(java.lang.String formatted) throws java.lang.NumberFormatException
The reverse operation to
.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
.format(double)
- Returns:
- the parsed number.
- Throws:
java.lang.NumberFormatException
- if the format of the argument is invalid.
-
removePropertyChangeListener
void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
Deregisters a property change listener that has been registerd for listening on the given property.- Parameters:
listener
- a listener that will only be informed if the property identified by the argumentpropertyName
changesproperty
- the property the listener was registered to.
-
setAxis
void setAxis(IAxis<?> axis)
Allows theAAxis
to register itself with the given formatter so that it may get information about the data (e.g. range) it has to format.This method should only be invoked by
AAxis
, all other invocations will cause trouble.- Parameters:
axis
- the axis to gain information about.
-
-