com.sas.graphics.components
Class ColorPosition

com.sas.graphics.components.ColorPosition

public class ColorPosition

The ColorPosition class supports an association between a color and a position to facilitate defining a color spectrum.

Although the usage of this class may evolve and could vary later, the origin intent of this class is to support the specification of a color spectrum in the DataElementStyles. Each ColorPosition object defines a color inflection point along the color spectrum defined along a normalized range of 0 to 1 (inclusive). This class is immutable.

Since:
SAS 9.1.4

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
ColorPosition(java.awt.Color newActiveColor, java.awt.Color newColor, double newPosition)
          Deprecated. scheduled for deletion
ColorPosition(java.awt.Color newColor, double newPosition)
          Constructs a ColorPosition object from the specified color double value pair for use in defining a color inflection point in a color spectrum.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determines whether another object is equal to this ColorPosition.
 java.awt.Color getColor()
          Returns the color portion of this inflection point.
 double getPosition()
          Returns the position of this color inflection point.
static ColorPosition[] newContinuousColorRange(java.awt.Color[] colors, double[] positions)
          Convenience method for constructing a color position array suitable for defining color ranges.
static ColorPosition[] newContinuousColorRange(double from, double to, double by, java.awt.Color[] colorArray)
           
 java.lang.String toString()
           
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

ColorPosition

public ColorPosition(java.awt.Color newColor,
                     double newPosition)
Constructs a ColorPosition object from the specified color double value pair for use in defining a color inflection point in a color spectrum. See the colorSpectrum property in the DataElementStyles class.

The color value must be non null. The position must be a real number (Double.NaN or infinities are not allowed)

Parameters:
newColor - the color of this inflection point in the color spectrum
newPosition - the position of this inflection point along the color spectrum range
Throws:
java.lang.IllegalArgumentException - is thrown if color is null.
java.lang.IllegalArgumentException - is thrown if position is a Double.NaN or Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY
java.lang.IllegalArgumentException - is thrown if position is outside the 0.0 to 1.0 range.

ColorPosition

public ColorPosition(java.awt.Color newActiveColor,
                     java.awt.Color newColor,
                     double newPosition)
Deprecated. scheduled for deletion

Constructs a ColorPosition object from the specified color double value pair for use in defining a color inflection point in a color spectrum. See the colorSpectrum property in the DataElementStyles class.

The color value must be non null. The position must be a real number (Double.NaN or infinities are not allowed)

Parameters:
newColor - the color of this inflection point in the color spectrum
newPosition - the position of this inflection point along the color spectrum range
Throws:
java.lang.IllegalArgumentException - is thrown if color is null.
java.lang.IllegalArgumentException - is thrown if position is a Double.NaN or Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY
java.lang.IllegalArgumentException - is thrown if position is outside the 0.0 to 1.0 range.
Method Detail

newContinuousColorRange

public static ColorPosition[] newContinuousColorRange(java.awt.Color[] colors,
                                                      double[] positions)
Convenience method for constructing a color position array suitable for defining color ranges. Color ranges are defined as solid color intervals broken across a contiguous data range. For example: The results of a test score could be colored as follows {0-60 is red, 60-70 is gray, 70-80 is a light green, 80-90 is a medium green, 90-100 is a dark green}.
The size the resulting ColorPositions array will be the lesser of: the length of the positions array or the size of the color array +1.

Throws:
java.lang.IllegalArgumentException - is thrown if colors is null.
java.lang.IllegalArgumentException - is thrown if length of the colors array is 0.
java.lang.IllegalArgumentException - is thrown if a null entry is encountered in the colors array.
java.lang.IllegalArgumentException - is thrown if positions is null.
java.lang.IllegalArgumentException - is thrown if length of the positions array is less than 2.
java.lang.IllegalArgumentException - is thrown if a Double.NaN or infinity entry is encountered in the positions array.
java.lang.IllegalArgumentException - is thrown if the positions array is not in ascending order.
java.lang.IllegalArgumentException - is thrown if the positions array contains duplicate values.

newContinuousColorRange

public static ColorPosition[] newContinuousColorRange(double from,
                                                      double to,
                                                      double by,
                                                      java.awt.Color[] colorArray)

getColor

public java.awt.Color getColor()
Returns the color portion of this inflection point.

Returns:
the color at this position.

getPosition

public double getPosition()
Returns the position of this color inflection point.

Returns:
position of the color.

equals

public boolean equals(java.lang.Object obj)
Determines whether another object is equal to this ColorPosition.

The result is true if and only if the argument is not null and is a ColorPosition object that has the same property values as this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test for equality with this ColorPosition
Returns:
true if the objects are the same; false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object



Copyright © 2009 SAS Institute Inc. All Rights Reserved.