Package org.cip4.jdflib.datatypes
Class JDFRGBColor
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Object>,Collection<Object>,List<Object>,RandomAccess,JDFBaseDataTypes
This class is a representation of a RGB color (JDFRGBColor). It is a blank separated list of double values consisting of R the red color, G the green color and B the blue color value.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.cip4.jdflib.datatypes.JDFNumList
JDFNumList.NormComparator, JDFNumList.VolumeComparatorNested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue -
Field Summary
FieldsFields inherited from class java.util.Vector
capacityIncrement, elementCount, elementDataFields inherited from class java.util.AbstractList
modCountFields inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
EPSILON, MAX_CMYK_COLOR, MAX_LAB_COLOR, MAX_MATRIX_DIMENSION, MAX_RECTANGLE_DIMENSION, MAX_RGB_COLOR, MAX_SHAPE_DIMENSION, MAX_XY_DIMENSION -
Constructor Summary
ConstructorsConstructorDescriptionconstructs a RGB color with all values set to 0.0 DoubleJDFRGBColor(double[] rgbArray) JDFRGBColor(double r, double g, double b) constructs a new RGB color with the given double valuesJDFRGBColor(int r, int g, int b) constructs a new RGB color with the given double valuesconstructs a RGB color with all values set via a StringDeprecated.use typesafe constructorsconstructs a RGB color with all values set via a JDFNumberList -
Method Summary
Modifier and TypeMethodDescriptionstatic JDFRGBColorfactory for RGBColors that silently returns null in case of illegal strings also applies some voodo to parse html hex stringsdoublegetB()getBlue - returns the blue colorintgetB255()getBlue - returns the blue colorgetCMYK()static double[]getCMYKArray(double r, double g, double b) static double[]getCMYKArray(int r, int g, int b) doublegetG()getG - returns the green colorintgetG255()getBlue - returns the green colorget the html color representation of this color in the format 0xrrggbb;doublegetR()getR - returns the red colorintgetR255()getBlue - returns the red colorbooleanisValid()isValid - true if the size of the vector is 3 and all instances are Double typesvoidsetB(double blue) setBlue - sets the blue colorvoidsetB255(int blue) setBlue - sets the blue colorvoidsetG(double green) setGreen - sets the green colorvoidsetG255(int green) setGreen - sets the green colorvoidsetR(double red) setR - sets the red colorvoidsetR255(int red) setR - sets the red colorMethods inherited from class org.cip4.jdflib.datatypes.JDFNumList
abs, clone, contains, containsAll, copyNumList, doubleAt, elementAt, equals, getDouble, getDoubleList, getDoubleVector, getIntArray, getString, getString, hashCode, intAt, isValidString, matches, max, min, norm, removeElementAt, replaceElementAt, scale, scale, scaleFromCM, scaleFromCM, scaleFromMM, scaleFromMM, scaleToCM, scaleToCM, scaleToMM, scaleToMM, set, setString, setX, shift, sort, subtract, toString, unify, volumeMethods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elements, ensureCapacity, firstElement, forEach, get, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Field Details
-
RGB_BLACK
-
-
Constructor Details
-
JDFRGBColor
public JDFRGBColor()constructs a RGB color with all values set to 0.0 Double -
JDFRGBColor
Deprecated.use typesafe constructorsconstructs a RGB color with all values set via a Vector of Double objects- Parameters:
v- Vector of Double- Throws:
DataFormatException- - if the Vector has not a valid format
-
JDFRGBColor
constructs a RGB color with all values set via a String- Parameters:
s- the given String- Throws:
DataFormatException- - if the String has not a valid format
-
JDFRGBColor
constructs a RGB color with all values set via a JDFNumberList- Parameters:
nl- the given number list- Throws:
DataFormatException- - if the String has not a valid format
-
JDFRGBColor
public JDFRGBColor(double r, double g, double b) constructs a new RGB color with the given double values- Parameters:
r- the color redg- the color greenb- the color blue
-
JDFRGBColor
public JDFRGBColor(int r, int g, int b) constructs a new RGB color with the given double values- Parameters:
r- the color redg- the color greenb- the color blue
-
JDFRGBColor
public JDFRGBColor(double[] rgbArray) - Parameters:
rgbArray- 0-1 r,g,b
-
-
Method Details
-
createRGBColor
factory for RGBColors that silently returns null in case of illegal strings also applies some voodo to parse html hex strings- Parameters:
s- the string to parse- Returns:
- the RGB color, null if s is not compatible
-
isValid
isValid - true if the size of the vector is 3 and all instances are Double types- Specified by:
isValidin classJDFNumList- Returns:
- boolean - true if all instances are Double or Integer types
- Throws:
DataFormatException- - if the Vector has not a valid format
-
getR
public double getR()getR - returns the red color- Returns:
- double - the red color
-
setR
public void setR(double red) setR - sets the red color- Parameters:
red- the red color
-
setR255
public void setR255(int red) setR - sets the red color- Parameters:
red- the red color
-
getG
public double getG()getG - returns the green color- Returns:
- double - the green color
-
setG
public void setG(double green) setGreen - sets the green color- Parameters:
green- the green color
-
setG255
public void setG255(int green) setGreen - sets the green color- Parameters:
green- the green color
-
getB
public double getB()getBlue - returns the blue color- Returns:
- double - the blue color
-
getR255
public int getR255()getBlue - returns the red color- Returns:
- int - the red color in 0-255
-
getG255
public int getG255()getBlue - returns the green color- Returns:
- int - the green color in 0-255
-
getB255
public int getB255()getBlue - returns the blue color- Returns:
- int - the blue color in 0-255
-
setB
public void setB(double blue) setBlue - sets the blue color- Parameters:
blue- the blue color
-
setB255
public void setB255(int blue) setBlue - sets the blue color- Parameters:
blue- the blue color
-
getHTMLColor
get the html color representation of this color in the format 0xrrggbb;- Returns:
- the formatted string
-
getCMYK
- Returns:
- the cmyk color that roughly represents this
-
getCMYKArray
public static double[] getCMYKArray(double r, double g, double b) - Parameters:
r-g-b-- Returns:
- the cmyk color that roughly represents this
-
getCMYKArray
public static double[] getCMYKArray(int r, int g, int b) - Parameters:
r-g-b-- Returns:
- the cmyk color that roughly represents this
-