org.geotools.axis
Class AbstractGraduation

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

public abstract class AbstractGraduation
extends Object
implements Graduation, Serializable

Base class for graduation.

Since:
2.0
Author:
Martin Desruisseaux (PMO, IRD)
See Also:
Serialized Form
Module:

Field Summary
protected  PropertyChangeSupport listenerList
          A list of event listeners for this component.
 
Fields inherited from interface Graduation
AXIS_TITLE_FONT, TICK_LABEL_FONT, VISUAL_AXIS_LENGTH, VISUAL_TICK_SPACING
 
Constructor Summary
AbstractGraduation(Unit<?> unit)
          Constructs a graduation with the supplied units.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 boolean equals(Object object)
          Compares this graduation with the specified object for equality.
 Locale getLocale()
          Returns the locale to use for formatting labels.
 String getTitle(boolean includeSymbol)
          Returns the axis title.
 Unit<?> getUnit()
          Returns the graduation's units, or null if unknow.
 int hashCode()
          Returns a hash value for this graduation.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void setLocale(Locale locale)
          Sets the locale to use for formatting labels.
abstract  boolean setMaximum(double value)
          Sets the maximum value for this graduation.
abstract  boolean setMinimum(double value)
          Sets the minimum value for this graduation.
 void setTitle(String title)
          Sets the axis title, not including unit symbol.
 void setUnit(Unit<?> unit)
          Changes the graduation's units.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Graduation
getFormat, getMaximum, getMinimum, getRange, getTickIterator
 

Field Detail

listenerList

protected final PropertyChangeSupport listenerList
A list of event listeners for this component.

Constructor Detail

AbstractGraduation

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

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

setMinimum

public abstract 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 equals to the minimum.

Parameters:
value - The new minimum in 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:
Graduation.getMinimum(), setMaximum(double)

setMaximum

public abstract 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 equals to the maximum.

Parameters:
value - The new maximum in 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:
Graduation.getMaximum(), setMinimum(double)

getTitle

public String getTitle(boolean includeSymbol)
Returns the axis title. If includeUnits is true, then the returned string will includes units as in "Temperature (°C)". The exact formatting is local-dependent.

Specified by:
getTitle in interface Graduation
Parameters:
includeSymbol - true to format unit symbol after the name.
Returns:
The graduation name (also to be use as axis title).

setTitle

public void setTitle(String title)
Sets the axis title, not including unit symbol. This method will fire a property change event with the "title" property name.

Parameters:
title - New axis title, or null to remove any previous setting.

getUnit

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

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

setUnit

public void setUnit(Unit<?> unit)
             throws ConversionException
Changes the graduation's units. Subclasses will automatically convert minimum and maximum values from the old units to the new one. This method fires a property change event with the "unit" property name.

Parameters:
unit - The new units, or null if unknow. If null, minimum and maximum values are not converted.
Throws:
ConversionException - if units are not convertible, or if the specified units is illegal for this graduation.

getLocale

public Locale getLocale()
Returns the locale to use for formatting labels.

Specified by:
getLocale in interface Graduation
Returns:
The locale for formatting title and labels.

setLocale

public void setLocale(Locale locale)
Sets the locale to use for formatting labels. This will fire a property change event with the "locale" property name.

Parameters:
locale - The new labels format.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties. A PropertyChangeEvent will get fired in response to setting a property, such as setTitle(java.lang.String) or setLocale(java.util.Locale).

Specified by:
addPropertyChangeListener in interface Graduation
Parameters:
listener - The listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list.

Specified by:
removePropertyChangeListener in interface Graduation
Parameters:
listener - The listener to remove.

equals

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

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

hashCode

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

Overrides:
hashCode in class Object


Copyright © 1996-2009 Geotools. All Rights Reserved.