|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.models.RangeCollection
public class RangeCollection
A RangeCollection defines a set of values and colors (a collection of RangeSegments).
Creating a RangeCollection
RangeCollections can be created in the following ways:
// default constructor. Creates a RangeCollection with 3 segments -
// Red, 0-33; Yellow, 33-67; Green, 67-100
RangeCollection range = new RangeCollection();
// specified RangeSegments. Creates a RangeCollection with the
// specified segments.
Rangecollection range = new RangeCollection(RangeSegmentInterface[]);
UsageIf the default segments are not desired, the user can remove them all at once.
// removes all segments
range.removeAllSegments();
Specific segments can also be removed.
// remove the specific RangeSegment object
range.removeSegment( rangeSegment );
// remove the RangeSegment at a specified index
range.removeSegment( index );
Then segments can be added to the collection. See RangeSegment documentation
for more details on creating segments. If contiguous segments are required, then
segments can only be added to the beginning or the end of the collection.
// add the specified segment to the collection.
range.addSegment( segment );
An array of all RangeSegments can be obtained:
// returns all RangeSegments in an array
segmentArray = range.getSegments();
The number of total RangeSegments can also be obtained:
// returns the number of RangeSegments in the collection
int segmentCount = range.getSegmentCount();
Specific RangeSegments can be obtained in the following ways:
// get the segment at a specified index where index
// is an integer value
RangeSegmentInterface segment = range.getSegment( 0 );
// get the segment containing a specified value where
// value is a double
segment = range.getSegment( value );
The RangeCollection can be queried to see which Color is
represented by a specified value.
// get the color represented by a specified value
// where value is a double
Color valueColor = range.getColor( value );
RangeCollections are contiguous by default, but can be
changed to be non-contiguous.
// set the RangeCollection to be non-contiguous
range.setContiguousSegmentsRequired( false );
// find out whether the RangeCollection is contiguous
boolean isContiguous = range.isContiguousSegmentsRequired();
RangeCollectionInterface,
RangeSegment,
RangeSegmentInterface,
Serialized Form| Field Summary | |
|---|---|
protected com.sas.collection.ContentsChangedListenerList |
allContentsChangedListeners
|
protected boolean |
contiguousSegmentsRequired
|
protected int |
pendingEventGateCount
|
static java.lang.String |
RB_KEY
|
protected OrderedCollection |
segments
|
| Constructor Summary | |
|---|---|
RangeCollection()
|
|
RangeCollection(RangeSegmentInterface[] rangeSegments)
|
|
| Method Summary | |
|---|---|
void |
addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Add a listener for the com.sas.util.ContentsChangedEvent event. |
void |
addSegment(RangeSegmentInterface segment)
Add a segment into the rangeCollection. |
java.lang.Object |
clone()
Return a clone of the object. |
java.lang.Object |
clone(com.sas.DeepCloneSupport support,
boolean deeply)
Clone this object using a deep copy. |
void |
contentsChanged(com.sas.collection.ContentsChangedEvent cev)
|
void |
disableEvents()
Ask a collection to suppress delivery of ContentsChangeEvents on subsequent changes to the collection. |
void |
enableEvents()
Undo a disableEvents call. |
protected void |
fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
Send a ContentsChangedEvent event to all the ContentsChangedListener objects in the listener list. |
java.awt.Color |
getColor(double value)
Return the color that represents the given value within the rangeCollection. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
RangeSegmentInterface |
getSegment(double value)
Fetch the segment containing the specified value in the rangeCollection. |
RangeSegmentInterface |
getSegment(int index)
Fetch the segment at the specified index in the rangeCollection. |
int |
getSegmentCount()
Return the number of segments in the rangeCollection. |
java.util.Enumeration |
getSegments()
Gets an array of all the range segments in this collection. |
boolean |
isContiguousSegmentsRequired()
Returns whether contiguous segments are required. |
void |
monitorData(java.lang.Object component,
java.lang.Object value)
Implementations of monitorData() can interrogate the data value and change the presentation style of the data by performing operations on the component. |
void |
removeAllSegments()
Removes all the segments from the rangeCollection. |
void |
removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for the com.sas.util.ContentsChangedEvent event. |
void |
removeSegment(int index)
Remove a segment from the rangeCollection. |
void |
removeSegment(RangeSegmentInterface segment)
Remove a segment from the rangeCollection. |
void |
setContiguousSegmentsRequired(boolean contiguousSegmentsRequired)
Specifies whether contiguous segments are required. |
void |
setDefaultValues()
This method sets the initial property values to their default values. |
| Field Detail |
|---|
public static final java.lang.String RB_KEY
protected OrderedCollection segments
protected int pendingEventGateCount
protected boolean contiguousSegmentsRequired
protected transient com.sas.collection.ContentsChangedListenerList allContentsChangedListeners
| Constructor Detail |
|---|
public RangeCollection()
public RangeCollection(RangeSegmentInterface[] rangeSegments)
| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void setDefaultValues()
ComponentInterfaceNote that the designTime property is not initialized when setDefaultValues is called, so initialization which depends on the value of designTime should take place in initializeComponent.
setDefaultValues in interface ComponentInterfacesetDefaultValues in class ComponentComponentInterface.setDefaultValues()public boolean isContiguousSegmentsRequired()
public void setContiguousSegmentsRequired(boolean contiguousSegmentsRequired)
public int getSegmentCount()
getSegmentCount in interface RangeCollectionInterfacepublic java.util.Enumeration getSegments()
public RangeSegmentInterface getSegment(int index)
getSegment in interface RangeCollectionInterfaceindex - The position of the segment in the rangeCollection.
Indices are zero-based.public RangeSegmentInterface getSegment(double value)
getSegment in interface RangeCollectionInterfacevalue - The value to use to determine which segment contains it.public void addSegment(RangeSegmentInterface segment)
addSegment in interface RangeCollectionInterfacesegment - the segment to add to the rangeCollection. It must implement
the RangeSegmentInterface.public void removeSegment(RangeSegmentInterface segment)
removeSegment in interface RangeCollectionInterfacesegment - the segment to remove from the rangeCollection.public void removeSegment(int index)
removeSegment in interface RangeCollectionInterfaceindex - The index of the segment to remove from the rangeCollection.
The index must be 0 or getSegmentCount()-1.public void removeAllSegments()
removeAllSegments in interface RangeCollectionInterfacepublic java.awt.Color getColor(double value)
getColor in interface RangeCollectionInterfacevalue - The value whose color is desired.
public void contentsChanged(com.sas.collection.ContentsChangedEvent cev)
contentsChanged in interface com.sas.collection.ContentsChangedListenerpublic void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
addContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ContentsChangedEvent events
the listener is not added a second time if it already exists
in the list of listeners for this event.ContentsChangedSourcepublic void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
removeContentsChangedListener in interface com.sas.collection.ContentsChangedSourcelistener - an object which handles ContentsChangedEvent eventsContentsChangedSourceprotected void fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
event - the event to sendpublic void disableEvents()
This call should appear in a try block, with the matching enableEvents method in the finally block.
disableEvents in interface com.sas.util.EventGateInterfacepublic void enableEvents()
This call should always appear in a finally block; the disableEvents calls should be in the try block.
enableEvents in interface com.sas.util.EventGateInterface
public void monitorData(java.lang.Object component,
java.lang.Object value)
DataMonitorInterface
monitorData in interface com.sas.util.datamonitors.DataMonitorInterfacecomponent - The component which is displaying the monitored value.value - The value which is being monitored.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
Component
clone in interface RangeCollectionInterfaceclone in interface com.sas.PublicClonableclone in class Componentjava.lang.CloneNotSupportedException - if the model attached to the component being cloned
will not allow the clone to attach.
public java.lang.Object clone(com.sas.DeepCloneSupport support,
boolean deeply)
throws java.lang.CloneNotSupportedException
DeepClonable
This object and all the range elements it contains
are cloned, preserving the same structure.
support - a required object which keeps track
of cloned objects during the deep cloning.deeply - If true, clone recursively using the deep clone support.
if false, this is equivalent to a normal clone.
java.lang.CloneNotSupportedException
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||