Package info.monitorenter.gui.util
Class ColorIterator
- java.lang.Object
-
- info.monitorenter.gui.util.ColorIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.awt.Color>
public class ColorIterator extends java.lang.Object implements java.util.Iterator<java.awt.Color>
Iterator of the color space.- Version:
- $Revision: 1.10 $
- Author:
- Achim Westermann
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColorIterator.ADefaultStepping
Just for protected internal float stepping.static class
ColorIterator.AlphaStepper
A stepping model that steps on the alpha channel of the HSB color space.static class
ColorIterator.APiggyBackStepper
Base class for stepping models that may step in each direction of the Hue Saturation Luminance color space.static class
ColorIterator.HSBStepper
Performs hue steps until it has walked the whole hue line, then performs a saturation step to start with hue steps again.static class
ColorIterator.HSStepper
Performs hue steps until it has walked the whole hue line, then performs a saturation step to start with hue steps again.static class
ColorIterator.HueStepper
A stepper that walks along the hue line of the color space.static interface
ColorIterator.ISteppingModel
Defines the strategy of walking through the HSB color space.static class
ColorIterator.LuminanceStepper
A stepping model that steps on the luminance line of the HSB color space.static class
ColorIterator.SaturationStepper
A stepping model that steps on the saturation line of the HSB color space.
-
Field Summary
Fields Modifier and Type Field Description protected HSBColor
m_iterate
Reference to the currently iterated color.protected HSBColor
m_startColor
The starting color which is also used to detect if a whole iteration has been performed.
-
Constructor Summary
Constructors Constructor Description ColorIterator()
Creates an instance that starts with a red color and walks the hue line with aColorIterator.HueStepper
.ColorIterator(java.awt.Color startColor, ColorIterator.ISteppingModel stepper)
Creates an instance that starts with the given color and uses the given stepper for iteration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.awt.Color
getStartColor()
Returns the starting color which is also used to detect if a whole iteration has been performed.int
hashCode()
boolean
hasNext()
Returns true if more colors are available.boolean
isAscendingDirection()
Returns the ascendingDirection.static void
main(java.lang.String[] args)
Main entry for a test application.java.awt.Color
next()
Returns instances of java.awt.Color or throws a NoSuchElementException, if iterator has finished.void
remove()
Nothing is done here.void
reset()
Resets the ColorIterator.void
setAscendingDirection(boolean ascendingDirection)
Sets whether the color space should be iterated in ascending direction (+ operations) or descending direction(- operations).void
setStartColor(java.awt.Color startColor)
Sets the starting color which is also used to detect if a whole iteration has been performed.void
setSteps(int steps)
Sets the amount of colors to iterate over.
-
-
-
Constructor Detail
-
ColorIterator
public ColorIterator()
Creates an instance that starts with a red color and walks the hue line with aColorIterator.HueStepper
.
-
ColorIterator
public ColorIterator(java.awt.Color startColor, ColorIterator.ISteppingModel stepper)
Creates an instance that starts with the given color and uses the given stepper for iteration.- Parameters:
startColor
- the color to start the iteration with.stepper
- the stepping model to use.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Main entry for a test application.- Parameters:
args
- ignored.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getStartColor
public final java.awt.Color getStartColor()
Returns the starting color which is also used to detect if a whole iteration has been performed.- Returns:
- the starting color which is also used to detect if a whole iteration has been performed.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
hasNext
public boolean hasNext()
Returns true if more colors are available.- Specified by:
hasNext
in interfacejava.util.Iterator<java.awt.Color>
- Returns:
- true if more colors are available.
- See Also:
Iterator.hasNext()
-
isAscendingDirection
public final boolean isAscendingDirection()
Returns the ascendingDirection.- Returns:
- the ascendingDirection
- See Also:
setAscendingDirection(boolean)
-
next
public java.awt.Color next() throws java.util.NoSuchElementException
Returns instances of java.awt.Color or throws a NoSuchElementException, if iterator has finished.- Specified by:
next
in interfacejava.util.Iterator<java.awt.Color>
- Returns:
- the next available Color.
- Throws:
java.util.NoSuchElementException
- ifhasNext()
returns false.
-
remove
public void remove()
Nothing is done here. Do you really want to remove a color from the color circle model?- Specified by:
remove
in interfacejava.util.Iterator<java.awt.Color>
-
reset
public void reset()
Resets the ColorIterator. It will be able to start a new iteration over the color space.
-
setAscendingDirection
public final void setAscendingDirection(boolean ascendingDirection)
Sets whether the color space should be iterated in ascending direction (+ operations) or descending direction(- operations).- Parameters:
ascendingDirection
- if true the color space will be iterated in ascending direction.
-
setStartColor
public final void setStartColor(java.awt.Color startColor)
Sets the starting color which is also used to detect if a whole iteration has been performed.- Parameters:
startColor
- the starting color which is also used to detect if a whole iteration has been performed.
-
setSteps
public void setSteps(int steps)
Sets the amount of colors to iterate over.- Parameters:
steps
- the amount of steps to take in the color space.
-
-