|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph.formatter.Formatter
org.faceless.graph.formatter.DateFormatter
public class DateFormatter
A subclasss of Formatter
that deals with dates and times.
The Date formatter will select "useful" dates to plot on the axis that
fall into the given timespan. The smallest unit this class can handle
is the second, and it can be used to plot date ranges from between 2
seconds and a hundred years. The returned dates are those that we consider
"sensible" depending on the range - for example, every 15 seconds, every
day or the first of every quarter (the number of values returned can be
set with the Formatter.setDensity(int)
method). The start and end dates specified
are always returned.
In addition, because of the non-uniform spacing of days in the year
(e.g. February 1st is 31 days after January 1st, but March 1st is
only another 28 days) the spacing between entries may not be uniform.
We felt this was less of a compromise than returning dates like
01-Jan
, 01-Feb
, 04-Mar
, but if
you think otherwise then we would recommend writing a custom subclass
of Formatter
for complete control over the output.
Field Summary |
---|
Fields inherited from class org.faceless.graph.formatter.Formatter |
---|
MINIMAL, NORMAL, SPARSE |
Constructor Summary | |
---|---|
DateFormatter()
Create a new DataFormatter with a format of "dd MMM yy" |
|
DateFormatter(DateFormat format)
Create a new DataFormatter with the specified format |
|
DateFormatter(DateFormat format,
int density)
Create a new DateFormatter with the specified format and density |
|
DateFormatter(int density)
Create a new DataFormatter with a format of "dd MMM yy" and the specified density |
Method Summary | |
---|---|
String |
format(double in)
Return a String that is the formatted version of the input parameter. |
double[] |
steps(double min,
double max)
Which steps between min and max should be marked on the axis. |
static Date |
toDate(double in)
Convert a double to a Date. |
static double |
toDouble(Date in)
Convert a date to a double, so it can be stored internally. |
Methods inherited from class org.faceless.graph.formatter.Formatter |
---|
isDiscrete, setDensity, setFixedEnds |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DateFormatter()
public DateFormatter(int density)
density
- the density of the formatter - one of Formatter.NORMAL
, Formatter.SPARSE
or Formatter.MINIMAL
public DateFormatter(DateFormat format)
format
- The DateFormat
to use.public DateFormatter(DateFormat format, int density)
format
- The DateFormat
to use.density
- the density of the formatter - one of Formatter.NORMAL
, Formatter.SPARSE
or Formatter.MINIMAL
Method Detail |
---|
public String format(double in)
Formatter
format
in class Formatter
public static Date toDate(double in)
public static double toDouble(Date in)
DataCurve data = new DataCurve(); Date today = new Date(); data.set(DateFormatter.toDouble(today), 123.45);
public double[] steps(double min, double max)
Formatter
Which steps between min and max should be marked on the axis.
This is an array because although the steps will usually be
evenly spaced, they may not always be (see the DateFormatter
for an example).
This method returns the default settings, which is to calculate a number of "useful" values between min and max, possibly rounding those two values up or down to fit the scale. The number of values returned depends on the density setting.
steps
in class Formatter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |