FileDocCategorySizeDatePackage
CommonGraphics2D.javaAPI DocAndroid 1.5 API36872Wed May 06 22:41:54 BST 2009org.apache.harmony.awt.gl

CommonGraphics2D

public abstract class CommonGraphics2D extends Graphics2D
CommonGraphics2D class is a super class for all system-dependent implementations. It implements major part of Graphics and Graphics2D abstract methods.

CommonGraphics2D Class Internals

Line and Shape Rasterizers

The CommonGraphics2D class splits all shapes into a set of rectangles to unify the drawing process for different operating systems and architectures. For this purpose Java 2D* uses the JavaShapeRasterizer and the JavaLineRasterizer classes from the org.apache.harmony.awt.gl.render package. The JavaShapeRasterizer class splits an object implementing a Shape interface into a set of rectangles and produces a MultiRectArea object. The JavaLineRasterizer class makes line drawing more accurate and processes lines with strokes, which are instances of the BasicStroke class.

To port the shape drawing to another platform you just need to override rectangle-drawing methods. However, if your operating system has functions to draw particular shapes, you can optimize your subclass of the CommonGraphics2D class by using this functionality in overridden methods.

Blitters

Blitter classes draw images on the display or buffered images. All blitters inherit the org.apache.harmony.awt.gl.render.Blitter interface.

Blitters are divided into:

  • Native blitters for simple types of images, which the underlying native library can draw.
  • Java* blitters for those types of images, which the underlying native library cannot handle.

DRL Java 2D* also uses blitters to fill the shapes and the user-defined subclasses of the java.awt.Paint class with paints, which the system does not support.

Text Renderers

Text renderers draw strings and glyph vectors. All text renderers are subclasses of the org.apache.harmony.awt.gl.TextRenderer class.

Fields Summary
protected org.apache.harmony.awt.gl.Surface
dstSurf
protected org.apache.harmony.awt.gl.render.Blitter
blitter
protected RenderingHints
hints
protected MultiRectArea
clip
protected Paint
paint
protected Color
fgColor
protected Color
bgColor
protected Composite
composite
protected Stroke
stroke
protected FontRenderContext
frc
protected org.apache.harmony.awt.gl.render.JavaShapeRasterizer
jsr
protected Font
font
protected TextRenderer
jtr
protected AffineTransform
transform
protected double[]
matrix
public Point
origPoint
protected static final boolean
debugOutput
Constructors Summary
protected CommonGraphics2D()

 //$NON-NLS-1$ //$NON-NLS-2$

    // Constructors
      
    
protected CommonGraphics2D(int tx, int ty)

        this(tx, ty, null);
    
protected CommonGraphics2D(int tx, int ty, MultiRectArea clip)

        setTransform(AffineTransform.getTranslateInstance(tx, ty));
        //origTransform = AffineTransform.getTranslateInstance(tx, ty);
        origPoint = new Point(tx, ty);
        setClip(clip);
    
Methods Summary
public voidaddRenderingHints(java.util.Map hints)

        this.hints.putAll(hints);
    
