org.geotoolkit.display.axis
Class NumberGraduation

Object
  extended by AbstractGraduation
      extended by NumberGraduation
All Implemented Interfaces:
Serializable, Localized, Graduation
Direct Known Subclasses:
LogarithmicNumberGraduation

public class NumberGraduation
extends AbstractGraduation

A graduation using numbers on a linear axis.

Since:
2.0
Version:
3.00
Author:
Martin Desruisseaux (MPO, IRD)
See Also:
Serialized Form
Module:
display/geotk-display (download)    View source code for this class

Field Summary
 
Fields inherited from class AbstractGraduation
listenerList
 
Fields inherited from interface Graduation
AXIS_TITLE_FONT, TICK_LABEL_FONT, VISUAL_AXIS_LENGTH, VISUAL_TICK_SPACING
 
Constructor Summary
NumberGraduation(Unit<?> unit)
          Constructs a graduation with the supplied units.
 
Method Summary
 boolean equals(Object object)
          Compares this graduation with the specified object for equality.
 NumberFormat getFormat()
          Returns the format used for formatting labels.
 double getMaximum()
          Returns the maximal value for this graduation.
 double getMinimum()
          Returns the minimal value for this graduation
 double getSpan()
          Returns the graduation's range.
 TickIterator getTickIterator(RenderingHints hints, TickIterator reuse)
          Returns an iterator object that iterates along the graduation ticks and provides access to the graduation values.
 int hashCode()
          Returns a hash value for this graduation.
 void setFormat(NumberFormat format)
          Sets the format used for formatting labels.
 boolean setMaximum(double value)
          Sets the maximum value for this graduation.
 boolean setMinimum(double value)
          Sets the minimum value for this graduation.
 void setRange(double min, double max, Unit<?> unit)
          Sets the graduation's minimum, maximum and units.
 void setUnit(Unit<?> unit)
          Changes the graduation's units.
 
Methods inherited from class AbstractGraduation
addPropertyChangeListener, getLocale, getTitle, getUnit, removePropertyChangeListener, setLocale, setTitle, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberGraduation

public NumberGraduation(Unit<?> unit)
Constructs a graduation with the supplied units.

Parameters:
unit - The axis's units, or null if unknown.
Method Detail

setMinimum

public boolean setMinimum(double value)
                   throws IllegalArgumentException
Sets the minimum value for this graduation. If the new minimum is greater than the current maximum, then the maximum will also be set to a value greater than or equal to the minimum.

Specified by:
setMinimum in class AbstractGraduation
Parameters:
value - The new minimum in AbstractGraduation.getUnit() units.
Returns:
true if the state of this graduation changed as a result of this call, or false if the new value is identical to the previous one.
Throws:
IllegalArgumentException - Si value is NaN ou infinite.
See Also:
getMinimum(), setMaximum(double)

setMaximum

public boolean setMaximum(double value)
                   throws IllegalArgumentException
Sets the maximum value for this graduation. If the new maximum is less than the current minimum, then the minimum will also be set to a value less than or equal to the maximum.

Specified by:
setMaximum in class AbstractGraduation
Parameters:
value - The new maximum in AbstractGraduation.getUnit() units.
Returns:
true if the state of this graduation changed as a result of this call, or false if the new value is identical to the previous one.
Throws:
IllegalArgumentException - If value is NaN ou infinite.
See Also:
getMaximum(), setMinimum(double)

getMinimum

public double getMinimum()
Returns the minimal value for this graduation

Returns:
The minimal value in AbstractGraduation.getUnit() units.
See Also:
setMinimum(double), getMaximum(), getSpan()

getMaximum

public double getMaximum()
Returns the maximal value for this graduation.

Returns:
The maximal value in AbstractGraduation.getUnit() units.
See Also:
setMaximum(double), getMinimum(), getSpan()

getSpan

public double getSpan()
Returns the graduation's range. This is equivalents to computing getMaximum() - getMinimum().

Returns:
The graduation range.

setRange

public void setRange(double min,
                     double max,
                     Unit<?> unit)
Sets the graduation's minimum, maximum and units. This method will fire property change events for "minimum", "maximum" and "unit" property names.

Parameters:
min - The minimal value in the graduation.
max - The maximal value in the graduation.
unit - The graduation unit.

setUnit

public void setUnit(Unit<?> unit)
             throws IllegalArgumentException
Changes the graduation's units. This method will automatically convert minimum and maximum values from the old units to the new one.

Overrides:
setUnit in class AbstractGraduation
Parameters:
unit - The new units, or null if unknown. If null, minimum and maximum values are not converted.
Throws:
IllegalArgumentException - if units are not convertible.

getFormat

public NumberFormat getFormat()
Returns the format used for formatting labels. The TickIterator.currentLabel() method will use a copy of this format configured in the same way except for the number of fraction digits, which will be calculated automatically.

This method returns a direct reference to the format used internally - not a clone. If the returned format is changed, then the changes will be reflected in the next tick iterations except for the properties that are automatically calculated. Note however that it is advisable to invoke setFormat(NumberFormat) after a change in order to keep the listener list informed.

Returns:
The labels format.

setFormat

public void setFormat(NumberFormat format)
Sets the format used for formatting labels. This method stores the given format directly - it is not cloned.

Parameters:
format - The new format.

getTickIterator

public TickIterator getTickIterator(RenderingHints hints,
                                    TickIterator reuse)
Returns an iterator object that iterates along the graduation ticks and provides access to the graduation values. If an optional RenderingHints is specified, tick locations are adjusted according values for Graduation.VISUAL_AXIS_LENGTH and Graduation.VISUAL_TICK_SPACING keys.

Parameters:
hints - Rendering hints, or null for the default hints.
reuse - An iterator to reuse if possible, or null to create a new one. A non-null object may help to reduce the number of object garbage-collected when rendering the axis.
Returns:
A iterator to use for iterating through the graduation. This iterator may or may not be the reuse object.

equals

public boolean equals(Object object)
Compares this graduation with the specified object for equality. This method do not compare registered listeners.

Overrides:
equals in class AbstractGraduation
Parameters:
object - The object to compare with.
Returns:
true if this graduation is equal to the given object.

hashCode

public int hashCode()
Returns a hash value for this graduation.

Overrides:
hashCode in class AbstractGraduation


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.