com.jidesoft.range
Class CategoryRange<T>

java.lang.Object
  extended by com.jidesoft.range.AbstractRange<T>
      extended by com.jidesoft.range.CategoryRange<T>
All Implemented Interfaces:
Range<T>, java.lang.Iterable<Category<T>>

public class CategoryRange<T>
extends AbstractRange<T>
implements java.lang.Iterable<Category<T>>

Note that this class is iterable so you can use it in an advanced for.. loop

Author:
Simon White (swhite@catalysoft.com)

Field Summary
 
Fields inherited from interface com.jidesoft.range.Range
PROPERTY_MAX, PROPERTY_MIN
 
Constructor Summary
CategoryRange()
           
CategoryRange(java.util.Set<T> values)
          Create a CategoryRange from a set of values.
CategoryRange(T... values)
          Create a CategoryRange from the supplied values
 
Method Summary
 CategoryRange<T> add(Category<T> c)
          This method fires a propety change event, but to avoid cloning a list for efficiency, the old value is always null
 void adjust(T lower, T upper)
          Adjusts the range.
 boolean contains(Category<T> value)
          Determines whether the category range contains the specified category value
 boolean contains(T x)
          Determines whether the category range contains the supplied possible value
 java.util.List<Category<T>> getCategoryValues()
           
 java.util.List<T> getPossibleValues()
           
 java.util.Iterator<Category<T>> iterator()
           
 T lower()
           
 double maximum()
          This may be the numeric representation of upper() or it may be rounded up.
 double minimum()
          This may be the numeric representation of lower() or it may be rounded down.
 int position(T value)
           
 double size()
          Compute the size of the range
 T upper()
           
 
Methods inherited from class com.jidesoft.range.AbstractRange
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CategoryRange

public CategoryRange()

CategoryRange

public CategoryRange(T... values)
Create a CategoryRange from the supplied values

Parameters:
values - the values.

CategoryRange

public CategoryRange(java.util.Set<T> values)
Create a CategoryRange from a set of values. Note that internally, a list is created out of the set so that the class can reliably determine an upper() and a lower() value.

Parameters:
values - - the set of possible values
Method Detail

getPossibleValues

public java.util.List<T> getPossibleValues()

add

public CategoryRange<T> add(Category<T> c)
This method fires a propety change event, but to avoid cloning a list for efficiency, the old value is always null

Parameters:
c - the category to add
Returns:
this range

lower

public T lower()
Specified by:
lower in interface Range<T>
Returns:
the smallest value of the range

upper

public T upper()
Specified by:
upper in interface Range<T>
Returns:
the largest value of the range

adjust

public void adjust(T lower,
                   T upper)
Description copied from interface: Range
Adjusts the range.

Specified by:
adjust in interface Range<T>
Parameters:
lower - the new smallest value of the range
upper - the new largest value of the range

maximum

public double maximum()
Description copied from interface: Range
This may be the numeric representation of upper() or it may be rounded up.

Specified by:
maximum in interface Range<T>
Returns:
the maximum value for the axis in the range
See Also:
Range.maximum()

minimum

public double minimum()
Description copied from interface: Range
This may be the numeric representation of lower() or it may be rounded down.

Specified by:
minimum in interface Range<T>
Returns:
the minimum value for the axis in the range
See Also:
Range.minimum()

size

public double size()
Description copied from interface: Range
Compute the size of the range

Specified by:
size in interface Range<T>
Returns:
the size of the range
See Also:
Range.size()

position

public int position(T value)

contains

public boolean contains(T x)
Determines whether the category range contains the supplied possible value

Specified by:
contains in interface Range<T>
Returns:
a boolean to indicate whether the supplied point lies within the range

contains

public boolean contains(Category<T> value)
Determines whether the category range contains the specified category value

Parameters:
value - the category value.
Returns:
true if the range contains the specified value. Otherwise false.

iterator

public java.util.Iterator<Category<T>> iterator()
Specified by:
iterator in interface java.lang.Iterable<Category<T>>

getCategoryValues

public java.util.List<Category<T>> getCategoryValues()


Copyright © 2009. All Rights Reserved.