|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.monitorenter.gui.chart.labelformatters.ALabelFormatter info.monitorenter.gui.chart.labelformatters.LabelFormatterDate
public class LabelFormatterDate
An ILabelFormatter instance that uses a DateFormat
to
format the labels.
Caution:
It only makes sense to use this class if the data of the corresponding axis
may be interpreted as long number of milliseconds since the standard base
time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
Caution:
This implementation is not completely conform with the constraint:
instance.parse(instance.format(value)) == value
This only works for subsequent call: one call to format contains the
next value to return from parse to be the same as the format. That value is
cached as date / time formatting produces truncation of the internal value
(e.g. if no year is displayed).
Use:
Chart2D chart = new <Constructor> Axis axis = new AxisSimple(); axis.setFormatter(new LabelFormatterDate(DateFormat.getDateInstance())); chart.setAxisX(axis);to use this class.
Date
,
Serialized FormField 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 | |
---|---|
LabelFormatterDate()
Default constructor that uses the local datetime ( ) with
style. |
|
LabelFormatterDate(java.text.SimpleDateFormat dateFormat)
Creates a formatter that uses the given date format. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
format(double value)
Provide a String for the value. |
int |
getMaxAmountChars()
Returns the maximum amount of characters that will be returned from IAxisLabelFormatter.format(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. |
int |
hashCode()
|
java.lang.Number |
parse(java.lang.String formatted)
The reverse operation to . |
Methods inherited from class info.monitorenter.gui.chart.labelformatters.ALabelFormatter |
---|
addPropertyChangeListener, getAxis, getUnit, initPaintIteration, removePropertyChangeListener, setAxis |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface info.monitorenter.gui.chart.IAxisLabelFormatter |
---|
addPropertyChangeListener, getUnit, initPaintIteration, removePropertyChangeListener, setAxis |
Constructor Detail |
---|
public LabelFormatterDate()
DateFormat.getDateTimeInstance(int, int)
) with
DateFormat.SHORT
style.
public LabelFormatterDate(java.text.SimpleDateFormat dateFormat)
dateFormat
- the date format to use.Method Detail |
---|
public boolean equals(java.lang.Object obj)
equals
in class ALabelFormatter
Object.equals(java.lang.Object)
public java.lang.String format(double value)
IAxisLabelFormatter
format
in interface IAxisLabelFormatter
value
- the value to format.
IAxisLabelFormatter.format(double)
public int getMaxAmountChars()
ALabelFormatter
IAxisLabelFormatter.format(double)
.
getMaxAmountChars
in interface IAxisLabelFormatter
getMaxAmountChars
in class ALabelFormatter
IAxisLabelFormatter.format(double)
.IAxisLabelFormatter.getMaxAmountChars()
public double getMinimumValueShiftForChange()
IAxisLabelFormatter
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).
getMinimumValueShiftForChange
in interface IAxisLabelFormatter
IAxisLabelFormatter.getMinimumValueShiftForChange()
public double getNextEvenValue(double value, boolean ceiling)
IAxisLabelFormatter
getNextEvenValue
in interface IAxisLabelFormatter
value
- the value to get the next "even" value for.ceiling
- if true, the next higher number will returned, else the next lower
one.
IAxisLabelFormatter.getNextEvenValue(double,
boolean)
public int hashCode()
hashCode
in class ALabelFormatter
Object.hashCode()
public java.lang.Number parse(java.lang.String formatted) throws java.lang.NumberFormatException
IAxisLabelFormatter
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.
parse
in interface IAxisLabelFormatter
formatted
- a String
in the format that will be produced by
method IAxisLabelFormatter.format(double)
.
java.lang.NumberFormatException
- if the format of the argument is invalid.IAxisLabelFormatter.parse(java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |