public class IlvBlinkingColor extends Color implements IlvBlinkingDrawingResource
IlvGraphic
support blinking colors.
Limitation: For technical reasons, the "on" and "off" durations are limited from 1 to max integer (not max long). It is recommended to use the same durations whenever possible for all objects, and to choose the durations not too small (e.g. not smaller than 100 ms), because otherwise the performance of the system will degrade dramatically.
Hashing (tables or maps) of a mixture of blinking colors and normal
colors don't work, since the fully transparent white color claims to
be equal to any blinking color (i.e.
transparentWhite.equals(blinkingColor)
returns
true
).
However, this is no problem if the fully transparent color
Color(255,255,255,0)
never occurs.
black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOW
BITMASK, OPAQUE, TRANSLUCENT
Constructor and Description |
---|
IlvBlinkingColor(Color onColor,
Color offColor)
Creates a new blinking color.
|
IlvBlinkingColor(Color onColor,
Color offColor,
long onPeriod,
long offPeriod)
Creates a new blinking color.
|
Modifier and Type | Method and Description |
---|---|
PaintContext |
createContext(ColorModel cm,
Rectangle r,
Rectangle2D r2d,
AffineTransform xform,
RenderingHints hints)
Creates and returns a
PaintContext . |
boolean |
equals(Object obj)
Determines whether another object is equal to this
IlvBlinkingColor . |
Color |
getCurrentColor()
Returns current color.
|
Color |
getOffColor()
Returns the color of the "off" period.
|
long |
getOffPeriod()
Returns the duration, in milliseconds, of the "off" period.
|
Color |
getOnColor()
Returns the color of the "on" period.
|
long |
getOnPeriod()
Returns the duration, in milliseconds, of the "on" period.
|
int |
getRGB()
Returns the RGB value representing the color in the default sRGB
ColorModel . |
int |
getTransparency()
Returns the transparency mode for this
Color . |
int |
hashCode()
Returns the hash code of this object.
|
boolean |
isOn()
Returns
true if this color displays like the "on" state,
and false if this color displays like the "off" state. |
void |
notifyUsed(IlvBlinkingObject obj,
boolean used)
Called by
IlvGraphic if this color is used. |
void |
setOn(boolean flag)
Sets whether this color displays like the "on" or "off" state.
|
void |
setTemporarilyDisabled(boolean flag)
Temporarily disable the blinking.
|
String |
toString()
Returns a string representation of the object.
|
brighter, darker, decode, getAlpha, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGBColorComponents, getRGBComponents, HSBtoRGB, RGBtoHSB
public IlvBlinkingColor(Color onColor, Color offColor)
onColor
- Color used during the "on" periodoffColor
- Color used during the "off" periodpublic IlvBlinkingColor(Color onColor, Color offColor, long onPeriod, long offPeriod)
onColor
- Color used during the "on" periodoffColor
- Color used during the "off" periodonPeriod
- Duration, in milliseconds, of the "on" periodoffPeriod
- Duration, in milliseconds, of the "off" periodpublic boolean equals(Object obj)
IlvBlinkingColor
.public int hashCode()
public PaintContext createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints)
PaintContext
.
If the current state is on, it returns a context representing the "on
color", otherwise the "off color".createContext
in interface Paint
createContext
in class Color
cm
- the specified ColorModel
r
- the specified Rectangle
r2d
- the specified Rectangle2D
xform
- the specified AffineTransform
hints
- the specified RenderingHints
PaintContext
that is used to generate a
solid color pattern.Color.createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints)
,
Paint
,
PaintContext
,
getOnColor()
,
getOffColor()
public int getTransparency()
Color
.
If the current state is on, it returns a transparency of the "on
color", otherwise of the "off color".getTransparency
in interface Transparency
getTransparency
in class Color
Color
object's transparency mode.Paint
,
Transparency
,
getOnColor()
,
getOffColor()
public int getRGB()
ColorModel
.
(Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are
blue).public Color getCurrentColor()
public Color getOnColor()
public Color getOffColor()
public long getOnPeriod()
getOnPeriod
in interface IlvBlinkingDrawingResource
public long getOffPeriod()
getOffPeriod
in interface IlvBlinkingDrawingResource
public void setOn(boolean flag)
setOn
in interface IlvBlinkingDrawingResource
flag
- true
means it displays like the "on" statepublic boolean isOn()
true
if this color displays like the "on" state,
and false
if this color displays like the "off" state.isOn
in interface IlvBlinkingDrawingResource
public void setTemporarilyDisabled(boolean flag)
setTemporarilyDisabled
in interface IlvBlinkingDrawingResource
flag
- true
if temporarily disabled.public void notifyUsed(IlvBlinkingObject obj, boolean used)
IlvGraphic
if this color is used.
You should not call this method.notifyUsed
in interface IlvBlinkingDrawingResource
obj
- The blinking object.used
- Whether the color is used.© Copyright Rogue Wave Software, Inc. 1997, 2017. All Rights Reserved.