edu.neu.ccs.gui
Class Interval

java.lang.Object
  |
  +--edu.neu.ccs.gui.Interval
All Implemented Interfaces:
Cloneable, Serializable, Stringable

public class Interval
extends Object
implements Cloneable, Serializable, Stringable

Encapsulates an interval of double precision numbers. The endpoints of the interval may be supplied in any order and will be ordered automatically.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  SwingPropertyChangeSupport changeAdapter
          Helper object for property change API.
protected  double maximum
          Upper endpoint of interval.
protected static String MAXIMUM
          Bound property name for the maximum property.
protected  double midpoint
          The midpoint of the interval.
protected static String MIDPOINT
          Bound property name for the midpoint property.
protected  double minimum
          Lower endpoint of interval.
protected static String MINIMUM
          Bound property name for the minimum property.
protected  double size
          Interval size, equal to the difference between the maximum and minimum endpoints.
protected static String SIZE
          Bound property name for the size property.
 
Constructor Summary
Interval()
          Constructs an interval with all data set to 0.0.
Interval(double endpointA, double endpointB)
          Constructs an interval with the given endpoints.
Interval(String data)
          Constructs an interval from encoded String data.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers the given object to listen for property change events generated by this object.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Registers the given object to listen for property change events generated by this object with the given property name.
 void fromStringData(String data)
          Extracts the data state for this Interval object from a String representation of the data state.
 double getMaximum()
          Returns the upper endpoint of the interval.
 double getMidpoint()
          Returns the midpoint of the interval.
 double getMinimum()
          Returns the lower endpoint of the interval.
 double getSize()
          Returns the size of the interval, that is, the difference between the upper and lower endpoints.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Deregisters the given object from listening for property change events generated by this object.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Deregisters the given object from listening for property change events generated by this object with the given property name.
 void setEndpoints(double endpointA, double endpointB)
          Sets the endpoints for the interval to the given endpoints.
 void setInterval(Interval other)
          Sets the endpoints for this interval to the endpoints of the given interval.
 String toString()
          Returns a human readable String representing the data state of this Interval as: (minimum;maximum).
 String toStringData()
          Returns a String representation of the data state for this Interval object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM

protected static final String MINIMUM
Bound property name for the minimum property.

See Also:
Constant Field Values

MAXIMUM

protected static final String MAXIMUM
Bound property name for the maximum property.

See Also:
Constant Field Values

MIDPOINT

protected static final String MIDPOINT
Bound property name for the midpoint property.

See Also:
Constant Field Values

SIZE

protected static final String SIZE
Bound property name for the size property.

See Also:
Constant Field Values

minimum

protected double minimum
Lower endpoint of interval.


maximum

protected double maximum
Upper endpoint of interval.


size

protected double size
Interval size, equal to the difference between the maximum and minimum endpoints.


midpoint

protected double midpoint
The midpoint of the interval.


changeAdapter

protected SwingPropertyChangeSupport changeAdapter
Helper object for property change API.

Constructor Detail

Interval

public Interval()
Constructs an interval with all data set to 0.0.

See Also:
Interval(double, double), Interval(String)

Interval

public Interval(double endpointA,
                double endpointB)
Constructs an interval with the given endpoints.

Parameters:
endpointA - one of the two endpoints
endpointB - the other of the two endpoints
See Also:
Interval(), Interval(String), setEndpoints(double, double)

Interval

public Interval(String data)
         throws ParseException
Constructs an interval from encoded String data.

Parameters:
data - the encoded String data
See Also:
Interval(), Interval(double, double), toStringData(), fromStringData(String), toString()
Method Detail

toStringData

public String toStringData()
Returns a String representation of the data state for this Interval object.

Specified by:
toStringData in interface Stringable
See Also:
Interval(String), fromStringData(String), toString()

fromStringData

public void fromStringData(String data)
                    throws ParseException
Extracts the data state for this Interval object from a String representation of the data state.

Specified by:
fromStringData in interface Stringable
Parameters:
data - String representation of the desired value
Throws:
ParseException - if the data is malformed
See Also:
Interval(String), toStringData(), toString()

toString

public String toString()
Returns a human readable String representing the data state of this Interval as: (minimum;maximum).

Overrides:
toString in class Object
See Also:
Interval(String), toStringData(), fromStringData(String)

setEndpoints

public void setEndpoints(double endpointA,
                         double endpointB)

Sets the endpoints for the interval to the given endpoints.

Calling this method may result in the firing of one or more PropertyChangeEvents. These events will be fired for property changes in the following order: MINIMUM, MAXIMUM, MIDPOINT, SIZE.

Parameters:
endpointA - one of the two endpoints
endpointB - the other of the two endpoints
See Also:
setInterval(Interval)

setInterval

public void setInterval(Interval other)
Sets the endpoints for this interval to the endpoints of the given interval. If the given interval is null, this method does nothing.

Parameters:
other - the interval to be copied
See Also:
setEndpoints(double, double)

getMinimum

public double getMinimum()
Returns the lower endpoint of the interval.

See Also:
getMaximum()

getMaximum

public double getMaximum()
Returns the upper endpoint of the interval.

See Also:
getMinimum()

getSize

public double getSize()
Returns the size of the interval, that is, the difference between the upper and lower endpoints.


getMidpoint

public double getMidpoint()
Returns the midpoint of the interval.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this object.

Parameters:
listener - the listener to be registered

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Registers the given object to listen for property change events generated by this object with the given property name.

Parameters:
propertyName - the name of the desired property
listener - the listener to be registered

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this object.

Parameters:
listener - the listener to be deregistered

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Deregisters the given object from listening for property change events generated by this object with the given property name.

Parameters:
propertyName - the name of the desired property
listener - the listener to be deregistered