Class ColorMutable
Color
implementation.
The color is wrapped by the logic to fake mutability. As long as the color is not set setting of values will not have an effect but only be stored until color is set and then applied to it.
- Author:
- Achim Westermann
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the color to the graphics context if it is different and returns the previous one of the graphics context or null if there was no change.Sets the color to the graphics context.boolean
int
getAlpha()
Returns the alpha value of the wrapped color.int
getBlue()
Returns the blue value of the wrapped color.getColor()
Returns the wrapped color.int
getGreen()
Returns the green value of the wrapped color.int
getRed()
Returns the red value of the wrapped color.int
hashCode()
int
setAlpha
(int alpha) Sets the transparency to use for painting.int
setBlue
(int blue) Sets the blue to use for painting.Sets the color to use.int
setGreen
(int green) Sets the green to use for painting.int
setRed
(int red) Sets the red to use for painting.
-
Constructor Details
-
ColorMutable
public ColorMutable()
-
-
Method Details
-
applyColorIfChange
Sets the color to the graphics context if it is different and returns the previous one of the graphics context or null if there was no change.- Parameters:
g
- the graphics context to use.- Returns:
- the previously configured color of the graphics context or null if nothing was done.
-
applyColorUnconditionally
Sets the color to the graphics context.- Parameters:
g
- the graphics context to use.- Returns:
- the previously configured color of the graphics context or null if nothing was done.
-
equals
-
getAlpha
public int getAlpha()Returns the alpha value of the wrapped color.- Returns:
- the alpha value of the wrapped color.
-
getBlue
public int getBlue()Returns the blue value of the wrapped color.- Returns:
- the blue value of the wrapped color.
-
getColor
Returns the wrapped color.This will be
null
if no color has been set before even if other values have been set before.- Returns:
- the wrapped color.
-
getGreen
public int getGreen()Returns the green value of the wrapped color.- Returns:
- the green value of the wrapped color.
-
getRed
public int getRed()Returns the red value of the wrapped color.- Returns:
- the red value of the wrapped color.
-
hashCode
public int hashCode() -
setAlpha
public int setAlpha(int alpha) Sets the transparency to use for painting.This value will be fold into color. If color has not been configured before it will not have any effect (until a color is set).
Caution: using a value greater 0 may cost a multiple cpu load!
- Parameters:
alpha
- a transparency value between 0 and 255.- Returns:
- the previous transparency used.
-
setBlue
public int setBlue(int blue) Sets the blue to use for painting.This value will be fold into color. If color has not been configured before it will not have any effect (until a color is set).
- Parameters:
blue
- a blue value between 0 and 255.- Returns:
- the previous blue used.
-
setColor
Sets the color to use.If any other setters have been invoked before (e.g.
) and the internal color was null those values will be implanted to the new color before overtaking it.setAlpha(int)
- Parameters:
color
- the new color to use as base for modifications.- Returns:
- the previous color or null if none was set.
-
setGreen
public int setGreen(int green) Sets the green to use for painting.This value will be fold into color. If color has not been configured before it will not have any effect (until a color is set).
- Parameters:
green
- a green value between 0 and 255.- Returns:
- the previous green used.
-
setRed
public int setRed(int red) Sets the red to use for painting.This value will be fold into color. If color has not been configured before it will not have any effect (until a color is set).
- Parameters:
red
- a red value between 0 and 255.- Returns:
- the previous red used.
-