Class 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
    • Field Detail

      • RGB_BLACK

        public static final java.lang.Object RGB_BLACK
    • 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.DataFormatException
        Deprecated.
        use typesafe constructors
        constructs 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.DataFormatException
        constructs 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 red
        g - the color green
        b - 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 red
        g - the color green
        b - 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.DataFormatException
        isValid - true if the size of the vector is 3 and all instances are Double types
        Specified by:
        isValid in class JDFNumList
        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