edu.neu.ccs
Class XInterval

java.lang.Object
  extended byedu.neu.ccs.XInterval
All Implemented Interfaces:
JPTConstants, Serializable, Stringable, SwingConstants

public class XInterval
extends Object
implements Serializable, Stringable, JPTConstants

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
Version:
2.4.0
See Also:
Serialized Form

Field Summary
private static String[] BLANK
          The data array with blank names "", "".
protected  SwingPropertyChangeSupport changeAdapter
          Helper object for property change API.
protected  double maximum
          Upper endpoint of interval.
private static String[] MAXMIN
          The data array with names "max", "min".
protected  double minimum
          Lower endpoint of interval.
private static String[] MINMAX
          The data array with names "min", "max".
static String standardMessage
          The standard error message for fromStringData.
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
XInterval()
          Constructs an interval with the endpoints set to 0,0.
XInterval(double endpointA, double endpointB)
          Constructs an interval with the given endpoints.
XInterval(String data)
          Constructs an interval from the encoded String data.
XInterval(XInterval interval)
          Constructs an XInterval using the given XInterval.
 
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)
          Defines the data state for this XInterval 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(XInterval interval)
          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 XInterval as an annotated string.
 String toStringData()
          Returns a human readable String representing the data state of this XInterval as a simple string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLANK

private static String[] BLANK
The data array with blank names "", "".


MINMAX

private static String[] MINMAX
The data array with names "min", "max".


MAXMIN

private static String[] MAXMIN
The data array with names "max", "min".


standardMessage

public static final String standardMessage
The standard error message for fromStringData.

See Also:
Constant Field Values

minimum

protected double minimum
Lower endpoint of interval.


maximum

protected double maximum
Upper endpoint of interval.


changeAdapter

protected SwingPropertyChangeSupport changeAdapter
Helper object for property change API.

Constructor Detail

XInterval

public XInterval()
Constructs an interval with the endpoints set to 0,0.


XInterval

public XInterval(XInterval interval)
Constructs an XInterval using the given XInterval.

Parameters:
interval - the interval to be copied

XInterval

public XInterval(double endpointA,
                 double endpointB)

Constructs an interval with the given endpoints.

The order of the endpoints does not matter since the endpoints will be ordered internally.

Parameters:
endpointA - one of the two endpoints
endpointB - the other of the two endpoints

XInterval

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

Parameters:
data - the encoded String data
Method Detail

toString

public String toString()

Returns a human readable String representing the data state of this XInterval as an annotated string.

XInterval[min=...;max=...]

where ... stands for the minimum and maximum of the interval.


toStringData

public String toStringData()

Returns a human readable String representing the data state of this XInterval as a simple string.

[...;...]

where ... stands for the minimum and maximum of the interval.

Specified by:
toStringData in interface Stringable
See Also:
Stringable.fromStringData(String)

fromStringData

public void fromStringData(String data)
                    throws ParseException

Defines the data state for this XInterval object from a String representation of the data state.

Fires property change VALUE.

Specified by:
fromStringData in interface Stringable
Parameters:
data - String representation of the data state
Throws:
ParseException - if the data is malformed
See Also:
Stringable.toStringData()

setEndpoints

public void setEndpoints(double endpointA,
                         double endpointB)

Sets the endpoints for the interval to the given endpoints.

The order of the endpoints does not matter since the endpoints will be ordered internally.

Fires property change VALUE.

Parameters:
endpointA - one of the two endpoints
endpointB - the other of the two endpoints

setInterval

public void setInterval(XInterval interval)

Sets the endpoints for this interval to the endpoints of the given interval.

Does nothing if the given interval is null.

Fires property change VALUE.

Parameters:
interval - the interval to be copied

getMinimum

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


getMaximum

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


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