public voidclearRect(int x, int y, int width, int height)

        Color c = getColor();
        Paint p = getPaint();
        setColor(getBackground());
        fillRect(x, y, width, height);
        setColor(c);
        setPaint(p);
        if (debugOutput) {
            System.err.println("CommonGraphics2D.clearRect("+x+", "+y+", "+width+", "+height+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        }
    
public voidclip(java.awt.Shape s)

        if (s == null) {
            clip = null;
            return;
        }

        MultiRectArea mra = null;
        if (s instanceof MultiRectArea) {
            mra = new MultiRectArea((MultiRectArea)s);
            mra.translate((int)transform.getTranslateX(), (int)transform.getTranslateY());
        } else {
            int type = transform.getType();
            if(s instanceof Rectangle && (type & (AffineTransform.TYPE_IDENTITY |
                AffineTransform.TYPE_TRANSLATION)) != 0){
                    mra = new MultiRectArea((Rectangle)s);
                    if(type == AffineTransform.TYPE_TRANSLATION){
                        mra.translate((int)transform.getTranslateX(), (int)transform.getTranslateY());
                    }
            } else {
                s = transform.createTransformedShape(s);
                mra = jsr.rasterize(s, 0.5);
            }
        }

        if (clip == null) {
            setTransformedClip(mra);
        } else {
            clip.intersect(mra);
            setTransformedClip(clip);
        }
    
public voidclipRect(int x, int y, int width, int height)

        clip(new Rectangle(x, y, width, height));
    
protected voidcopyInternalFields(org.apache.harmony.awt.gl.CommonGraphics2D copy)
Copies graphics class fields. Used in create method

param
copy Graphics class to copy

        if (clip == null) {
            copy.setTransformedClip(null);
        } else {
            copy.setTransformedClip(new MultiRectArea(clip));
        }
        copy.setBackground(bgColor);
        copy.setColor(fgColor);
        copy.setPaint(paint);
        copy.setComposite(composite);
        copy.setStroke(stroke);
        copy.setFont(font);
        copy.setTransform(new AffineTransform(transform));
        //copy.origTransform = new AffineTransform(origTransform);
        copy.origPoint = new Point(origPoint);
    
public voiddispose()

        // Do nothing for Java only classes
    
public voiddraw(java.awt.Shape s)
Draw methods

        if (stroke instanceof BasicStroke && ((BasicStroke)stroke).getLineWidth() <= 1) {
            //TODO: Think about drawing the shape in one fillMultiRectArea call
            BasicStroke bstroke = (BasicStroke)stroke;
            JavaLineRasterizer.LineDasher ld = (bstroke.getDashArray() == null)?null:new JavaLineRasterizer.LineDasher(bstroke.getDashArray(), bstroke.getDashPhase());
            PathIterator pi = s.getPathIterator(transform, 0.5);
            float []points = new float[6];
            int x1 = Integer.MIN_VALUE;
            int y1 = Integer.MIN_VALUE;
            int cx1 = Integer.MIN_VALUE;
            int cy1 = Integer.MIN_VALUE;
            while (!pi.isDone()) {
                switch (pi.currentSegment(points)) {
                    case PathIterator.SEG_MOVETO:
                        x1 = (int)Math.floor(points[0]);
                        y1 = (int)Math.floor(points[1]);
                        cx1 = x1;
                        cy1 = y1;
                        break;
                    case PathIterator.SEG_LINETO:
                        int x2 = (int)Math.floor(points[0]);
                        int y2 = (int)Math.floor(points[1]);
                        fillMultiRectArea(JavaLineRasterizer.rasterize(x1, y1, x2, y2, null, ld, false));
                        x1 = x2;
                        y1 = y2;
                        break;
                    case PathIterator.SEG_CLOSE:
                        x2 = cx1;
                        y2 = cy1;
                        fillMultiRectArea(JavaLineRasterizer.rasterize(x1, y1, x2, y2, null, ld, false));
                        x1 = x2;
                        y1 = y2;
                        break;
                }
                pi.next();
            }
        } else {
            s = stroke.createStrokedShape(s);
            s = transform.createTransformedShape(s);
            fillMultiRectArea(jsr.rasterize(s, 0.5));
        }
    
public voiddrawArc(int x, int y, int width, int height, int sa, int ea)

        if (stroke instanceof BasicStroke && ((BasicStroke)stroke).getLineWidth() <= 1 &&
                ((BasicStroke)stroke).getDashArray() == null && 
                (transform.isIdentity() || transform.getType() == AffineTransform.TYPE_TRANSLATION)) {
            Point p = new Point(x, y);
            transform.transform(p, p);
            MultiRectArea mra = JavaArcRasterizer.rasterize(x, y, width, height, sa, ea, clip);
            fillMultiRectArea(mra);
            return;
        }
        draw(new Arc2D.Float(x, y, width, height, sa, ea, Arc2D.OPEN));
    
public voiddrawGlyphVector(java.awt.font.GlyphVector gv, float x, float y)


        AffineTransform at = gv.getFont().getTransform();

        double[] matrix = new double[6];
        if ((at != null) && (!at.isIdentity())){

            int atType = at.getType();
            at.getMatrix(matrix);

            // TYPE_TRANSLATION
            if ((atType == AffineTransform.TYPE_TRANSLATION) &&
                ((gv.getLayoutFlags() & GlyphVector.FLAG_HAS_TRANSFORMS) == 0)){
                jtr.drawGlyphVector(this, gv, (int)(x+matrix[4]), (int)(y+matrix[5]));
                return;
            }
        } else {
            if (((gv.getLayoutFlags() & GlyphVector.FLAG_HAS_TRANSFORMS) == 0)){
                jtr.drawGlyphVector(this, gv, x, y);
                return;
            }
        }

        // TODO: we use slow type of drawing strings when Font object
        // in Graphics has transforms, we just fill outlines. New textrenderer
        // is to be implemented.

        Shape sh = gv.getOutline(x, y);
        this.fill(sh);

        
public booleandrawImage(java.awt.Image image, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)


        if(image == null) {
            return true;
        }

        boolean done = false;
        boolean somebits = false;
        Surface srcSurf = null;
        if(image instanceof OffscreenImage){
            OffscreenImage oi = (OffscreenImage) image;
            if((oi.getState() & ImageObserver.ERROR) != 0) {
                return false;
            }
            done = oi.prepareImage(imageObserver);
            somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
            srcSurf = oi.getImageSurface();
        }else{
            done = true;
            srcSurf = Surface.getImageSurface(image);
        }

        if(done || somebits) {
            int w = srcSurf.getWidth();
            int h = srcSurf.getHeight();
            blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h, (AffineTransform) transform.clone(),
                    composite, bgcolor, clip);
        }
        return done;
    
