All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.models
Class RangeCollection

    com.sas.models.RangeCollection

All Implemented Interfaces:
  com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.collection.ContentsChangedListener, com.sas.collection.ContentsChangedSource, ComponentInterface, LinkPropertiesInterface, ModelInterface, RangeCollectionInterface, com.sas.PublicClonable, com.sas.util.datamonitors.DataMonitorInterface, com.sas.util.EventGateInterface, ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

    public class RangeCollection

implements RangeCollectionInterface, com.sas.util.datamonitors.DataMonitorInterface, com.sas.collection.ContentsChangedListener, com.sas.collection.ContentsChangedSource, com.sas.util.EventGateInterface, java.io.Serializable

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[]);

Usage

If 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();

See Also:
  `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.

Methods inherited from class com.sas.Component
`addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject`

Field Detail

### RB_KEY

    public static final java.lang.String RB_KEY

See Also:
  Constant Field Values

### segments

    protected OrderedCollection segments

### pendingEventGateCount

    protected int pendingEventGateCount

### contiguousSegmentsRequired

    protected boolean contiguousSegmentsRequired

### allContentsChangedListeners

    protected transient com.sas.collection.ContentsChangedListenerList allContentsChangedListeners

Constructor Detail

### RangeCollection

    public RangeCollection()

### RangeCollection

    public RangeCollection(RangeSegmentInterface[] rangeSegments)

Method Detail

### getExtendedBeanInfo

    public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

### setDefaultValues

    public void setDefaultValues()

  Description copied from interface: `ComponentInterface`
  This method sets the initial property values to their default values. It is called by initializeComponent. Subclasses of the Component class or classes that implement the ComponentInterface should override setDefaultValues to perform their initialization.

  Note 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.

  Specified by:
    `setDefaultValues` in interface `ComponentInterface`
  Overrides:
    `setDefaultValues` in class `Component`
  See Also:
    `ComponentInterface.setDefaultValues()`

### isContiguousSegmentsRequired

    public boolean isContiguousSegmentsRequired()

  Returns whether contiguous segments are required. By default, they are required.

### setContiguousSegmentsRequired

    public void setContiguousSegmentsRequired(boolean contiguousSegmentsRequired)

  Specifies whether contiguous segments are required. By default, they are required. If they are required, the closest range will be found. Otherwise, getSegment and getColor will return null for values that don't fall within a segment.

### getSegmentCount

    public int getSegmentCount()

  Return the number of segments in the rangeCollection.

  Specified by:
    `getSegmentCount` in interface `RangeCollectionInterface`
  Returns:
    int The number of segments in the rangeCollection.

### getSegments

    public java.util.Enumeration getSegments()

  Gets an array of all the range segments in this collection.

  Returns:
    an array of rangesegmentInterface elements in this collection

### getSegment

    public RangeSegmentInterface getSegment(int index)

  Fetch the segment at the specified index in the rangeCollection.

  Specified by:
    `getSegment` in interface `RangeCollectionInterface`
  Parameters:
    `index` - The position of the segment in the rangeCollection. Indices are zero-based.

### getSegment

    public RangeSegmentInterface getSegment(double value)

  Fetch the segment containing the specified value in the rangeCollection. The closest segment will be returned if contiguous segments are required, otherwise null will be returned if the value does not fall within a segment.

  Specified by:
    `getSegment` in interface `RangeCollectionInterface`
  Parameters:
    `value` - The value to use to determine which segment contains it.

### addSegment

    public void addSegment(RangeSegmentInterface segment)

  Add a segment into the rangeCollection. If contiguous segments are required, the segment can only be added at the beginning or the end of the rangeCollection and the position of the segment is determined by its min and max values. If contiguous segments are not required, the segment is added to the end of the rangeCollection.

  Specified by:
    `addSegment` in interface `RangeCollectionInterface`
  Parameters:
    `segment` - the segment to add to the rangeCollection. It must implement the RangeSegmentInterface.

### removeSegment

    public void removeSegment(RangeSegmentInterface segment)

  Remove a segment from the rangeCollection. If contiguous segments are required, a segment can only be removed from the beginning or the end of the rangeCollection. If contiguous segments are not required, random segments can be removed from the rangeCollection.

  Specified by:
    `removeSegment` in interface `RangeCollectionInterface`
  Parameters:
    `segment` - the segment to remove from the rangeCollection.

### removeSegment

    public void removeSegment(int index)

  Remove a segment from the rangeCollection. If contiguous segments are required, a segment can only be removed from the beginning or the end of the rangeCollection. If contiguous segments are not required, random segments can be removed from the rangeCollection.

  Specified by:
    `removeSegment` in interface `RangeCollectionInterface`
  Parameters:
    `index` - The index of the segment to remove from the rangeCollection. The index must be 0 or getSegmentCount()-1.

### removeAllSegments

    public void removeAllSegments()

  Removes all the segments from the rangeCollection.

  Specified by:
    `removeAllSegments` in interface `RangeCollectionInterface`

### getColor

    public java.awt.Color getColor(double value)

  Return the color that represents the given value within the rangeCollection. The closest segment's color will be returned if contiguous segments are required, otherwise null will be returned if the value does not fall within a segment.

  Specified by:
    `getColor` in interface `RangeCollectionInterface`
  Parameters:
    `value` - The value whose color is desired.
  Returns:
    Color The color representing the specified value.

### contentsChanged

    public void contentsChanged(com.sas.collection.ContentsChangedEvent cev)

  Specified by:
    `contentsChanged` in interface `com.sas.collection.ContentsChangedListener`

### addContentsChangedListener

    public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)

  Add a listener for the com.sas.util.ContentsChangedEvent event.

  Specified by:
    `addContentsChangedListener` in interface `com.sas.collection.ContentsChangedSource`
  Parameters:
    `listener` - 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.
  See Also:
    `ContentsChangedSource`

### removeContentsChangedListener

    public void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)

  Remove a listener for the com.sas.util.ContentsChangedEvent event. Nothing happens if the listener is not in the list of listeners for this event.

  Specified by:
    `removeContentsChangedListener` in interface `com.sas.collection.ContentsChangedSource`
  Parameters:
    `listener` - an object which handles ContentsChangedEvent events
  See Also:
    `ContentsChangedSource`

### fireContentsChanged

    protected void fireContentsChanged(com.sas.collection.ContentsChangedEvent event)

  Send a ContentsChangedEvent event to all the ContentsChangedListener objects in the listener list. The listener list is copied first, so the event is sent only to each item which is in the list at the time of this copy, even if adds or removes are performed after the send has started.

  Parameters:
    `event` - the event to send

### disableEvents

    public void disableEvents()

  Ask a collection to suppress delivery of ContentsChangeEvents on subsequent changes to the collection.

  This call should appear in a try block, with the matching enableEvents method in the finally block.

  Specified by:
    `disableEvents` in interface `com.sas.util.EventGateInterface`

### enableEvents

    public void enableEvents()

  Undo a disableEvents call. This may or may not cause the collection to start sending events again. If there are no other pending suppress/allow gates on the collection, the collection will send a single ContentsChangedEvent and then subsequent changes to the collection will also fire ContentsChangedEvents.

  This call should always appear in a finally block; the disableEvents calls should be in the try block.

  Specified by:
    `enableEvents` in interface `com.sas.util.EventGateInterface`

### monitorData

    public void monitorData(java.lang.Object component,
                            java.lang.Object value)

  Description copied from interface: `DataMonitorInterface`
  Implementations of monitorData() can interrogate the data value and change the presentation style of the data by performing operations on the component.

  Specified by:
    `monitorData` in interface `com.sas.util.datamonitors.DataMonitorInterface`
  Parameters:
    `component` - The component which is displaying the monitored value.
    `value` - The value which is being monitored.

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Description copied from class: `Component`
  Return a clone of the object.

  Specified by:
    `clone` in interface `RangeCollectionInterface`
  Specified by:
    `clone` in interface `com.sas.PublicClonable`
  Overrides:
    `clone` in class `Component`
  Returns:
    a clone of the object.
  Throws:
    `java.lang.CloneNotSupportedException` - if the model attached to the component being cloned will not allow the clone to attach.

### clone

    public java.lang.Object clone(com.sas.DeepCloneSupport support,
                                  boolean deeply)
                           throws java.lang.CloneNotSupportedException

  Clone this object using a deep copy. With this method, this class implements `DeepClonable` This object and all the range elements it contains are cloned, preserving the same structure.

  Parameters:
    `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.
  Throws:
    `java.lang.CloneNotSupportedException`

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.