edu.jhu.tmaj.beans.masks.color
Class CircleRange

java.lang.Object
  extended by edu.jhu.tmaj.beans.masks.color.CircleRange
All Implemented Interfaces:
java.io.Serializable

public final class CircleRange
extends java.lang.Object
implements java.io.Serializable

Represents a range on a circle. This is similar to a linear, straight line, numerical range like 10 - 50, except for one thing, a circular range can "wrap" around 0. So for example, if the maxValue is 255, a circular range might go from 220 to 5. So, values 220-255 and values 0 - 5 would be included in the range. Everything from 6 to 219 would be excluded. The range has 2 end points, which are represented by a start angle and a end angle. -- Adding Points -- The user adds points on this circle, and this class tries to keep the range as small as possible. So if the circle ranges from points 0 to 255, and the current range is from 10 to 20, and the user adds point 8, the new range will be from 8 to 20. If the user were to add point 25 instead of 8, the new range would be from 10 to 25. The range will "wrap" around 0. For example, if the current range is 0 to 10, and a user adds 253, the new range will be 253 - 10. This is why we represent the range as a circle. -- Resets -- The range will generally start off as being called "reset". A reset range by definition contains nothing. The values returned for a reset range will be 0 to 0. However, that does not mean the user can't set this class to actually represent the range 0 to 0. (That range would only include the value 0.) So, a reset range will always have the values 0 to 0 (and not include 0, or any other number.). A 0 to 0 range, however, may actually be reset or not-reset. If if weren't reset, it WOULD include the number 0.

See Also:
Serialized Form

Field Summary
static int RESET_MAX_VALUE
           
static int RESET_MIN_VALUE
           
 
Method Summary
 boolean containsPosition(int position)
          Returns true if the current range contains the given position.
 void ensureRangeContains(int position)
          Ensures that the given position is in current given range; if necessary, the range is expanded.
static CircleRange getDefinedRange(int startValue, int endValue)
           
 int getEndPosition()
          Gets the position of where the range ends.
static CircleRange getResetRange()
           
 int getStartPosition()
          Gets the position of where the range starts.
 boolean isReset()
           
 boolean isWrapping()
          Returns true if the range "wraps" around 0.
static void main(java.lang.String[] args)
          Performs a test of this class.
 void reset()
          Resets this range so that no numbers are included.
 void setRange(CircleRange circleRange)
           
 void setRange(int startPosition, int endPosition)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESET_MIN_VALUE

public static final int RESET_MIN_VALUE
See Also:
Constant Field Values

RESET_MAX_VALUE

public static final int RESET_MAX_VALUE
See Also:
Constant Field Values
Method Detail

main

public static void main(java.lang.String[] args)
Performs a test of this class.


getResetRange

public static CircleRange getResetRange()

getDefinedRange

public static CircleRange getDefinedRange(int startValue,
                                          int endValue)

ensureRangeContains

public void ensureRangeContains(int position)
Ensures that the given position is in current given range; if necessary, the range is expanded.


reset

public void reset()
Resets this range so that no numbers are included.


isReset

public boolean isReset()

setRange

public void setRange(int startPosition,
                     int endPosition)

setRange

public void setRange(CircleRange circleRange)

getStartPosition

public int getStartPosition()
Gets the position of where the range starts.


getEndPosition

public int getEndPosition()
Gets the position of where the range ends.


containsPosition

public boolean containsPosition(int position)
Returns true if the current range contains the given position.


isWrapping

public boolean isWrapping()
Returns true if the range "wraps" around 0.


toString

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