org.faceless.graph.formatter
Class Formatter

java.lang.Object
  extended by org.faceless.graph.formatter.Formatter
Direct Known Subclasses:
CurrencyFormatter, DateFormatter, DiscreteFormatter, FloatingPointFormatter, IntegerFormatter, NullFormatter, PercentageFormatter, SimpleFormatter

public abstract class Formatter
extends Object

A Formatter controls how the values displayed on the axis of a graph are displayed - as integers, floating point, percentages, dates etc.

Several concrete subclasses are provided which allow for easy graphing of integers, floats, percentages, dates and discrete values (like the names of the bars in a bar graph). The class can easily be overridden however to allow just about anything to be used as an axis value.


Field Summary
static int MINIMAL
          Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "minimal" level - depending on the data and formatter between 3 and 4 points.
static int NORMAL
          Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "normal" level - depending on the data and formatter, between about 8 and 14 points.
static int SPARSE
          Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "sparse" level - depending on the data and formatter, between about 4 and 7 points.
 
Method Summary
abstract  String format(double in)
          Return a String that is the formatted version of the input parameter.
 boolean isDiscrete()
          If this formatter is for formatting discrete values.
 void setDensity(int density)
           Set the "density" of the formatter - the number of ticks it asks to be printed on the axis.
 void setFixedEnds(boolean fixed)
           Cause the ends of the axes to be fixed to the min and max values of the data.
 double[] steps(double min, double max)
           Which steps between min and max should be marked on the axis.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "normal" level - depending on the data and formatter, between about 8 and 14 points.

See Also:
Constant Field Values

SPARSE

public static final int SPARSE
Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "sparse" level - depending on the data and formatter, between about 4 and 7 points.

See Also:
Constant Field Values

MINIMAL

public static final int MINIMAL
Passed to the setDensity(int) method to set the number of ticks returned by this formatter to a "minimal" level - depending on the data and formatter between 3 and 4 points.

See Also:
Constant Field Values
Method Detail

setDensity

public void setDensity(int density)

Set the "density" of the formatter - the number of ticks it asks to be printed on the axis. Valid values are either NORMAL (the default), SPARSE or MINIMAL

Whether the subclass of formatter uses or ignores this value is down to it's implementation.

Parameters:
the - density of the formatter
Since:
1.0.5

setFixedEnds

public void setFixedEnds(boolean fixed)

Cause the ends of the axes to be fixed to the min and max values of the data. When this value is set to false, plotting data from (say) 31 to 78 would probably result in an axis that ran from 30 to 80. When this value is set to true, the axes will always start and end at the end of the data - 31 to 78 in this case. The default is false, except for the X-axis on area graphs, which default to true

Since:
1.1.5

format

public abstract String format(double in)
Return a String that is the formatted version of the input parameter.


isDiscrete

public boolean isDiscrete()
If this formatter is for formatting discrete values. This returns false, which is true for every one of it's subclasses except the DiscreteFormatter, which overrides this method


steps

public double[] steps(double min,
                      double max)

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.



Copyright © 2001-2012 Big Faceless Organization