JIDE 3.5.15

com.jidesoft.chart.axis
Class SimpleNumericTickCalculator

java.lang.Object
  extended by com.jidesoft.chart.axis.SimpleNumericTickCalculator
All Implemented Interfaces:
NumericTickCalculator, TickCalculator<Double>

public class SimpleNumericTickCalculator
extends Object
implements NumericTickCalculator

This class makes it easy to create custom ticks on a numeric axis by specifying an initial value for the location of a major tick and then specifying increments for major and (optionally) minor ticks. Note that the class has been designed so that the major tick increment does not have to be a multiple of the minor tick increment, although this is still the most common situation.

The class is called a SimpleNumericTickCalculator because it makes no provision for changing the distance between ticks when zooming. Zooming is well catered for by the DefaultNumericTickCalculator, which you get by default on a NumericAxis.


Field Summary
static String PROPERTY_MAJOR_TICK_INTERVAL
           
static String PROPERTY_MINOR_TICK_INTERVAL
           
static String PROPERTY_NUMBER_FORMAT
           
static String PROPERTY_START
           
 
Constructor Summary
SimpleNumericTickCalculator()
          Create a SimpleNumericTickCalculator
SimpleNumericTickCalculator(double start, double majorTickInterval)
          Create a SimpleNumericTickCalculator using the supplied start and majorTickInterval values.
SimpleNumericTickCalculator(double start, double majorTickInterval, double minorTickInterval)
          Create a SimpleNumericTickCalculator using the supplied start, majorTickInterval and minorTickInterval values.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers the supplied object as interested in property changes on this object
 Tick[] calculateTicks(Range<Double> range)
          Calculates the ticks and their labels according to the start and tick interval settings supplied
 double getMajorTickInterval()
          Returns the major tick interval used for calculating tick positions
 int getMaxTickCount()
          Returns the upper limit on the number of ticks that can be generated.
 Double getMinorTickInterval()
          Returns the minor tick interval used in calculating tick positions
 NumberFormat getNumberFormat()
          Returns the number format used for tick labels
 double getStart()
          Returns the initial lowest value used for calculating ticks
 void removePropertyChangeListener(PropertyChangeListener listener)
          De-registers the supplied object as interested in property changes on this object
 void setMajorTickInterval(double majorTickInterval)
          Specify the major tick interval used for calculating tick positions
 void setMaxTickCount(int maxTickCount)
          Set an upper limit on the number of ticks that can be generated.
 void setMinorTickInterval(Double minorTickInterval)
          Specifies the minor tick interval used in calculating tick positions
 void setNumberFormat(NumberFormat numberFormat)
          Specify the number format used when generating tick labels
 void setNumberFormat(String numberFormat)
          Uses the supplied string as a number format specifier as if supplied to the DecimalFormat class.
 void setStart(double start)
          Specifies the initial lowest value used for calculating ticks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NUMBER_FORMAT

public static final String PROPERTY_NUMBER_FORMAT
See Also:
Constant Field Values

PROPERTY_START

public static final String PROPERTY_START
See Also:
Constant Field Values

PROPERTY_MAJOR_TICK_INTERVAL

public static final String PROPERTY_MAJOR_TICK_INTERVAL
See Also:
Constant Field Values

PROPERTY_MINOR_TICK_INTERVAL

public static final String PROPERTY_MINOR_TICK_INTERVAL
See Also:
Constant Field Values
Constructor Detail

SimpleNumericTickCalculator

public SimpleNumericTickCalculator()
Create a SimpleNumericTickCalculator


SimpleNumericTickCalculator

public SimpleNumericTickCalculator(double start,
                                   double majorTickInterval)
Create a SimpleNumericTickCalculator using the supplied start and majorTickInterval values.

Parameters:
start - the lowest numeric tick value - assumed to be a major tick
majorTickInterval - the interval before the next major tick

SimpleNumericTickCalculator

public SimpleNumericTickCalculator(double start,
                                   double majorTickInterval,
                                   double minorTickInterval)
Create a SimpleNumericTickCalculator using the supplied start, majorTickInterval and minorTickInterval values.

Parameters:
start - the lowest numeric tick value - assumed to be a major tick
majorTickInterval - the interval before the next major tick
minorTickInterval - the interval before the next minor tick and the distance between subsequent minor ticks
Method Detail

getNumberFormat

public NumberFormat getNumberFormat()
Returns the number format used for tick labels

Specified by:
getNumberFormat in interface NumericTickCalculator
Returns:
the number format used for tick labels

setNumberFormat

public void setNumberFormat(NumberFormat numberFormat)
Specify the number format used when generating tick labels

Specified by:
setNumberFormat in interface NumericTickCalculator
Parameters:
numberFormat - the number format to use for tick labels

setNumberFormat

public void setNumberFormat(String numberFormat)
Uses the supplied string as a number format specifier as if supplied to the DecimalFormat class.

Specified by:
setNumberFormat in interface NumericTickCalculator
Parameters:
numberFormat - a numberFormat string as used by the DecimalFormat class

getStart

public double getStart()
Returns the initial lowest value used for calculating ticks

Returns:
the initial lowest value used for calculating ticks

setStart

public void setStart(double start)
Specifies the initial lowest value used for calculating ticks

Parameters:
start - the initial lowest value used for calculating ticks

getMajorTickInterval

public double getMajorTickInterval()
Returns the major tick interval used for calculating tick positions

Returns:
the major tick interval used for calculating tick positions

setMajorTickInterval

public void setMajorTickInterval(double majorTickInterval)
Specify the major tick interval used for calculating tick positions

Parameters:
majorTickInterval - the interval between major ticks

getMinorTickInterval

public Double getMinorTickInterval()
Returns the minor tick interval used in calculating tick positions

Returns:
the minor tick interval used in calculating tick positions

setMinorTickInterval

public void setMinorTickInterval(Double minorTickInterval)
Specifies the minor tick interval used in calculating tick positions

Parameters:
minorTickInterval - the interval between minor ticks

getMaxTickCount

public int getMaxTickCount()
Returns the upper limit on the number of ticks that can be generated.

Returns:
the maximum number of ticks that can be generated

setMaxTickCount

public void setMaxTickCount(int maxTickCount)
Set an upper limit on the number of ticks that can be generated. This property is a safety measure to guard against bad inputs and you should not normally need to adjust the value from its default.

Parameters:
maxTickCount - the maximum number of ticks to generate

calculateTicks

public Tick[] calculateTicks(Range<Double> range)
Calculates the ticks and their labels according to the start and tick interval settings supplied

Specified by:
calculateTicks in interface TickCalculator<Double>
Parameters:
range - the range for which ticks need to be calculated and returned
Returns:
an array of Ticks to use along the axis

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers the supplied object as interested in property changes on this object

Specified by:
addPropertyChangeListener in interface TickCalculator<Double>
Parameters:
listener - the interested object

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
De-registers the supplied object as interested in property changes on this object

Specified by:
removePropertyChangeListener in interface TickCalculator<Double>
Parameters:
listener - the object that is no longer interested in property changes on this object

JIDE 3.5.15