home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / print / ProxyGraphics2D.java < prev   
Encoding:
Java Source  |  1998-03-20  |  57.3 KB  |  1,509 lines

  1. /*
  2.  * @(#)ProxyGraphics2D.java    1.2 98/03/18
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.print;
  16.  
  17. import java.util.Hashtable;
  18.  
  19. import java.awt.Color;
  20. import java.awt.Composite;
  21. import java.awt.Graphics;
  22. import java.awt.Graphics2D;
  23. import java.awt.Font;
  24. import java.awt.FontMetrics;
  25. import java.awt.Graphics;
  26. import java.awt.GraphicsConfiguration;
  27. import java.awt.Image;
  28. import java.awt.Paint;
  29. import java.awt.Rectangle;
  30. import java.awt.Shape;
  31. import java.awt.Stroke;
  32.  
  33. import java.awt.font.GlyphSet;
  34. import java.awt.font.StyledString;
  35. import java.awt.font.TextLayout;
  36.  
  37. import java.awt.geom.AffineTransform;
  38. import java.awt.geom.Rectangle2D;
  39.  
  40. import java.awt.image.BufferedImage;
  41. import java.awt.image.BufferedImageOp;
  42. import java.awt.image.ImageObserver;
  43. import java.awt.image.RenderedImage;
  44.  
  45. import java.awt.image.renderable.RenderableImage;
  46.  
  47. public class ProxyGraphics2D extends Graphics2D implements PageContext {
  48.  
  49.     Graphics2D mGraphics;
  50.     PageContext mPageContext;
  51.  
  52.     /**
  53.      * The new ProxyGraphics2D will forward all graphics
  54.      * calls to 'graphics'.
  55.      */
  56.     public ProxyGraphics2D(Graphics2D graphics, PageContext pageContext) {
  57.     mGraphics = graphics;
  58.     mPageContext = pageContext;
  59.     }
  60.  
  61.     /**
  62.      * Return the Graphics2D object that does the drawing
  63.      * for this instance.
  64.      */
  65.     public Graphics2D getDelegate() {
  66.     return mGraphics;
  67.     }
  68.  
  69.     /**
  70.      * Set the Graphics2D instance which will do the
  71.      * drawing.
  72.      */
  73.     public void setDelegate(Graphics2D graphics) {
  74.     mGraphics = graphics;
  75.     }
  76.  
  77.     /**
  78.      * Return the format of the page being drawn.
  79.      */
  80.     public PageFormat getPageFormat() {
  81.     return mPageContext.getPageFormat();
  82.     }
  83.  
  84.     /**
  85.      * Get the object responsible for painting the page.
  86.      */
  87.     public Printable getPagePainter() {
  88.     return mPageContext.getPagePainter();
  89.     }
  90.  
  91.     /**
  92.      * Return the number of the page being drawn.
  93.      */
  94.     public int getPageIndex() {
  95.     return mPageContext.getPageIndex();
  96.     }
  97.  
  98.     /**
  99.      * Return the name of the page.
  100.      */
  101.     public String getPageName() {
  102.     return mPageContext.getPageName();
  103.     }
  104.  
  105.     /** Set the name of the page.
  106.      *
  107.  
  108.     public void setPageName(String pageName) {
  109.     mPageName = pageName;
  110.     }
  111.  
  112.     public void
  113.     /**
  114.      * Returns the device configuration associated with this Graphics2D.
  115.      */
  116.     public GraphicsConfiguration getDeviceConfiguration() {
  117.     // Need to do something here like copy the delegated config
  118.     // and then stamp it as a pritner config. For now we delegate
  119.     // but that's wrong.
  120.  
  121.     return mGraphics.getDeviceConfiguration();
  122.     }
  123.  
  124. /* The Delegated Graphics Methods */
  125.  
  126.     /**
  127.      * Creates a new <code>Graphics</code> object that is 
  128.      * a copy of this <code>Graphics</code> object.
  129.      * @return     a new graphics context that is a copy of 
  130.      *                       this graphics context.
  131.      * @since      JDK1.0
  132.      */
  133.     public Graphics create() {
  134.     return mGraphics.create();
  135.     }
  136.  
  137.     /**
  138.      * Translates the origin of the graphics context to the point
  139.      * (<i>x</i>, <i>y</i>) in the current coordinate system. 
  140.      * Modifies this graphics context so that its new origin corresponds 
  141.      * to the point (<i>x</i>, <i>y</i>) in this graphics context's 
  142.      * original coordinate system.  All coordinates used in subsequent 
  143.      * rendering operations on this graphics context will be relative 
  144.      * to this new origin.
  145.      * @param  x   the <i>x</i> coordinate.
  146.      * @param  y   the <i>y</i> coordinate.
  147.      * @since   JDK1.0
  148.      */
  149.     public void translate(int x, int y) {
  150.     mGraphics.translate(x, y);
  151.     }
  152.  
  153.     /**
  154.      * Concatenates the current transform of this Graphics2D with a
  155.      * translation transformation.
  156.      * This is equivalent to calling transform(T), where T is an
  157.      * AffineTransform represented by the following matrix:
  158.      * <pre>
  159.      *        [   1    0    tx  ]
  160.      *        [   0    1    ty  ]
  161.      *        [   0    0    1   ]
  162.      * </pre>
  163.      */
  164.     public void translate(double tx, double ty) {
  165.     mGraphics.translate(tx, ty);
  166.     }
  167.  
  168.     /**
  169.      * Concatenates the current transform of this Graphics2D with a
  170.      * rotation transformation.
  171.      * This is equivalent to calling transform(R), where R is an
  172.      * AffineTransform represented by the following matrix:
  173.      * <pre>
  174.      *        [   cos(theta)    -sin(theta)    0   ]
  175.      *        [   sin(theta)     cos(theta)    0   ]
  176.      *        [       0              0         1   ]
  177.      * </pre>
  178.      * Rotating with a positive angle theta rotates points on the positive
  179.      * x axis toward the positive y axis.
  180.      * @param theta The angle of rotation in radians.
  181.      */
  182.     public void rotate(double theta) {
  183.     mGraphics.rotate(theta);
  184.     }
  185.  
  186.     /**
  187.      * Concatenates the current transform of this Graphics2D with a
  188.      * translated rotation transformation.
  189.      * This is equivalent to the following sequence of calls:
  190.      * <pre>
  191.      *        translate(x, y);
  192.      *        rotate(theta);
  193.      *        translate(-x, -y);
  194.      * </pre>
  195.      * Rotating with a positive angle theta rotates points on the positive
  196.      * x axis toward the positive y axis.
  197.      * @param theta The angle of rotation in radians.
  198.      * @param x The x coordinate of the origin of the rotation
  199.      * @param y The x coordinate of the origin of the rotation
  200.      */
  201.     public void rotate(double theta, double x, double y) {
  202.     mGraphics.rotate(theta, x, y);
  203.     }
  204.  
  205.     /**
  206.      * Concatenates the current transform of this Graphics2D with a
  207.      * scaling transformation.
  208.      * This is equivalent to calling transform(S), where S is an
  209.      * AffineTransform represented by the following matrix:
  210.      * <pre>
  211.      *        [   sx   0    0   ]
  212.      *        [   0    sy   0   ]
  213.      *        [   0    0    1   ]
  214.      * </pre>
  215.      */
  216.     public void scale(double sx, double sy) {
  217.     mGraphics.scale(sx, sy);
  218.     }
  219.  
  220.     /**
  221.      * Concatenates the current transform of this Graphics2D with a
  222.      * shearing transformation.
  223.      * This is equivalent to calling transform(SH), where SH is an
  224.      * AffineTransform represented by the following matrix:
  225.      * <pre>
  226.      *        [   1   shx   0   ]
  227.      *        [  shy   1    0   ]
  228.      *        [   0    0    1   ]
  229.      * </pre>
  230.      * @param shx The factor by which coordinates are shifted towards the
  231.      * positive X axis direction according to their Y coordinate
  232.      * @param shy The factor by which coordinates are shifted towards the
  233.      * positive Y axis direction according to their X coordinate
  234.      */
  235.     public void shear(double shx, double shy) {
  236.     mGraphics.shear(shx, shy);
  237.     }
  238.  
  239.     /**
  240.      * Gets this graphics context's current color.
  241.      * @return    this graphics context's current color.
  242.      * @see       java.awt.Color
  243.      * @see       java.awt.Graphics#setColor
  244.      * @since     JDK1.0
  245.      */
  246.     public Color getColor() {
  247.     return mGraphics.getColor();
  248.     }
  249.  
  250.     /**
  251.      * Sets this graphics context's current color to the specified 
  252.      * color. All subsequent graphics operations using this graphics 
  253.      * context use this specified color. 
  254.      * @param     c   the new rendering color.
  255.      * @see       java.awt.Color
  256.      * @see       java.awt.Graphics#getColor
  257.      * @since     JDK1.0
  258.      */
  259.     public void setColor(Color c) {
  260.     mGraphics.setColor(c);
  261.     }
  262.  
  263.     /**
  264.      * Sets the paint mode of this graphics context to overwrite the 
  265.      * destination with this graphics context's current color. 
  266.      * This sets the logical pixel operation function to the paint or
  267.      * overwrite mode.  All subsequent rendering operations will
  268.      * overwrite the destination with the current color. 
  269.      * @since   JDK1.0
  270.      */
  271.     public void setPaintMode() {
  272.     mGraphics.setPaintMode();
  273.     }
  274.  
  275.     /**
  276.      * Sets the paint mode of this graphics context to alternate between 
  277.      * this graphics context's current color and the new specified color. 
  278.      * This specifies that logical pixel operations are performed in the 
  279.      * XOR mode, which alternates pixels between the current color and 
  280.      * a specified XOR color. 
  281.      * <p>
  282.      * When drawing operations are performed, pixels which are the 
  283.      * current color are changed to the specified color, and vice versa. 
  284.      * <p>
  285.      * Pixels that are of colors other than those two colors are changed 
  286.      * in an unpredictable but reversible manner; if the same figure is 
  287.      * drawn twice, then all pixels are restored to their original values. 
  288.      * @param     c1 the XOR alternation color
  289.      * @since     JDK1.0
  290.      */
  291.     public void setXORMode(Color c1) {
  292.     mGraphics.setXORMode(c1);
  293.     }
  294.  
  295.     /**
  296.      * Gets the current font.
  297.      * @return    this graphics context's current font.
  298.      * @see       java.awt.Font
  299.      * @see       java.awt.Graphics#setFont
  300.      * @since     JDK1.0
  301.      */
  302.     public Font getFont() {
  303.     return mGraphics.getFont();
  304.     }
  305.  
  306.     /**
  307.      * Sets this graphics context's font to the specified font. 
  308.      * All subsequent text operations using this graphics context 
  309.      * use this font. 
  310.      * @param  font   the font.
  311.      * @see     java.awt.Graphics#getFont
  312.      * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
  313.      * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
  314.      * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
  315.      * @since   JDK1.0
  316.     */
  317.     public void setFont(Font font) {
  318.     mGraphics.setFont(font);
  319.     }
  320.  
  321.     /**
  322.      * Gets the font metrics for the specified font.
  323.      * @return    the font metrics for the specified font.
  324.      * @param     f the specified font
  325.      * @see       java.awt.Graphics#getFont
  326.      * @see       java.awt.FontMetrics
  327.      * @see       java.awt.Graphics#getFontMetrics()
  328.      * @since     JDK1.0
  329.      */
  330.     public FontMetrics getFontMetrics(Font f) {
  331.     return mGraphics.getFontMetrics(f);
  332.     }
  333.  
  334.  
  335.     /**
  336.      * Returns the bounding rectangle of the current clipping area.
  337.      * The coordinates in the rectangle are relative to the coordinate
  338.      * system origin of this graphics context.
  339.      * @return      the bounding rectangle of the current clipping area.
  340.      * @see         java.awt.Graphics#getClip
  341.      * @see         java.awt.Graphics#clipRect
  342.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  343.      * @see         java.awt.Graphics#setClip(Shape)
  344.      * @since       JDK1.1
  345.      */
  346.     public Rectangle getClipBounds() {
  347.     return mGraphics.getClipBounds();
  348.     }
  349.  
  350.  
  351.     /** 
  352.      * Intersects the current clip with the specified rectangle.
  353.      * The resulting clipping area is the intersection of the current
  354.      * clipping area and the specified rectangle.
  355.      * This method can only be used to make the current clip smaller.
  356.      * To set the current clip larger, use any of the setClip methods.
  357.      * Rendering operations have no effect outside of the clipping area.
  358.      * @param x the x coordinate of the rectangle to intersect the clip with
  359.      * @param y the y coordinate of the rectangle to intersect the clip with
  360.      * @param width the width of the rectangle to intersect the clip with
  361.      * @param height the height of the rectangle to intersect the clip with
  362.      * @see #setClip(int, int, int, int)
  363.      * @see #setClip(Shape)
  364.      */
  365.     public void clipRect(int x, int y, int width, int height) {
  366.     mGraphics.clipRect(x, y, width, height);
  367.     }
  368.  
  369.  
  370.     /**
  371.      * Sets the current clip to the rectangle specified by the given
  372.      * coordinates.
  373.      * Rendering operations have no effect outside of the clipping area.
  374.      * @param       x the <i>x</i> coordinate of the new clip rectangle.
  375.      * @param       y the <i>y</i> coordinate of the new clip rectangle.
  376.      * @param       width the width of the new clip rectangle.
  377.      * @param       height the height of the new clip rectangle.
  378.      * @see         java.awt.Graphics#clipRect
  379.      * @see         java.awt.Graphics#setClip(Shape)
  380.      * @since       JDK1.1
  381.      */
  382.     public void setClip(int x, int y, int width, int height) {
  383.     mGraphics.setClip(x, y, width, height);
  384.     }
  385.  
  386.     /**
  387.      * Gets the current clipping area.
  388.      * @return      a <code>Shape</code> object representing the 
  389.      *                      current clipping area.
  390.      * @see         java.awt.Graphics#getClipBounds
  391.      * @see         java.awt.Graphics#clipRect
  392.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  393.      * @see         java.awt.Graphics#setClip(Shape)
  394.      * @since       JDK1.1
  395.      */
  396.     public Shape getClip() {
  397.     return mGraphics.getClip();
  398.     }
  399.  
  400.  
  401.     /**
  402.      * Sets the current clipping area to an arbitrary clip shape.
  403.      * Not all objects which implement the <code>Shape</code> 
  404.      * interface can be used to set the clip.  The only 
  405.      * <code>Shape</code> objects which are guaranteed to be 
  406.      * supported are <code>Shape</code> objects which are
  407.      * obtained via the <code>getClip</code> method and via 
  408.      * <code>Rectangle</code> objects.
  409.      * @see         java.awt.Graphics#getClip()
  410.      * @see         java.awt.Graphics#clipRect
  411.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  412.      * @since       JDK1.1
  413.      */
  414.     public void setClip(Shape clip) {
  415.     mGraphics.setClip(clip);
  416.     }
  417.  
  418.  
  419.     /**
  420.      * Copies an area of the component by a distance specified by 
  421.      * <code>dx</code> and <code>dy</code>. From the point specified
  422.      * by <code>x</code> and <code>y</code>, this method
  423.      * copies downwards and to the right.  To copy an area of the 
  424.      * component to the left or upwards, specify a negative value for 
  425.      * <code>dx</code> or <code>dy</code>.
  426.      * If a portion of the source rectangle lies outside the bounds 
  427.      * of the component, or is obscured by another window or component, 
  428.      * <code>copyArea</code> will be unable to copy the associated
  429.      * pixels. The area that is omitted can be refreshed by calling 
  430.      * the component's <code>paint</code> method.
  431.      * @param       x the <i>x</i> coordinate of the source rectangle.
  432.      * @param       y the <i>y</i> coordinate of the source rectangle.
  433.      * @param       width the width of the source rectangle.
  434.      * @param       height the height of the source rectangle.
  435.      * @param       dx the horizontal distance to copy the pixels.
  436.      * @param       dy the vertical distance to copy the pixels.
  437.      * @since       JDK1.0
  438.      */
  439.     public void copyArea(int x, int y, int width, int height,
  440.              int dx, int dy) {
  441.     mGraphics.copyArea(x, y, width, height, dx, dy);
  442.     }
  443.  
  444.     /** 
  445.      * Draws a line, using the current color, between the points 
  446.      * <code>(x1, y1)</code> and <code>(x2, y2)</code> 
  447.      * in this graphics context's coordinate system. 
  448.      * @param   x1  the first point's <i>x</i> coordinate.
  449.      * @param   y1  the first point's <i>y</i> coordinate.
  450.      * @param   x2  the second point's <i>x</i> coordinate.
  451.      * @param   y2  the second point's <i>y</i> coordinate.
  452.      * @since   JDK1.0
  453.      */
  454.     public void drawLine(int x1, int y1, int x2, int y2) {
  455.     mGraphics.drawLine(x1, y1, x2, y2);
  456.     }
  457.  
  458.  
  459.     /** 
  460.      * Fills the specified rectangle. 
  461.      * The left and right edges of the rectangle are at 
  462.      * <code>x</code> and <code>x + width - 1</code>. 
  463.      * The top and bottom edges are at 
  464.      * <code>y</code> and <code>y + height - 1</code>. 
  465.      * The resulting rectangle covers an area 
  466.      * <code>width</code> pixels wide by 
  467.      * <code>height</code> pixels tall.
  468.      * The rectangle is filled using the graphics context's current color. 
  469.      * @param         x   the <i>x</i> coordinate 
  470.      *                         of the rectangle to be filled.
  471.      * @param         y   the <i>y</i> coordinate 
  472.      *                         of the rectangle to be filled.
  473.      * @param         width   the width of the rectangle to be filled.
  474.      * @param         height   the height of the rectangle to be filled.
  475.      * @see           java.awt.Graphics#fillRect
  476.      * @see           java.awt.Graphics#clearRect
  477.      * @since         JDK1.0
  478.      */
  479.     public void fillRect(int x, int y, int width, int height) {
  480.     mGraphics.fillRect(x, y, width, height);
  481.     }
  482.  
  483.     /** 
  484.      * Clears the specified rectangle by filling it with the background
  485.      * color of the current drawing surface. This operation does not 
  486.      * use the current paint mode. 
  487.      * <p>
  488.      * Beginning with Java 1.1, the background color 
  489.      * of offscreen images may be system dependent. Applications should 
  490.      * use <code>setColor</code> followed by <code>fillRect</code> to 
  491.      * ensure that an offscreen image is cleared to a specific color. 
  492.      * @param       x the <i>x</i> coordinate of the rectangle to clear.
  493.      * @param       y the <i>y</i> coordinate of the rectangle to clear.
  494.      * @param       width the width of the rectangle to clear.
  495.      * @param       height the height of the rectangle to clear.
  496.      * @see         java.awt.Graphics#fillRect(int, int, int, int)
  497.      * @see         java.awt.Graphics#drawRect
  498.      * @see         java.awt.Graphics#setColor(java.awt.Color)
  499.      * @see         java.awt.Graphics#setPaintMode
  500.      * @see         java.awt.Graphics#setXORMode(java.awt.Color)
  501.      * @since       JDK1.0
  502.      */
  503.     public void clearRect(int x, int y, int width, int height) {
  504.     mGraphics.clearRect(x, y, width, height);
  505.     }
  506.  
  507.     /** 
  508.      * Draws an outlined round-cornered rectangle using this graphics 
  509.      * context's current color. The left and right edges of the rectangle 
  510.      * are at <code>x</code> and <code>x + width</code>, 
  511.      * respectively. The top and bottom edges of the rectangle are at 
  512.      * <code>y</code> and <code>y + height</code>. 
  513.      * @param      x the <i>x</i> coordinate of the rectangle to be drawn.
  514.      * @param      y the <i>y</i> coordinate of the rectangle to be drawn.
  515.      * @param      width the width of the rectangle to be drawn.
  516.      * @param      height the height of the rectangle to be drawn.
  517.      * @param      arcWidth the horizontal diameter of the arc 
  518.      *                    at the four corners.
  519.      * @param      arcHeight the vertical diameter of the arc 
  520.      *                    at the four corners.
  521.      * @see        java.awt.Graphics#fillRoundRect
  522.      * @since      JDK1.0
  523.      */
  524.     public void drawRoundRect(int x, int y, int width, int height,
  525.                   int arcWidth, int arcHeight) {
  526.     mGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
  527.     }
  528.  
  529.     /** 
  530.      * Fills the specified rounded corner rectangle with the current color.
  531.      * The left and right edges of the rectangle 
  532.      * are at <code>x</code> and <code>x + width - 1</code>, 
  533.      * respectively. The top and bottom edges of the rectangle are at 
  534.      * <code>y</code> and <code>y + height - 1</code>. 
  535.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  536.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  537.      * @param       width the width of the rectangle to be filled.
  538.      * @param       height the height of the rectangle to be filled.
  539.      * @param       arcWidth the horizontal diameter 
  540.      *                     of the arc at the four corners.
  541.      * @param       arcHeight the vertical diameter 
  542.      *                     of the arc at the four corners.
  543.      * @see         java.awt.Graphics#drawRoundRect
  544.      * @since       JDK1.0
  545.      */
  546.     public void fillRoundRect(int x, int y, int width, int height,
  547.                        int arcWidth, int arcHeight) {
  548.     mGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
  549.     }
  550.  
  551.     /** 
  552.      * Draws the outline of an oval.
  553.      * The result is a circle or ellipse that fits within the 
  554.      * rectangle specified by the <code>x</code>, <code>y</code>, 
  555.      * <code>width</code>, and <code>height</code> arguments. 
  556.      * <p> 
  557.      * The oval covers an area that is 
  558.      * <code>width + 1</code> pixels wide 
  559.      * and <code>height + 1<code> pixels tall. 
  560.      * @param       x the <i>x</i> coordinate of the upper left 
  561.      *                     corner of the oval to be drawn.
  562.      * @param       y the <i>y</i> coordinate of the upper left 
  563.      *                     corner of the oval to be drawn.
  564.      * @param       width the width of the oval to be drawn.
  565.      * @param       height the height of the oval to be drawn.
  566.      * @see         java.awt.Graphics#fillOval
  567.      * @since       JDK1.0
  568.      */
  569.     public void drawOval(int x, int y, int width, int height) {
  570.     mGraphics.drawOval(x, y, width, height);
  571.     }
  572.  
  573.     /** 
  574.      * Fills an oval bounded by the specified rectangle with the
  575.      * current color.
  576.      * @param       x the <i>x</i> coordinate of the upper left corner 
  577.      *                     of the oval to be filled.
  578.      * @param       y the <i>y</i> coordinate of the upper left corner 
  579.      *                     of the oval to be filled.
  580.      * @param       width the width of the oval to be filled.
  581.      * @param       height the height of the oval to be filled.
  582.      * @see         java.awt.Graphics#drawOval
  583.      * @since       JDK1.0
  584.      */
  585.     public void fillOval(int x, int y, int width, int height) {
  586.     mGraphics.fillOval(x, y, width, height);
  587.     }
  588.  
  589.     /**
  590.      * Draws the outline of a circular or elliptical arc 
  591.      * covering the specified rectangle.
  592.      * <p>
  593.      * The resulting arc begins at <code>startAngle</code> and extends  
  594.      * for <code>arcAngle</code> degrees, using the current color.
  595.      * Angles are interpreted such that 0 degrees 
  596.      * is at the 3 o'clock position. 
  597.      * A positive value indicates a counter-clockwise rotation
  598.      * while a negative value indicates a clockwise rotation.
  599.      * <p>
  600.      * The center of the arc is the center of the rectangle whose origin 
  601.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  602.      * <code>width</code> and <code>height</code> arguments. 
  603.      * <p>
  604.      * The resulting arc covers an area 
  605.      * <code>width + 1</code> pixels wide
  606.      * by <code>height + 1</code> pixels tall.
  607.      * @param        x the <i>x</i> coordinate of the 
  608.      *                    upper-left corner of the arc to be drawn.
  609.      * @param        y the <i>y</i>  coordinate of the 
  610.      *                    upper-left corner of the arc to be drawn.
  611.      * @param        width the width of the arc to be drawn.
  612.      * @param        height the height of the arc to be drawn.
  613.      * @param        startAngle the beginning angle.
  614.      * @param        arcAngle the angular extent of the arc, 
  615.      *                    relative to the start angle.
  616.      * @see         java.awt.Graphics#fillArc
  617.      * @since       JDK1.0
  618.      */
  619.     public void drawArc(int x, int y, int width, int height,
  620.                  int startAngle, int arcAngle) {
  621.     mGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
  622.     }
  623.  
  624.     /** 
  625.      * Fills a circular or elliptical arc covering the specified rectangle.
  626.      * <p>
  627.      * The resulting arc begins at <code>startAngle</code> and extends  
  628.      * for <code>arcAngle</code> degrees.
  629.      * Angles are interpreted such that 0 degrees 
  630.      * is at the 3 o'clock position. 
  631.      * A positive value indicates a counter-clockwise rotation
  632.      * while a negative value indicates a clockwise rotation.
  633.      * <p>
  634.      * The center of the arc is the center of the rectangle whose origin 
  635.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  636.      * <code>width</code> and <code>height</code> arguments. 
  637.      * <p>
  638.      * The resulting arc covers an area 
  639.      * <code>width + 1</code> pixels wide
  640.      * by <code>height + 1</code> pixels tall.
  641.      * @param        x the <i>x</i> coordinate of the 
  642.      *                    upper-left corner of the arc to be filled.
  643.      * @param        y the <i>y</i>  coordinate of the 
  644.      *                    upper-left corner of the arc to be filled.
  645.      * @param        width the width of the arc to be filled.
  646.      * @param        height the height of the arc to be filled.
  647.      * @param        startAngle the beginning angle.
  648.      * @param        arcAngle the angular extent of the arc, 
  649.      *                    relative to the start angle.
  650.      * @see         java.awt.Graphics#drawArc
  651.      * @since       JDK1.0
  652.      */
  653.     public void fillArc(int x, int y, int width, int height,
  654.             int startAngle, int arcAngle) {
  655.     mGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
  656.     }
  657.  
  658.     /** 
  659.      * Draws a sequence of connected lines defined by 
  660.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  661.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  662.      * The figure is not closed if the first point 
  663.      * differs from the last point.
  664.      * @param       xPoints an array of <i>x</i> points
  665.      * @param       yPoints an array of <i>y</i> points
  666.      * @param       nPoints the total number of points
  667.      * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
  668.      * @since       JDK1.1
  669.      */
  670.     public void drawPolyline(int xPoints[], int yPoints[],
  671.                  int nPoints) {
  672.     mGraphics.drawPolyline(xPoints, yPoints, nPoints);
  673.     }
  674.  
  675.     /** 
  676.      * Draws a closed polygon defined by 
  677.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  678.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  679.      * <p>
  680.      * This method draws the polygon defined by <code>nPoint</code> line 
  681.      * segments, where the first <code>nPoint - 1</code> 
  682.      * line segments are line segments from 
  683.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  684.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  685.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  686.      * The figure is automatically closed by drawing a line connecting
  687.      * the final point to the first point, if those points are different.
  688.      * @param        xPoints   a an array of <code>x</code> coordinates.
  689.      * @param        yPoints   a an array of <code>y</code> coordinates.
  690.      * @param        nPoints   a the total number of points.
  691.      * @see          java.awt.Graphics#fillPolygon
  692.      * @see          java.awt.Graphics#drawPolyline
  693.      * @since        JDK1.0
  694.      */
  695.     public void drawPolygon(int xPoints[], int yPoints[],
  696.                 int nPoints) {
  697.     mGraphics.drawPolygon(xPoints, yPoints, nPoints);
  698.     }
  699.  
  700.    /** 
  701.      * Fills a closed polygon defined by 
  702.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  703.      * <p>
  704.      * This method draws the polygon defined by <code>nPoint</code> line 
  705.      * segments, where the first <code>nPoint - 1</code> 
  706.      * line segments are line segments from 
  707.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  708.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  709.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  710.      * The figure is automatically closed by drawing a line connecting
  711.      * the final point to the first point, if those points are different.
  712.      * <p>
  713.      * The area inside the polygon is defined using an 
  714.      * even-odd fill rule, also known as the alternating rule.
  715.      * @param        xPoints   a an array of <code>x</code> coordinates.
  716.      * @param        yPoints   a an array of <code>y</code> coordinates.
  717.      * @param        nPoints   a the total number of points.
  718.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  719.      * @since        JDK1.0
  720.      */
  721.     public void fillPolygon(int xPoints[], int yPoints[],
  722.                 int nPoints) {
  723.     mGraphics.fillPolygon(xPoints, yPoints, nPoints);
  724.     }
  725.  
  726.     /** 
  727.      * Draws the text given by the specified string, using this 
  728.      * graphics context's current font and color. The baseline of the 
  729.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  730.      * graphics context's coordinate system. 
  731.      * @param       str      the string to be drawn.
  732.      * @param       x        the <i>x</i> coordinate.
  733.      * @param       y        the <i>y</i> coordinate.
  734.      * @see         java.awt.Graphics#drawBytes
  735.      * @see         java.awt.Graphics#drawChars
  736.      * @since       JDK1.0
  737.      */
  738.     public void drawString(String str, int x, int y) {
  739.  
  740.     /* Map this call to the StyleString draw as we can
  741.      * ask the StyledString for its bounds and see if
  742.      * that falls within the current clip. If hitString()
  743.      * were implemented we could use it here.
  744.      */
  745.     drawString(new StyledString(str, getFont()), x, y);
  746.  
  747.     }
  748.  
  749.    /** 
  750.      * Draws as much of the specified image as is currently available.
  751.      * The image is drawn with its top-left corner at 
  752.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  753.      * space. Transparent pixels in the image do not affect whatever 
  754.      * pixels are already there. 
  755.      * <p>
  756.      * This method returns immediately in all cases, even if the
  757.      * complete image has not yet been loaded, and it has not been dithered 
  758.      * and converted for the current output device.
  759.      * <p>
  760.      * If the image has not yet been completely loaded, then
  761.      * <code>drawImage</code> returns <code>false</code>. As more of
  762.      * the image becomes available, the process that draws the image notifies 
  763.      * the specified image observer.
  764.      * @param    img the specified image to be drawn.
  765.      * @param    x   the <i>x</i> coordinate.
  766.      * @param    y   the <i>y</i> coordinate.
  767.      * @param    observer    object to be notified as more of 
  768.      *                          the image is converted.
  769.      * @see      java.awt.Image
  770.      * @see      java.awt.image.ImageObserver
  771.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  772.      * @since    JDK1.0
  773.      */
  774.     public boolean drawImage(Image img, int x, int y, 
  775.                  ImageObserver observer) {
  776.  
  777.     return mGraphics.drawImage(img, x, y, observer);
  778.     }
  779.  
  780.     /**
  781.      * Draws as much of the specified image as has already been scaled
  782.      * to fit inside the specified rectangle.
  783.      * <p>
  784.      * The image is drawn inside the specified rectangle of this 
  785.      * graphics context's coordinate space, and is scaled if 
  786.      * necessary. Transparent pixels do not affect whatever pixels
  787.      * are already there. 
  788.      * <p>
  789.      * This method returns immediately in all cases, even if the
  790.      * entire image has not yet been scaled, dithered, and converted
  791.      * for the current output device.
  792.      * If the current output representation is not yet complete, then
  793.      * <code>drawImage</code> returns <code>false</code>. As more of
  794.      * the image becomes available, the process that draws the image notifies 
  795.      * the image observer by calling its <code>imageUpdate</code> method.
  796.      * <p>
  797.      * A scaled version of an image will not necessarily be
  798.      * available immediately just because an unscaled version of the
  799.      * image has been constructed for this output device.  Each size of
  800.      * the image may be cached separately and generated from the original
  801.      * data in a separate image production sequence.
  802.      * @param    img    the specified image to be drawn.
  803.      * @param    x      the <i>x</i> coordinate.
  804.      * @param    y      the <i>y</i> coordinate.
  805.      * @param    width  the width of the rectangle.
  806.      * @param    height the height of the rectangle.
  807.      * @param    observer    object to be notified as more of 
  808.      *                          the image is converted.
  809.      * @see      java.awt.Image
  810.      * @see      java.awt.image.ImageObserver
  811.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  812.      * @since    JDK1.0
  813.      */
  814.     public boolean drawImage(Image img, int x, int y,
  815.                  int width, int height, 
  816.                  ImageObserver observer) {
  817.  
  818.     return mGraphics.drawImage(img, x, y, width, height, observer);
  819.     }
  820.     
  821.     /** 
  822.      * Draws as much of the specified image as is currently available.
  823.      * The image is drawn with its top-left corner at 
  824.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  825.      * space.  Transparent pixels are drawn in the specified
  826.      * background color.
  827.      * <p> 
  828.      * This operation is equivalent to filling a rectangle of the
  829.      * width and height of the specified image with the given color and then
  830.      * drawing the image on top of it, but possibly more efficient.
  831.      * <p>
  832.      * This method returns immediately in all cases, even if the
  833.      * complete image has not yet been loaded, and it has not been dithered 
  834.      * and converted for the current output device.
  835.      * <p>
  836.      * If the image has not yet been completely loaded, then
  837.      * <code>drawImage</code> returns <code>false</code>. As more of
  838.      * the image becomes available, the process that draws the image notifies 
  839.      * the specified image observer.
  840.      * @param    img    the specified image to be drawn.
  841.      * @param    x      the <i>x</i> coordinate.
  842.      * @param    y      the <i>y</i> coordinate.
  843.      * @param    bgcolor the background color to paint under the
  844.      *                         non-opaque portions of the image.
  845.      * @param    observer    object to be notified as more of 
  846.      *                          the image is converted.
  847.      * @see      java.awt.Image
  848.      * @see      java.awt.image.ImageObserver
  849.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  850.      * @since    JDK1.0
  851.      */
  852.     public boolean drawImage(Image img, int x, int y, 
  853.                  Color bgcolor,
  854.                  ImageObserver observer) {
  855.  
  856.     return mGraphics.drawImage(img, x, y, bgcolor, observer);
  857.     }
  858.  
  859.     /**
  860.      * Draws as much of the specified image as has already been scaled
  861.      * to fit inside the specified rectangle.
  862.      * <p>
  863.      * The image is drawn inside the specified rectangle of this 
  864.      * graphics context's coordinate space, and is scaled if 
  865.      * necessary. Transparent pixels are drawn in the specified
  866.      * background color. 
  867.      * This operation is equivalent to filling a rectangle of the
  868.      * width and height of the specified image with the given color and then
  869.      * drawing the image on top of it, but possibly more efficient.
  870.      * <p>
  871.      * This method returns immediately in all cases, even if the
  872.      * entire image has not yet been scaled, dithered, and converted
  873.      * for the current output device.
  874.      * If the current output representation is not yet complete then
  875.      * <code>drawImage</code> returns <code>false</code>. As more of
  876.      * the image becomes available, the process that draws the image notifies 
  877.      * the specified image observer.
  878.      * <p>
  879.      * A scaled version of an image will not necessarily be
  880.      * available immediately just because an unscaled version of the
  881.      * image has been constructed for this output device.  Each size of
  882.      * the image may be cached separately and generated from the original
  883.      * data in a separate image production sequence.
  884.      * @param    img       the specified image to be drawn.
  885.      * @param    x         the <i>x</i> coordinate.
  886.      * @param    y         the <i>y</i> coordinate.
  887.      * @param    width     the width of the rectangle.
  888.      * @param    height    the height of the rectangle.
  889.      * @param    bgcolor   the background color to paint under the
  890.      *                         non-opaque portions of the image.
  891.      * @param    observer    object to be notified as more of 
  892.      *                          the image is converted.
  893.      * @see      java.awt.Image
  894.      * @see      java.awt.image.ImageObserver
  895.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  896.      * @since    JDK1.0
  897.      */
  898.     public boolean drawImage(Image img, int x, int y,
  899.                  int width, int height, 
  900.                  Color bgcolor,
  901.                  ImageObserver observer) {
  902.  
  903.     return mGraphics.drawImage(img, x, y, width, height,
  904.                        bgcolor, observer);
  905.     }
  906.     
  907.     /**
  908.      * Draws as much of the specified area of the specified image as is
  909.      * currently available, scaling it on the fly to fit inside the
  910.      * specified area of the destination drawable surface. Transparent pixels 
  911.      * do not affect whatever pixels are already there.
  912.      * <p>
  913.      * This method returns immediately in all cases, even if the
  914.      * image area to be drawn has not yet been scaled, dithered, and converted
  915.      * for the current output device.
  916.      * If the current output representation is not yet complete then
  917.      * <code>drawImage</code> returns <code>false</code>. As more of
  918.      * the image becomes available, the process that draws the image notifies 
  919.      * the specified image observer.
  920.      * <p>
  921.      * This method always uses the unscaled version of the image
  922.      * to render the scaled rectangle and performs the required
  923.      * scaling on the fly. It does not use a cached, scaled version
  924.      * of the image for this operation. Scaling of the image from source
  925.      * to destination is performed such that the first coordinate
  926.      * of the source rectangle is mapped to the first coordinate of
  927.      * the destination rectangle, and the second source coordinate is
  928.      * mapped to the second destination coordinate. The subimage is
  929.      * scaled and flipped as needed to preserve those mappings.
  930.      * @param       img the specified image to be drawn
  931.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  932.      *                    destination rectangle.
  933.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  934.      *                    destination rectangle.
  935.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  936.      *                    destination rectangle.
  937.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  938.      *                    destination rectangle.
  939.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  940.      *                    source rectangle.
  941.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  942.      *                    source rectangle.
  943.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  944.      *                    source rectangle.
  945.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  946.      *                    source rectangle.
  947.      * @param       observer object to be notified as more of the image is
  948.      *                    scaled and converted.
  949.      * @see         java.awt.Image
  950.      * @see         java.awt.image.ImageObserver
  951.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  952.      * @since       JDK1.1
  953.      */
  954.     public boolean drawImage(Image img,
  955.                       int dx1, int dy1, int dx2, int dy2,
  956.                       int sx1, int sy1, int sx2, int sy2,
  957.                       ImageObserver observer) {
  958.     return mGraphics.drawImage(img, dx1, dy1, dx2, dy2,
  959.                    sx1, sy1, sx2, sy2,
  960.                    observer);
  961.     }
  962.  
  963.     /**
  964.      * Draws as much of the specified area of the specified image as is
  965.      * currently available, scaling it on the fly to fit inside the
  966.      * specified area of the destination drawable surface. 
  967.      * <p>
  968.      * Transparent pixels are drawn in the specified background color. 
  969.      * This operation is equivalent to filling a rectangle of the
  970.      * width and height of the specified image with the given color and then
  971.      * drawing the image on top of it, but possibly more efficient.
  972.      * <p>
  973.      * This method returns immediately in all cases, even if the
  974.      * image area to be drawn has not yet been scaled, dithered, and converted
  975.      * for the current output device.
  976.      * If the current output representation is not yet complete then
  977.      * <code>drawImage</code> returns <code>false</code>. As more of
  978.      * the image becomes available, the process that draws the image notifies 
  979.      * the specified image observer.
  980.      * <p>
  981.      * This method always uses the unscaled version of the image
  982.      * to render the scaled rectangle and performs the required
  983.      * scaling on the fly. It does not use a cached, scaled version
  984.      * of the image for this operation. Scaling of the image from source
  985.      * to destination is performed such that the first coordinate
  986.      * of the source rectangle is mapped to the first coordinate of
  987.      * the destination rectangle, and the second source coordinate is
  988.      * mapped to the second destination coordinate. The subimage is
  989.      * scaled and flipped as needed to preserve those mappings.
  990.      * @param       img the specified image to be drawn
  991.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  992.      *                    destination rectangle.
  993.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  994.      *                    destination rectangle.
  995.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  996.      *                    destination rectangle.
  997.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  998.      *                    destination rectangle.
  999.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  1000.      *                    source rectangle.
  1001.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  1002.      *                    source rectangle.
  1003.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  1004.      *                    source rectangle.
  1005.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  1006.      *                    source rectangle.
  1007.      * @param       bgcolor the background color to paint under the
  1008.      *                    non-opaque portions of the image.
  1009.      * @param       observer object to be notified as more of the image is
  1010.      *                    scaled and converted.
  1011.      * @see         java.awt.Image
  1012.      * @see         java.awt.image.ImageObserver
  1013.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  1014.      * @since       JDK1.1
  1015.      */
  1016.     public boolean drawImage(Image img,
  1017.                  int dx1, int dy1, int dx2, int dy2,
  1018.                  int sx1, int sy1, int sx2, int sy2,
  1019.                  Color bgcolor,
  1020.                  ImageObserver observer) {
  1021.     return mGraphics.drawImage(img, dx1, sy1, sx2, sy2,
  1022.                    bgcolor, observer);
  1023.     }
  1024.  
  1025.     /**
  1026.      * Draws an image, applying a transform from image space into user space
  1027.      * before drawing.
  1028.      * The transformation from user space into device space is done with
  1029.      * the current transform in the Graphics2D.
  1030.      * The given transformation is applied to the image before the
  1031.      * transform attribute in the Graphics2D state is applied.
  1032.      * The rendering attributes applied include the clip, transform,
  1033.      * and composite attributes. Note that the result is
  1034.      * undefined, if the given transform is noninvertible.
  1035.      * @param img The image to be drawn.
  1036.      * @param xform The transformation from image space into user space.
  1037.      * @see #transform
  1038.      * @see #setTransform
  1039.      * @see #setComposite
  1040.      * @see #clip
  1041.      * @see #setClip
  1042.      */
  1043.     public void drawRenderedImage(RenderedImage img,
  1044.                   AffineTransform xform) {
  1045.         mGraphics.drawRenderedImage(img, xform);
  1046.     }
  1047.  
  1048.  
  1049.     public void drawRenderableImage(RenderableImage img,
  1050.                     AffineTransform xfrom,
  1051.                     Hashtable renderHints,
  1052.                     Hashtable renderHintsObserved) {
  1053.         mGraphics.drawRenderableImage(img, xfrom, renderHints,
  1054.                       renderHintsObserved);
  1055.     }
  1056.  
  1057.     /**
  1058.      * Disposes of this graphics context and releases 
  1059.      * any system resources that it is using. 
  1060.      * A <code>Graphics</code> object cannot be used after 
  1061.      * <code>dispose</code>has been called.
  1062.      * <p>
  1063.      * When a Java program runs, a large number of <code>Graphics</code>
  1064.      * objects can be created within a short time frame.
  1065.      * Although the finalization process of the garbage collector 
  1066.      * also disposes of the same system resources, it is preferable 
  1067.      * to manually free the associated resources by calling this
  1068.      * method rather than to rely on a finalization process which 
  1069.      * may not run to completion for a long period of time.
  1070.      * <p>
  1071.      * Graphics objects which are provided as arguments to the 
  1072.      * <code>paint</code> and <code>update</code> methods 
  1073.      * of components are automatically released by the system when 
  1074.      * those methods return. For efficiency, programmers should
  1075.      * call <code>dispose</code> when finished using
  1076.      * a <code>Graphics</code> object only if it was created 
  1077.      * directly from a component or another <code>Graphics</code> object.
  1078.      * @see         java.awt.Graphics#finalize
  1079.      * @see         java.awt.Component#paint
  1080.      * @see         java.awt.Component#update
  1081.      * @see         java.awt.Component#getGraphics
  1082.      * @see         java.awt.Graphics#create
  1083.      * @since       JDK1.0
  1084.      */
  1085.     public void dispose() {
  1086.     mGraphics.dispose();
  1087.     }
  1088.  
  1089.  
  1090. /* The Delegated Graphics2D Methods */
  1091.  
  1092.    /**
  1093.      * Strokes the outline of a Shape using the settings of the current
  1094.      * graphics state.  The rendering attributes applied include the
  1095.      * clip, transform, paint or color, composite and stroke attributes.
  1096.      * @param s The shape to be drawn.
  1097.      * @see #setStroke
  1098.      * @see #setPaint
  1099.      * @see java.awt.Graphics#setColor
  1100.      * @see #transform
  1101.      * @see #setTransform
  1102.      * @see #clip
  1103.      * @see #setClip
  1104.      * @see #setComposite
  1105.      */
  1106.     public void draw(Shape s) {
  1107.     mGraphics.draw(s);
  1108.     }
  1109.  
  1110.     /**
  1111.      * Draws an image, applying a transform from image space into user space
  1112.      * before drawing.
  1113.      * The transformation from user space into device space is done with
  1114.      * the current transform in the Graphics2D.
  1115.      * The given transformation is applied to the image before the
  1116.      * transform attribute in the Graphics2D state is applied.
  1117.      * The rendering attributes applied include the clip, transform,
  1118.      * and composite attributes. Note that the result is
  1119.      * undefined, if the given transform is noninvertible.
  1120.      * @param img The image to be drawn.
  1121.      * @param xform The transformation from image space into user space.
  1122.      * @param obs The image observer to be notified as more of the image
  1123.      * is converted.
  1124.      * @see #transform
  1125.      * @see #setTransform
  1126.      * @see #setComposite
  1127.      * @see #clip
  1128.      * @see #setClip
  1129.      */
  1130.     public void drawImage(Image img,
  1131.               AffineTransform xform,
  1132.               ImageObserver obs) {
  1133.  
  1134.     mGraphics.drawImage(img, xform, obs);    
  1135.     }
  1136.  
  1137.     /**
  1138.      * Draws a BufferedImage that is filtered with a BufferedImageOp.
  1139.      * The rendering attributes applied include the clip, transform
  1140.      * and composite attributes.  This is equivalent to:
  1141.      * <pre>
  1142.      * img1 = op.filter(img, null);
  1143.      * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
  1144.      * </pre>
  1145.      * @param op The filter to be applied to the image before drawing.
  1146.      * @param img The BufferedImage to be drawn.
  1147.      * @param x,y The location in user space where the image should be drawn.
  1148.      * @see #transform
  1149.      * @see #setTransform
  1150.      * @see #setComposite
  1151.      * @see #clip
  1152.      * @see #setClip
  1153.      */
  1154.     public void drawImage(BufferedImage img,
  1155.               BufferedImageOp op,
  1156.               int x,
  1157.               int y) {
  1158.  
  1159.     mGraphics.drawImage(img, op, x, y);
  1160.     }
  1161.  
  1162.  
  1163.     /**
  1164.      * Draws a string of text.
  1165.      * The rendering attributes applied include the clip, transform,
  1166.      * paint or color, font and composite attributes.
  1167.      * @param s The string to be drawn.
  1168.      * @param x,y The coordinates where the string should be drawn.
  1169.      * @see #setPaint
  1170.      * @see java.awt.Graphics#setColor
  1171.      * @see java.awt.Graphics#setFont
  1172.      * @see #transform
  1173.      * @see #setTransform
  1174.      * @see #setComposite
  1175.      * @see #clip
  1176.      * @see #setClip
  1177.      */
  1178.     public void drawString(String s,
  1179.                float x,
  1180.                float y) {
  1181.  
  1182.     /* Map this call to the StyleString draw as we can
  1183.      * ask the StyledString for its bounds and see if
  1184.      * that falls within the current clip. If hitString()
  1185.      * were implemented we could use it here.
  1186.      */
  1187.     drawString(new StyledString(s, getFont()), x, y);
  1188.     }
  1189.  
  1190.  
  1191.     /**
  1192.      * Draws a StyledString.
  1193.      * The rendering attributes applied include the clip, transform,
  1194.      * paint or color, and composite attributes.  A Font is associated
  1195.      * with each character in the StyledString.
  1196.      * @param s The StyledString to be drawn.
  1197.      * @param x,y The coordinates where the StyledString should be drawn.
  1198.      * @see #setPaint
  1199.      * @see java.awt.Graphics#setColor
  1200.      * @see #transform
  1201.      * @see #setTransform
  1202.      * @see #setComposite
  1203.      * @see #clip
  1204.      * @see #setClip
  1205.      * @see Font
  1206.      */
  1207.     public void drawString(StyledString s,
  1208.                float x,
  1209.                float y) {
  1210.  
  1211.     /* If the bounding rectangle of the strings intersects
  1212.      * the clip then we'll draw it. This improves performance
  1213.      * by a factor of four.
  1214.      */
  1215.     Rectangle2D clip = getClipBounds();
  1216.     Rectangle2D stringBounds = s.getBounds2D();
  1217.     stringBounds.setRect(x, y - s.getAscent(),
  1218.                  stringBounds.getWidth(),
  1219.                  stringBounds.getHeight());
  1220.  
  1221.     if (clip.intersects(stringBounds)) {
  1222.         mGraphics.drawString(s, x, y);
  1223.     }
  1224.  
  1225.  
  1226.     }
  1227.  
  1228.     /**
  1229.      * Draws a GlyphSet.
  1230.      * The rendering attributes applied include the clip, transform,
  1231.      * paint or color, and composite attributes.  The glyphSet specifies
  1232.      * individual glyphs from a Font.
  1233.      * @param g The GlyphSet to be drawn.
  1234.      * @param x,y The coordinates where the glyphs should be drawn.
  1235.      * @see #setPaint
  1236.      * @see java.awt.Graphics#setColor
  1237.      * @see #transform
  1238.      * @see #setTransform
  1239.      * @see #setComposite
  1240.      * @see #clip
  1241.      * @see #setClip
  1242.      */
  1243.     public void drawString(GlyphSet g,
  1244.                float x,
  1245.                float y) {
  1246.  
  1247.     mGraphics.drawString(g, x, y);
  1248.     }
  1249.  
  1250.     public void drawString(TextLayout text, float x, float y) {
  1251.     mGraphics.drawString(text, x, y);
  1252.     }
  1253.  
  1254.     /**
  1255.      * Fills the interior of a Shape using the settings of the current
  1256.      * graphics state. The rendering attributes applied include the
  1257.      * clip, transform, paint or color, and composite.
  1258.      * @see #setPaint
  1259.      * @see java.awt.Graphics#setColor
  1260.      * @see #transform
  1261.      * @see #setTransform
  1262.      * @see #setComposite
  1263.      * @see #clip
  1264.      * @see #setClip
  1265.      */
  1266.     public void fill(Shape s) {
  1267.     mGraphics.fill(s);
  1268.     }
  1269.  
  1270.     /**
  1271.      * Checks to see if the outline of a Shape intersects the specified
  1272.      * Rectangle in device space.
  1273.      * The rendering attributes taken into account include the
  1274.      * clip, transform, and stroke attributes.
  1275.      * @param rect The area in device space to check for a hit.
  1276.      * @param s The shape to check for a hit.
  1277.      * @param onStroke Flag to choose between testing the stroked or
  1278.      * the filled shape.
  1279.      * @return True if there is a hit, false otherwise.
  1280.      * @see #setStroke
  1281.      * @see #fill
  1282.      * @see #draw
  1283.      * @see #transform
  1284.      * @see #setTransform
  1285.      * @see #clip
  1286.      * @see #setClip
  1287.      */
  1288.     public boolean hit(Rectangle rect,
  1289.                Shape s,
  1290.                boolean onStroke) {
  1291.  
  1292.     return mGraphics.hit(rect, s, onStroke);
  1293.     }
  1294.  
  1295.     /**
  1296.      * Checks to see if the StyledString intersects the specified Rectangle
  1297.      * in device space.
  1298.      * The rendering attributes taken into account include the clip
  1299.      * and transform.
  1300.      * @param rect The area in device space to check for a hit.
  1301.      * @param s The StyledString to check for a hit.
  1302.      * @param x,y The coordinates where the StyledString should be
  1303.      * hit tested.
  1304.      * @return True if there is a hit, false otherwise.
  1305.      * @see #drawString(StyledString, float, float)
  1306.      * @see #transform
  1307.      * @see #setTransform
  1308.      * @see #clip
  1309.      * @see #setClip
  1310.      */
  1311.     public boolean hitString(Rectangle rect,
  1312.                  StyledString s,
  1313.                              float x,
  1314.                              float y) {
  1315.  
  1316.     return mGraphics.hitString(rect, s, x, y);
  1317.     }
  1318.  
  1319.  
  1320.  
  1321.  
  1322.     /**
  1323.      * Sets the Composite in the current graphics state. Composite is used
  1324.      * in all drawing methods such as drawImage, drawString, draw,
  1325.      * and fill.  It specifies how new pixels are to be combined with
  1326.      * the existing pixels on the graphics device in the rendering process.
  1327.      * @param comp The Composite object to be used for drawing.
  1328.      * @see java.awt.Graphics#setXORMode
  1329.      * @see java.awt.Graphics#setPaintMode
  1330.      * @see AlphaComposite
  1331.      */
  1332.     public void setComposite(Composite comp) {
  1333.     mGraphics.setComposite(comp); 
  1334.     }
  1335.  
  1336.  
  1337.     /**
  1338.      * Sets the Paint in the current graphics state.
  1339.      * @param paint The Paint object to be used to generate color in
  1340.      * the rendering process.
  1341.      * @see java.awt.Graphics#setColor
  1342.      * @see GradientPaint
  1343.      * @see TexturePaint
  1344.      */
  1345.     public void setPaint(Paint paint) {
  1346.     mGraphics.setPaint(paint);
  1347.     }
  1348.  
  1349.     /**
  1350.      * Sets the Stroke in the current graphics state.
  1351.      * @param s The Stroke object to be used to stroke a Shape in
  1352.      * the rendering process.
  1353.      * @see BasicStroke
  1354.      */
  1355.     public void setStroke(Stroke s) {
  1356.     mGraphics.setStroke(s);
  1357.     }
  1358.  
  1359.     /**
  1360.      * Sets the preferences for the rendering algorithms.
  1361.      * Hint categories include controls for rendering quality and
  1362.      * overall time/quality trade-off in the rendering process.
  1363.      * @param hintCategory The category of hint to be set. Possible values
  1364.      * are ANTIALIASING and RENDERING.
  1365.      * @param hintValue The value indicating preferences for the specified
  1366.      * hint category. Possible values for the ANTIALIASING category are
  1367.      * ANTIALIAS_ON, ANTIALIAS_OFF, ANTIALIAS_DEFAULT. Possible values for
  1368.      * the RENDERING hint are RENDER_SPEED, RENDER_QUALITY, RENDER_DEFAULT.
  1369.      * @see #ANTIALIASING
  1370.      * @see #RENDERING
  1371.      * @see #ANTIALIAS_ON
  1372.      * @see #ANTIALIAS_OFF
  1373.      * @see #ANTIALIAS_DEFAULT
  1374.      * @see #RENDER_SPEED
  1375.      * @see #RENDER_QUALITY
  1376.      * @see #RENDER_DEFAULT
  1377.      */
  1378.     public void setRenderingHints(int hintCategory, int hintValue) {
  1379.     mGraphics.setRenderingHints(hintCategory, hintValue);
  1380.     }
  1381.  
  1382.     /**
  1383.      * Returns the preferences for the rendering algorithms.
  1384.      * @param hintCategory The category of hint to be set. Possible values
  1385.      * are ANTIALIASING and RENDERING.
  1386.      * @return The preferences for rendering algorithms. Possible values for
  1387.      * the ANTIALIASING category are ANTIALIAS_ON, ANTIALIAS_OFF,
  1388.      * ANTIALIAS_DEFAULT.  Possible values for the RENDERING hint are
  1389.      * RENDER_SPEED, RENDER_QUALITY, RENDER_DEFAULT.
  1390.      * @see #ANTIALIASING
  1391.      * @see #RENDERING
  1392.      * @see #ANTIALIAS_ON
  1393.      * @see #ANTIALIAS_OFF
  1394.      * @see #ANTIALIAS_DEFAULT
  1395.      * @see #RENDER_SPEED
  1396.      * @see #RENDER_QUALITY
  1397.      * @see #RENDER_DEFAULT
  1398.      */
  1399.     public int getRenderingHints(int hintCategory) {
  1400.     return mGraphics.getRenderingHints(hintCategory);
  1401.     }
  1402.  
  1403.     /**
  1404.      * Composes a Transform object with the transform in this
  1405.      * Graphics2D according to the rule last-specified-first-applied.
  1406.      * If the currrent transform is Cx, the result of composition
  1407.      * with Tx is a new transform Cx'.  Cx' becomes the current
  1408.      * transform for this Graphics2D.
  1409.      * Transforming a point p by the updated transform Cx' is
  1410.      * equivalent to first transforming p by Tx and then transforming
  1411.      * the result by the original transform Cx.  In other words,
  1412.      * Cx'(p) = Cx(Tx(p)).
  1413.      * A copy of the Tx is made, if necessary, so further
  1414.      * modifications to Tx do not affect rendering.
  1415.      * @param Tx The Transform object to be composed with the current
  1416.      * transform.
  1417.      * @see #setTransform
  1418.      * @see TransformChain
  1419.      * @see AffineTransform
  1420.      */
  1421.     public void transform(AffineTransform Tx) {
  1422.     mGraphics.transform(Tx);
  1423.     }
  1424.  
  1425.     /**
  1426.      * Sets the Transform in the current graphics state.
  1427.      * @param Tx The Transform object to be used in the rendering process.
  1428.      * @see #transform
  1429.      * @see TransformChain
  1430.      * @see AffineTransform
  1431.      */
  1432.     public void setTransform(AffineTransform Tx) {
  1433.     mGraphics.setTransform(Tx);
  1434.     }
  1435.  
  1436.     /**
  1437.      * Returns the current Transform in the Graphics2D state.
  1438.      * @see #transform
  1439.      * @see #setTransform
  1440.      */
  1441.     public AffineTransform getTransform() {
  1442.     return mGraphics.getTransform();
  1443.     }
  1444.  
  1445.     /**
  1446.      * Returns the current Paint in the Graphics2D state.
  1447.      * @see #setPaint
  1448.      * @see java.awt.Graphics#setColor
  1449.      */
  1450.     public Paint getPaint() {
  1451.     return mGraphics.getPaint();
  1452.     }
  1453.  
  1454.     /**
  1455.      * Returns the current Composite in the Graphics2D state.
  1456.      * @see #setComposite
  1457.      */
  1458.     public Composite getComposite() {
  1459.     return mGraphics.getComposite();
  1460.     }
  1461.  
  1462.     /**
  1463.      * Sets the background color in this context used for clearing a region.
  1464.      * When Graphics2D is constructed for a component, the backgroung color is
  1465.      * inherited from the component. Setting the background color in the
  1466.      * Graphics2D context only affects the subsequent clearRect() calls and
  1467.      * not the background color of the component. To change the background
  1468.      * of the component, use appropriate methods of the component.
  1469.      * @param color The background color that should be used in
  1470.      * subsequent calls to clearRect().
  1471.      * @see getBackground
  1472.      * @see Graphics.clearRect()
  1473.      */
  1474.     public void setBackground(Color color) {
  1475.     mGraphics.setBackground(color);
  1476.     }
  1477.  
  1478.     /**
  1479.      * Returns the background color used for clearing a region.
  1480.      * @see setBackground
  1481.      */
  1482.     public Color getBackground() {
  1483.     return mGraphics.getBackground();
  1484.     }
  1485.  
  1486.     /**
  1487.      * Returns the current Stroke in the Graphics2D state.
  1488.      * @see setStroke
  1489.      */
  1490.     public Stroke getStroke() {
  1491.     return mGraphics.getStroke();
  1492.     }
  1493.  
  1494.     /**
  1495.      * Intersects the current clip with the interior of the specified Shape
  1496.      * and sets the current clip to the resulting intersection.
  1497.      * The indicated shape is transformed with the current transform in the
  1498.      * Graphics2D state before being intersected with the current clip.
  1499.      * This method is used to make the current clip smaller.
  1500.      * To make the clip larger, use any setClip method.
  1501.      * @param s The Shape to be intersected with the current clip.
  1502.      */
  1503.      public void clip(Shape s) {
  1504.     mGraphics.clip(s);
  1505.      }
  1506.  
  1507.  
  1508. }
  1509.