FileDocCategorySizeDatePackage
RGB.javaAPI DocphoneME MR2 API (J2ME)5120Wed May 02 18:00:34 BST 2007com.sun.perseus.j2d

RGB

public class RGB extends Object implements org.w3c.dom.svg.SVGRGBColor, PaintServer, PaintDef
Class which defines an Red, Green, Blue value.
version
$Id: RGB.java,v 1.3 2006/04/21 06:35:24 st125089 Exp $

Fields Summary
int
rgb
The internal RGB value.
public static final RGB
black
Predefined Colors
public static final RGB
white
public static final RGB
blue
public static final RGB
orange
public static final RGB
red
public static final RGB
green
public static final RGB
yellow
public static final RGB
gray
Constructors Summary
public RGB(int r, int g, int b)
Constructs an RGB with the red, green, and blue values.

param
r red component value
param
g green component value
param
b blue component value


                                  
               
        this(255, r, g, b);
    
public RGB(int a, int r, int g, int b)
Constructs an RGB with the alpha, red, green, and blue values.

param
a alpha component value
param
r red component value
param
g green component value
param
b blue component value

        rgb = (a << 24) | (r << 16) | (g << 8) | b;
    
Methods Summary
public voiddispose()
Called when the PaintServer is no longer used

    
public intgetAlpha()
Returns the alpha component of the SVGRGBColor.

return
the alpha component.

        return 0x000000ff & (rgb >> 24);
    
public intgetBlue()

        return 0x000000ff & rgb;
    
public intgetGreen()

        return 0x000000ff & (rgb >> 8);
    
public PaintDefgetPaintDef()

return
the PaintDef generated by the server.

        return this;
    
public intgetRed()

        return 0x000000ff & (rgb >> 16);
    
public voidsetPaint(PiscesRenderGraphics rg, com.sun.pisces.PiscesRenderer pr, int paintOpacity)
Sets the paint on a PiscesRender.

param
rg the RenderGraphics on requesting the paint to be set.
param
renderer the PiscesRender on which to set the paint.
param
paintOpacity additional paint opacity.

        pr.setColor(0xff & (rgb >> 16),
                    0xff & (rgb >> 8),
                    0xff & rgb,
                    (paintOpacity * (0xff & (rgb >> 24))) / 255);
    
public voidsetPaintTarget(java.lang.String paintType, PaintTarget paintTarget)

param
paintType a key that the PaintTarget can use to characterize its interest in the PaintServer. For example, a PaintTarget may be interested in the Paint both for stroking and filling purposes.
param
paintTarget the PaintTarget listening to changes to the paint generated by this PaintServer.

        // Do nothing: RGB is non mutable in that it does not change the PaintDef value it
        // returns from the getPaintDef method.
    
public java.lang.StringtoString()

return
this RGB color's values in the format 'rgb(r,g,b)'

        StringBuffer sb = new StringBuffer();
        sb.append("rgb(");
        sb.append(getRed());
        sb.append(",");
        sb.append(getGreen());
        sb.append(",");
        sb.append(getBlue());
        sb.append(")");
        return sb.toString();