public booleandrawImage(java.awt.Image image, int x, int y, java.awt.image.ImageObserver imageObserver)

        return drawImage(image, x, y, null, imageObserver);
    
public booleandrawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)


        if(image == null) {
            return true;
        }
        if(width == 0 || height == 0) {
            return true;
        }

        boolean done = false;
        boolean somebits = false;
        Surface srcSurf = null;

        if(image instanceof OffscreenImage){
            OffscreenImage oi = (OffscreenImage) image;
            if((oi.getState() & ImageObserver.ERROR) != 0) {
                return false;
            }
            done = oi.prepareImage(imageObserver);
            somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
            srcSurf = oi.getImageSurface();
        }else{
            done = true;
            srcSurf = Surface.getImageSurface(image);
        }

        if(done || somebits) {
            int w = srcSurf.getWidth();
            int h = srcSurf.getHeight();
            if(w == width && h == height){
                blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                        (AffineTransform) transform.clone(),
                        composite, bgcolor, clip);
            }else{
                AffineTransform xform = new AffineTransform();
                xform.setToScale((float)width / w, (float)height / h);
                blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                        (AffineTransform) transform.clone(),
                        xform, composite, bgcolor, clip);
            }
        }
        return done;
    
public booleandrawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.image.ImageObserver imageObserver)

        return drawImage(image, x, y, width, height, null, imageObserver);
    
public booleandrawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver imageObserver)


        if(image == null) {
            return true;
        }
        if(dx1 == dx2 || dy1 == dy2 || sx1 == sx2 || sy1 == sy2) {
            return true;
        }

        boolean done = false;
        boolean somebits = false;
        Surface srcSurf = null;
        if(image instanceof OffscreenImage){
            OffscreenImage oi = (OffscreenImage) image;
            if((oi.getState() & ImageObserver.ERROR) != 0) {
                return false;
            }
            done = oi.prepareImage(imageObserver);
            somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
            srcSurf = oi.getImageSurface();
        }else{
            done = true;
            srcSurf = Surface.getImageSurface(image);
        }

        if(done || somebits) {

            int dstX = dx1;
            int dstY = dy1;
            int srcX = sx1;
            int srcY = sy1;

            int dstW = dx2 - dx1;
            int dstH = dy2 - dy1;
            int srcW = sx2 - sx1;
            int srcH = sy2 - sy1;

            if(srcW == dstW && srcH == dstH){
                blitter.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, srcW, srcH,
                        (AffineTransform) transform.clone(),
                        composite, bgcolor, clip);
            }else{
                AffineTransform xform = new AffineTransform();
                xform.setToScale((float)dstW / srcW, (float)dstH / srcH);
                blitter.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, srcW, srcH,
                        (AffineTransform) transform.clone(),
                        xform, composite, bgcolor, clip);
            }
        }
        return done;
    
public booleandrawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver imageObserver)


        return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null,
                imageObserver);
     
public voiddrawImage(java.awt.image.BufferedImage bufImage, java.awt.image.BufferedImageOp op, int x, int y)


        if(bufImage == null) {
            return;
        }

        if(op == null) {
            drawImage(bufImage, x, y, null);
        } else if(op instanceof AffineTransformOp){
            AffineTransformOp atop = (AffineTransformOp) op;
            AffineTransform xform = atop.getTransform();
            Surface srcSurf = Surface.getImageSurface(bufImage);
            int w = srcSurf.getWidth();
            int h = srcSurf.getHeight();
            blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                    (AffineTransform) transform.clone(), xform,
                    composite, null, clip);
        } else {
            bufImage = op.filter(bufImage, null);
            Surface srcSurf = Surface.getImageSurface(bufImage);
            int w = srcSurf.getWidth();
            int h = srcSurf.getHeight();
            blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                    (AffineTransform) transform.clone(),
                    composite, null, clip);
        }
    
public booleandrawImage(java.awt.Image image, java.awt.geom.AffineTransform trans, java.awt.image.ImageObserver imageObserver)


        if(image == null) {
            return true;
        }
        if(trans == null || trans.isIdentity()) {
            return drawImage(image, 0, 0, imageObserver);
        }

        boolean done = false;
        boolean somebits = false;
        Surface srcSurf = null;
        if(image instanceof OffscreenImage){
            OffscreenImage oi = (OffscreenImage) image;
            if((oi.getState() & ImageObserver.ERROR) != 0) {
                return false;
            }
            done = oi.prepareImage(imageObserver);
            somebits = (oi.getState() & ImageObserver.SOMEBITS) != 0;
            srcSurf = oi.getImageSurface();
        }else{
            done = true;
            srcSurf = Surface.getImageSurface(image);
        }

        if(done || somebits) {
            int w = srcSurf.getWidth();
            int h = srcSurf.getHeight();
            AffineTransform xform = (AffineTransform) transform.clone();
            xform.concatenate(trans);
            blitter.blit(0, 0, srcSurf, 0, 0, dstSurf, w, h, xform, composite,
                    null, clip);
        }
        return done;
    
