ceTe Software Help Library for Java August - 2020
DynamicPDF Generator for Java / Programming with Generator for Java / Colors
In This Topic
    Colors
    In This Topic

    Colors are handled by a Color base class. Colors can be of the following types:

    • CMYK - Specified with C, M, Y, and K color values
    • RGB - Specified with R, G, and B color values
    • Web - Specified with the Web color format (i.e. "#FF0080" or "aqua")
    • Grayscale - Specified as a level of gray
    • Gradient - Specified with two colors of the same type
    • Spot Color - Specifies a tint (shading) of a spot color ink
    These colors can be used with many of the Page Element objects. RGB and Web colors can be used with the Outline and Bookmark Objects.

    Examples for creating color objects:

    CMYK Color

    [Java]
        CmykColor cmykColor1 = new CmykColor( 0.5f, 0.3f, 0.6f, 0.0f );
        CmykColor cmykColor2 = new CmykColor( 0.3f, 0.5f, 0.6f, 0.2f );
        page.getElements().add( new Circle( 100, 100, 40, cmykColor1, cmykColor2 ) );
        page.getElements().add( new Circle( 150, 100, 40, CmykColor.getBlack(), CmykColor.getRed() ) );
    

    RGB Color

    [Java]
        RgbColor rgbColor1 = new RgbColor( 0.5f, 0.3f, 0.6f );
        RgbColor rgbColor2 = new RgbColor( 0.3f, 0.5f, 0.2f );
        page.getElements().add( new Circle( 100, 100, 40, rgbColor1, rgbColor2 ) );
        page.getElements().add( new Circle( 150, 100, 40, RgbColor.getBlack(), RgbColor.getRed() ) );
    

    Web Color

    [Java]
        WebColor webColor1 = new WebColor( "#FF0080" );
        WebColor webColor2 = new WebColor( "aqua" );
        page.getElements().add( new Circle( 100, 100, 40, webColor1, webColor2 ) );
    

    Grayscale

    [Java]
        Grayscale grayscale1 = new Grayscale( 0.3f );
        Grayscale grayscale2 = new Grayscale( 0.6f );
        page.getElements().add( new Circle( 100, 100, 40, grayscale1, grayscale2 ) );
        page.getElements().add( new Circle( 150, 100, 40, Grayscale.getWhite(), Grayscale.getBlack() ) );
    

    Gradient

    [Java]
        Gradient gradient1 = new Gradient( 0, 0, 200, 200, Grayscale.getWhite(), Grayscale.getBlack());
        Gradient gradient2 = new Gradient( 50, 0, 250, 200, RgbColor.getYellowGreen(), RgbColor.getDarkMagenta());
        page.getElements().add( new Circle( 100, 100, 40, gradient1, gradient1 ) );
        page.getElements().add( new Circle( 150, 100, 40, gradient2, gradient2 ) );
    

    Spot Color

    [Java]
        CmykColor alternateColor = new CmykColor( 0.2f, 0.9f, 0.5f, 0.2f );
        SpotColorInk ink = new SpotColorInk( "My Red", alternateColor );
        SpotColor tint100 = new SpotColor( 1, ink );
        SpotColor tint50 = new SpotColor( 0.5f, ink );
        page.getElements().add( new Circle( 100, 100, 40, tint50, tint50 ) );
        page.getElements().add( new Circle( 150, 100, 40, tint100, tint100 ) );
    

    Predefined Colors

    The color class includes over 140 predefined colors accessed through the static property of the Color class by color name. These names correspond with the colors commonly used in web development. These can also be specified by name in the constructor of the WebColor class or from within a FormattedTextArea.  

    See Also