Class Color
java.lang.Object
ch.nolix.system.element.base.AbstractElement
ch.nolix.system.graphic.color.Color
A
Color is not mutable.- Author:
- Silvan Wyss
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final shortstatic final longstatic final shortstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorcreateAverageFrom(IContainer<IColor> colors) static ColorcreateAverageFrom(IColor color, IColor... colors) static Colorstatic ColorfromLong(long pLong) static ColorfromSpecification(INode<?> specification) static ColorfromString(String string) doubleintIContainer<INode<?>> doubleintdoubleintdoubleintbooleanbooleanbooleanbooleanintlongtoLong()withAlphaValue(int alphaValue) withFloatingPointAlphaValue(double floatingPointAlphaValue) static ColorwithRedValueAndGreenValueAndBlueValue(int redValue, int greenValue, int blueValue) static ColorwithRedValueAndGreenValueAndBlueValueAndAlphaValue(int redValue, int greenValue, int blueValue, int alphaValue) Methods inherited from class AbstractElement
equals, getSpecification, hashCode, toStringMethods inherited from interface IElement
getSpecification, toFormatedString, toXml
-
Field Details
-
DEFAULT_ALPHA_VALUE
public static final int DEFAULT_ALPHA_VALUE- See Also:
-
MIN_COLOR_LONG
public static final long MIN_COLOR_LONG- See Also:
-
MAX_COLOR_LONG
public static final long MAX_COLOR_LONG- See Also:
-
MIN_COLOR_COMPONENT
public static final short MIN_COLOR_COMPONENT- See Also:
-
MAX_COLOR_COMPONENT
public static final short MAX_COLOR_COMPONENT- See Also:
-
-
Method Details
-
createAverageFrom
-
createAverageFrom
-
fromColor
- Parameters:
color-- Returns:
- a new
Colorfrom the given color. - Throws:
NullPointerException- if the given color is null.
-
fromLong
- Parameters:
pLong-- Returns:
- a new
Colorfrom the given pLong. - Throws:
RuntimeException- if the given pLong does not represent aColor.
-
fromSpecification
- Parameters:
specification-- Returns:
- a new
Colorfrom the given specification - Throws:
RuntimeException- if the given specification is not valid.
-
fromString
- Parameters:
string-- Returns:
- a new
Colorfrom the given string. - Throws:
RuntimeException- if the given string does not represent aColor.
-
withRedValueAndGreenValueAndBlueValue
public static Color withRedValueAndGreenValueAndBlueValue(int redValue, int greenValue, int blueValue) - Parameters:
redValue-greenValue-blueValue-- Returns:
- a new
Colorwith the given redValue, greenValue and blueValue. - Throws:
RuntimeException- if the given blueValue is not a true color component (in [0, 255]).RuntimeException- if the given greenValue is not a true color component (in [0, 255]).RuntimeException- if the given blueValue is not a true color component (in [0, 255]).
-
withRedValueAndGreenValueAndBlueValueAndAlphaValue
public static Color withRedValueAndGreenValueAndBlueValueAndAlphaValue(int redValue, int greenValue, int blueValue, int alphaValue) - Parameters:
redValue-greenValue-blueValue-alphaValue-- Returns:
- a new
Colorwith the given redValue, greenValue, blueValue and alphaValue. - Throws:
RuntimeException- if the given blueValue is not a true color component (in [0, 255]).RuntimeException- if the given greenValue is not a true color component (in [0, 255]).RuntimeException- if the given blueValue is not a true color component (in [0, 255]).RuntimeException- if the given alphaValue is not a true color component (in [0, 255]).
-
getAlphaPercentage
public double getAlphaPercentage()- Specified by:
getAlphaPercentagein interfaceIColor- Returns:
- the alpha value of the current
IColoras percentage. A percentage is a number in the range [0.0, 1.0].
-
getAlphaValue
public int getAlphaValue()- Specified by:
getAlphaValuein interfaceIColor- Returns:
- the alpha value of the current
IColor.
-
getAttributes
- Specified by:
getAttributesin interfaceIElement- Returns:
- the attributes of the current
IElement.
-
getBluePercentage
public double getBluePercentage()- Specified by:
getBluePercentagein interfaceIColor- Returns:
- the blue value of the current
IColoras percentage. A percentage is a number in the range [0.0, 1.0].
-
getBlueValue
public int getBlueValue()- Specified by:
getBlueValuein interfaceIColor- Returns:
- the blue value of the current
IColor.
-
getColorNameOrHexadecimalString
- Specified by:
getColorNameOrHexadecimalStringin interfaceIColor- Returns:
- the color name or a hexadecimal
Stringrepresentation of the currentIColor.
-
getGreenPercentage
public double getGreenPercentage()- Specified by:
getGreenPercentagein interfaceIColor- Returns:
- the green value of the current
IColoras percentage. A percentage is a number in the range [0.0, 1.0].
-
getGreenValue
public int getGreenValue()- Specified by:
getGreenValuein interfaceIColor- Returns:
- the green value of the current
IColor.
-
getInvertedColor
-
getRedPercentage
public double getRedPercentage()- Specified by:
getRedPercentagein interfaceIColor- Returns:
- the red value of the current
IColoras percentage. A percentage is a number in the range [0.0, 1.0].
-
getRedValue
public int getRedValue()- Specified by:
getRedValuein interfaceIColor- Returns:
- the red value of the current
IColor.
-
hasFullAlphaValue
public boolean hasFullAlphaValue()- Specified by:
hasFullAlphaValuein interfaceIColor- Returns:
- true if the current
IColorhas a full alpha value, false otherwise.
-
hasFullBlueValue
public boolean hasFullBlueValue()- Specified by:
hasFullBlueValuein interfaceIColor- Returns:
- true if the current
IColorhas a full blue value, false otherwise.
-
hasFullGreenValue
public boolean hasFullGreenValue()- Specified by:
hasFullGreenValuein interfaceIColor- Returns:
- true if the current
IColorhas a full green value, false otherwise.
-
hasFullRedValue
public boolean hasFullRedValue()- Specified by:
hasFullRedValuein interfaceIColor- Returns:
- true if the current
IColorhas a full red value, false otherwise.
-
toAlphaRedGreenBlueInt
public int toAlphaRedGreenBlueInt()- Specified by:
toAlphaRedGreenBlueIntin interfaceIColor- Returns:
- an integer representation of the current
IColorwith the schema alpha-red-green-blue.
-
toHexadecimalString
- Specified by:
toHexadecimalStringin interfaceIColor- Returns:
- a hexadecimal
Stringrepresentation of the currentIColor.
-
toHexadecimalStringWithAlphaValue
- Specified by:
toHexadecimalStringWithAlphaValuein interfaceIColor- Returns:
- a hexadecimal with alpha value
Stringrepresentation of the currentIColor.
-
toLong
-
withFloatingPointAlphaValue
- Specified by:
withFloatingPointAlphaValuein interfaceIColor- Parameters:
floatingPointAlphaValue-- Returns:
- a new
IColorfrom the currentIColorwith the given floatingPointAlphaValue.
-
withFullAlphaValue
- Specified by:
withFullAlphaValuein interfaceIColor- Returns:
- a new
IColorfrom the currentIColorwith a full alpha value.
-
withAlphaValue
- Specified by:
withAlphaValuein interfaceIColor- Parameters:
alphaValue-- Returns:
- a new
IColorfrom the currentIColorwith the given alphaValue.
-