public voiddrawLine(int x1, int y1, int x2, int y2)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.drawLine("+x1+", "+y1+", "+x2+", "+y2+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        }

        if (stroke instanceof BasicStroke && ((BasicStroke)stroke).getLineWidth() <= 1) {
            BasicStroke bstroke = (BasicStroke)stroke;
            Point p1 = new Point(x1, y1);
            Point p2 = new Point(x2, y2);
            transform.transform(p1, p1);
            transform.transform(p2, p2);
            JavaLineRasterizer.LineDasher ld = (bstroke.getDashArray() == null)?null:new JavaLineRasterizer.LineDasher(bstroke.getDashArray(), bstroke.getDashPhase());
            MultiRectArea mra = JavaLineRasterizer.rasterize(p1.x, p1.y, p2.x, p2.y, null, ld, false);
            fillMultiRectArea(mra);
            return;
        }
        draw(new Line2D.Float(x1, y1, x2, y2));
    
public voiddrawOval(int x, int y, int width, int height)

        if (stroke instanceof BasicStroke && ((BasicStroke)stroke).getLineWidth() <= 1 &&
                ((BasicStroke)stroke).getDashArray() == null && 
                (transform.isIdentity() || transform.getType() == AffineTransform.TYPE_TRANSLATION)) {
            Point p = new Point(x, y);
            transform.transform(p, p);
            MultiRectArea mra = JavaArcRasterizer.rasterize(x, y, width, height, 0, 360, clip);
            fillMultiRectArea(mra);
            return;
        }
        draw(new Ellipse2D.Float(x, y, width, height));
    
public voiddrawPolygon(int[] xpoints, int[] ypoints, int npoints)

        draw(new Polygon(xpoints, ypoints, npoints));
    
public voiddrawPolygon(java.awt.Polygon polygon)

        draw(polygon);
    
public voiddrawPolyline(int[] xpoints, int[] ypoints, int npoints)

        for (int i = 0; i < npoints-1; i++) {
            drawLine(xpoints[i], ypoints[i], xpoints[i+1], ypoints[i+1]);
        }
    
public voiddrawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)

        if (img == null) {
            return;
        }

        double scaleX = xform.getScaleX();
        double scaleY = xform.getScaleY();
        if (scaleX == 1 && scaleY == 1) {
            drawRenderedImage(img.createDefaultRendering(), xform);
        } else {
            int width = (int)Math.round(img.getWidth()*scaleX);
            int height = (int)Math.round(img.getHeight()*scaleY);
            xform = (AffineTransform)xform.clone();
            xform.scale(1, 1);
            drawRenderedImage(img.createScaledRendering(width, height, null), xform);
        }
    
public voiddrawRenderedImage(java.awt.image.RenderedImage rimg, java.awt.geom.AffineTransform xform)

        if (rimg == null) {
            return;
        }

        Image img = null;

        if (rimg instanceof Image) {
            img = (Image)rimg;
        } else {
            //TODO: Create new class to provide Image interface for RenderedImage or rewrite this method
            img = new BufferedImage(rimg.getColorModel(), rimg.copyData(null), false, null);
        }

        drawImage(img, xform, null);
    
public voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.drawRoundRect("+x+", "+y+", "+width+", "+height+","+arcWidth+", "+arcHeight+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
        }

        draw(new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight));
    
public voiddrawString(java.text.AttributedCharacterIterator iterator, float x, float y)
String methods

        GlyphVector gv = font.createGlyphVector(frc, iterator);
        drawGlyphVector(gv, x, y);
    
public voiddrawString(java.text.AttributedCharacterIterator iterator, int x, int y)

        drawString(iterator, (float)x, (float)y);
    
public voiddrawString(java.lang.String str, int x, int y)

        drawString(str, (float)x, (float)y);
    
