org.geotoolkit.display.axis
Class DateGraduation

Object
  extended by AbstractGraduation
      extended by DateGraduation
All Implemented Interfaces:
Serializable, Localized, Graduation

public class DateGraduation
extends AbstractGraduation

A graduation using dates 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
DateGraduation(TimeZone timezone)
          Constructs a graduation with the supplied time zone.
DateGraduation(TimeZone timezone, Unit<Duration> unit)
          Constructs a graduation with the supplied time zone and unit.
 
Method Summary
 boolean equals(Object object)
          Compares this graduation with the specified object for equality.
 DateFormat getFormat()
          Returns the format to use 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.
 TimeZone getTimeZone()
          Returns the timezone for this graduation.
 Unit<Duration> getUnit()
          Returns the graduation's units, or null if unknown.
 int hashCode()
          Returns a hash value for this graduation.
 boolean setMaximum(Date time)
          Set the maximum value for this graduation.
 boolean setMaximum(double value)
          Sets the maximum value as a real number.
 boolean setMinimum(Date time)
          Set the minimum value for this graduation.
 boolean setMinimum(double value)
          Sets the minimum value as a real number.
 void setTimeZone(TimeZone timezone)
          Sets the time zone for this graduation.
 void setUnit(Unit<?> unit)
          Changes the graduation units.
 
Methods inherited from class AbstractGraduation
addPropertyChangeListener, getLocale, getTitle, removePropertyChangeListener, setLocale, setTitle, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateGraduation

public DateGraduation(TimeZone timezone)
Constructs a graduation with the supplied time zone. Unit default to milliseconds.

Parameters:
timezone - The timezone.

DateGraduation

public DateGraduation(TimeZone timezone,
                      Unit<Duration> unit)
Constructs a graduation with the supplied time zone and unit.

Parameters:
timezone - The timezone.
unit - The unit, or null if unknown. Must be compatible with milliseconds.
Method Detail

getUnit

public Unit<Duration> getUnit()
Returns the graduation's units, or null if unknown.

Specified by:
getUnit in interface Graduation
Overrides:
getUnit in class AbstractGraduation
Returns:
The graduation units, or null.

setMinimum

public boolean setMinimum(Date time)
Set 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.

Parameters:
time - The new minimum.
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.
See Also:
setMaximum(Date)

setMaximum

public boolean setMaximum(Date time)
Set 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.

Parameters:
time - The new maximum.
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.
See Also:
setMinimum(Date)

setMinimum

public final boolean setMinimum(double value)
Sets the minimum value as a real number. This method converts the value to milliseconds and invokes setMinimum(Date).

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.
See Also:
Graduation.getMinimum(), AbstractGraduation.setMaximum(double)

setMaximum

public final boolean setMaximum(double value)
Sets the maximum value as a real number. This method converts the value to milliseconds and invokes setMaximum(Date).

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.
See Also:
Graduation.getMaximum(), AbstractGraduation.setMinimum(double)

getMinimum

public double getMinimum()
Returns the minimal value for this graduation. The value is in units of getUnit(). By default, it is the number of milliseconds elapsed since January 1st, 1970 at 00:00 UTC.

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

getMaximum

public double getMaximum()
Returns the maximal value for this graduation. The value is in units of getUnit(). By default, it is the number of milliseconds elapsed since January 1st, 1970 at 00:00 UTC.

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

getSpan

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

Returns:
The graduation range.

getTimeZone

public TimeZone getTimeZone()
Returns the timezone for this graduation.

Returns:
The current timezone.

setTimeZone

public void setTimeZone(TimeZone timezone)
Sets the time zone for this graduation. This affect only the way labels are displayed.

Parameters:
timezone - The new timezone.

setUnit

public void setUnit(Unit<?> unit)
             throws IllegalArgumentException
Changes the graduation 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 the specified unit is not a time unit.

getFormat

public DateFormat getFormat()
Returns the format to use for formatting labels. The format really used by TickIterator.currentLabel() may not be the same. For example, some iterators may choose to show or hide hours, minutes and seconds.

Returns:
The labels 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.