Package org.cip4.jdflib.datatypes
Class JDFRGBColor
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.Object>
-
- org.cip4.jdflib.datatypes.JDFNumList
-
- org.cip4.jdflib.datatypes.JDFRGBColor
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.Object>,java.util.Collection<java.lang.Object>,java.util.List<java.lang.Object>,java.util.RandomAccess,JDFBaseDataTypes
public class JDFRGBColor extends JDFNumList
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cip4.jdflib.datatypes.JDFNumList
JDFNumList.NormComparator, JDFNumList.VolumeComparator
-
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ObjectRGB_BLACK-
Fields 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
Constructors Constructor Description JDFRGBColor()constructs 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 valuesJDFRGBColor(java.lang.String s)constructs a RGB color with all values set via a StringJDFRGBColor(java.util.Vector v)Deprecated.use typesafe constructorsJDFRGBColor(JDFRGBColor nl)constructs a RGB color with all values set via a JDFNumberList
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JDFRGBColorcreateRGBColor(java.lang.String s)factory 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 colorJDFCMYKColorgetCMYK()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 colorjava.lang.StringgetHTMLColor()get 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 color-
Methods 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, volume
-
Methods 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, trimToSize
-
-
-
-
Constructor Detail
-
JDFRGBColor
public JDFRGBColor()
constructs a RGB color with all values set to 0.0 Double
-
JDFRGBColor
@Deprecated public JDFRGBColor(java.util.Vector v) throws java.util.zip.DataFormatExceptionDeprecated.use typesafe constructorsconstructs a RGB color with all values set via a Vector of Double objects- Parameters:
v- Vector of Double- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFRGBColor
public JDFRGBColor(java.lang.String s) throws java.util.zip.DataFormatExceptionconstructs a RGB color with all values set via a String- Parameters:
s- the given String- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFRGBColor
public JDFRGBColor(JDFRGBColor nl)
constructs a RGB color with all values set via a JDFNumberList- Parameters:
nl- the given number list- Throws:
java.util.zip.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 Detail
-
createRGBColor
public static JDFRGBColor createRGBColor(java.lang.String s)
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
public boolean isValid() throws java.util.zip.DataFormatExceptionisValid - 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:
java.util.zip.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
public java.lang.String getHTMLColor()
get the html color representation of this color in the format 0xrrggbb;- Returns:
- the formatted string
-
getCMYK
public JDFCMYKColor 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
-
-