public voiddrawString(java.lang.String str, float x, float y)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.drawString("+str+", "+x+", "+y+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        }

        AffineTransform at = (AffineTransform)this.getTransform().clone();
        AffineTransform fontTransform = font.getTransform();
        at.concatenate(fontTransform);

        double[] matrix = new double[6];
        if (!at.isIdentity()){

            int atType = at.getType();
            at.getMatrix(matrix);

            // TYPE_TRANSLATION
            if (atType == AffineTransform.TYPE_TRANSLATION){
                jtr.drawString(this, str,
                        (float)(x+fontTransform.getTranslateX()),
                        (float)(y+fontTransform.getTranslateY()));
                return;
            }
            // TODO: we use slow type of drawing strings when Font object
            // in Graphics has transforms, we just fill outlines. New textrenderer
            // is to be implemented.
            Shape sh = font.createGlyphVector(this.getFontRenderContext(), str).getOutline(x, y);
            this.fill(sh);

        } else {
            jtr.drawString(this, str, x, y);
        }

    
public voidfill(java.awt.Shape s)
Fill methods

        s = transform.createTransformedShape(s);
        MultiRectArea mra = jsr.rasterize(s, 0.5);
        fillMultiRectArea(mra);
    
public voidfillArc(int x, int y, int width, int height, int sa, int ea)

        fill(new Arc2D.Float(x, y, width, height, sa, ea, Arc2D.PIE));
    
protected voidfillMultiRectArea(MultiRectArea mra)
This method fills the given MultiRectArea with current paint. It calls fillMultiRectAreaColor and fillMultiRectAreaPaint methods depending on the type of current paint.

param
mra MultiRectArea to fill

        if (clip != null) {
            mra.intersect(clip);
        }

        // Return if all stuff is clipped
        if (mra.rect[0] < 5) {
            return;
        }

        if (debugOutput) {
            System.err.println("CommonGraphics2D.fillMultiRectArea("+mra+")"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if (paint instanceof Color){
            fillMultiRectAreaColor(mra);
        }else{
            fillMultiRectAreaPaint(mra);
        }
    
protected voidfillMultiRectAreaColor(MultiRectArea mra)
This method fills the given MultiRectArea with solid color.

param
mra MultiRectArea to fill

        fillMultiRectAreaPaint(mra);
    
protected voidfillMultiRectAreaPaint(MultiRectArea mra)
This method fills the given MultiRectArea with any paint.

param
mra MultiRectArea to fill

        Rectangle rec = mra.getBounds();
        int x = rec.x;
        int y = rec.y;
        int w = rec.width;
        int h = rec.height;
        if(w <= 0 || h <= 0) {
            return;
        }
        PaintContext pc = paint.createContext(null, rec, rec, transform, hints);
        Raster r = pc.getRaster(x, y, w, h);
        WritableRaster wr;
        if(r instanceof WritableRaster){
            wr = (WritableRaster) r;
        }else{
            wr = r.createCompatibleWritableRaster();
            wr.setRect(r);
        }
        Surface srcSurf = new ImageSurface(pc.getColorModel(), wr);
        blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                composite, null, mra);
        srcSurf.dispose();
    
public voidfillOval(int x, int y, int width, int height)

        fill(new Ellipse2D.Float(x, y, width, height));
    
public voidfillPolygon(int[] xpoints, int[] ypoints, int npoints)

        fill(new Polygon(xpoints, ypoints, npoints));
    
public voidfillPolygon(java.awt.Polygon polygon)

        fill(polygon);
    
public voidfillRect(int x, int y, int width, int height)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.fillRect("+x+", "+y+", "+width+", "+height+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
        }

        fill(new Rectangle(x, y, width, height));
    
public voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.fillRoundRect("+x+", "+y+", "+width+", "+height+","+arcWidth+", "+arcHeight+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
        }

        fill(new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight));
    
public java.awt.ColorgetBackground()
Get methods

        return bgColor;
    
public java.awt.ShapegetClip()

        if (clip == null) {
            return null;
        }

        MultiRectArea res = new MultiRectArea(clip);
        res.translate(-Math.round((float)transform.getTranslateX()), -Math.round((float)transform.getTranslateY()));
        return res;
    
public java.awt.RectanglegetClipBounds()

        if (clip == null) {
            return null;
        }

        Rectangle res = (Rectangle) clip.getBounds().clone();
        res.translate(-Math.round((float)transform.getTranslateX()), -Math.round((float)transform.getTranslateY()));
        return res;
    
public java.awt.ColorgetColor()

        return fgColor;
    
public java.awt.CompositegetComposite()

        return composite;
    
public java.awt.FontgetFont()

        return font;
    
public java.awt.FontMetricsgetFontMetrics(java.awt.Font font)

        return Toolkit.getDefaultToolkit().getFontMetrics(font);
    
public java.awt.font.FontRenderContextgetFontRenderContext()

        return frc;
    
public java.awt.PaintgetPaint()

        return paint;
    
public java.lang.ObjectgetRenderingHint(java.awt.RenderingHints$Key key)

        return hints.get(key);
    
public java.awt.RenderingHintsgetRenderingHints()

        return hints;
    
public java.awt.StrokegetStroke()

        return stroke;
    
public java.awt.geom.AffineTransformgetTransform()

        return (AffineTransform)transform.clone();
    
public booleanhit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)

        //TODO: Implement method....
        return false;
    
public voidrotate(double theta)
Transformation methods

        transform.rotate(theta);
        transform.getMatrix(matrix);
    
public voidrotate(double theta, double x, double y)

        transform.rotate(theta, x, y);
        transform.getMatrix(matrix);
    
public voidscale(double sx, double sy)

        transform.scale(sx, sy);
        transform.getMatrix(matrix);
    
public voidsetBackground(java.awt.Color color)
Set methods

        bgColor = color;
    
public voidsetClip(int x, int y, int width, int height)

        setClip(new Rectangle(x, y, width, height));
    
public voidsetClip(java.awt.Shape s)

        if (s == null) {
            setTransformedClip(null);
            if (debugOutput) {
                System.err.println("CommonGraphics2D.setClip(null)"); //$NON-NLS-1$
            }
            return;
        }

        if (debugOutput) {
            System.err.println("CommonGraphics2D.setClip("+s.getBounds()+")"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if (s instanceof MultiRectArea) {
            MultiRectArea nclip = new MultiRectArea((MultiRectArea)s);
            nclip.translate(Math.round((float)transform.getTranslateX()), Math.round((float)transform.getTranslateY()));
            setTransformedClip(nclip);
        } else {
            int type = transform.getType();
            if(s instanceof Rectangle && (type & (AffineTransform.TYPE_IDENTITY |
                AffineTransform.TYPE_TRANSLATION)) != 0){
                    MultiRectArea nclip = new MultiRectArea((Rectangle)s);
                    if(type == AffineTransform.TYPE_TRANSLATION){
                        nclip.translate((int)transform.getTranslateX(), (int)transform.getTranslateY());
                    }
                    setTransformedClip(nclip);
            } else {
                s = transform.createTransformedShape(s);
                setTransformedClip(jsr.rasterize(s, 0.5));
            }
        }
    
public voidsetColor(java.awt.Color color)

        if (color != null) {
            fgColor = color;
            paint = color;
        }
    
public voidsetComposite(java.awt.Composite composite)

        this.composite = composite;
    
public voidsetFont(java.awt.Font font)

        this.font = font;
    
public voidsetPaint(java.awt.Paint paint)

        if (paint == null)
            return;
            
        this.paint = paint;
        if (paint instanceof Color) {
            fgColor = (Color)paint;
        }
    
public voidsetPaintMode()

        composite = AlphaComposite.SrcOver;
    
public voidsetRenderingHint(java.awt.RenderingHints$Key key, java.lang.Object value)

        hints.put(key, value);
    
public voidsetRenderingHints(java.util.Map hints)

        this.hints.clear();
        this.hints.putAll(hints);
    
public voidsetStroke(java.awt.Stroke stroke)

        this.stroke = stroke;
    
public voidsetTransform(java.awt.geom.AffineTransform transform)

        this.transform = transform;

        transform.getMatrix(matrix);
    
protected voidsetTransformedClip(MultiRectArea clip)

        this.clip = clip;
    
public voidsetXORMode(java.awt.Color color)

        composite = new XORComposite(color);
    
public voidshear(double shx, double shy)

        transform.shear(shx, shy);
        transform.getMatrix(matrix);
    
public voidtransform(java.awt.geom.AffineTransform at)

        transform.concatenate(at);
        transform.getMatrix(matrix);
    
public voidtranslate(double tx, double ty)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.translate("+tx+", "+ty+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }

        transform.translate(tx, ty);
        transform.getMatrix(matrix);
    
public voidtranslate(int tx, int ty)

        if (debugOutput) {
            System.err.println("CommonGraphics2D.translate("+tx+", "+ty+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }

        transform.translate(tx, ty);
        transform.getMatrix(matrix);