src/share/classes/java/awt/Graphics.java

Print this page




 134      * Its clip area is determined by the intersection of the original
 135      * clip area with the specified rectangle.  The arguments are all
 136      * interpreted in the coordinate system of the original
 137      * <code>Graphics</code> object. The new graphics context is
 138      * identical to the original, except in two respects:
 139      *
 140      * <ul>
 141      * <li>
 142      * The new graphics context is translated by (<i>x</i>,&nbsp;<i>y</i>).
 143      * That is to say, the point (<code>0</code>,&nbsp;<code>0</code>) in the
 144      * new graphics context is the same as (<i>x</i>,&nbsp;<i>y</i>) in
 145      * the original graphics context.
 146      * <li>
 147      * The new graphics context has an additional clipping rectangle, in
 148      * addition to whatever (translated) clipping rectangle it inherited
 149      * from the original graphics context. The origin of the new clipping
 150      * rectangle is at (<code>0</code>,&nbsp;<code>0</code>), and its size
 151      * is specified by the <code>width</code> and <code>height</code>
 152      * arguments.
 153      * </ul>
 154      * <p>
 155      * @param      x   the <i>x</i> coordinate.
 156      * @param      y   the <i>y</i> coordinate.
 157      * @param      width   the width of the clipping rectangle.
 158      * @param      height   the height of the clipping rectangle.
 159      * @return     a new graphics context.
 160      * @see        java.awt.Graphics#translate
 161      * @see        java.awt.Graphics#clipRect
 162      */
 163     public Graphics create(int x, int y, int width, int height) {
 164         Graphics g = create();
 165         if (g == null) return null;
 166         g.translate(x, y);
 167         g.clipRect(0, 0, width, height);
 168         return g;
 169     }
 170 
 171     /**
 172      * Translates the origin of the graphics context to the point
 173      * (<i>x</i>,&nbsp;<i>y</i>) in the current coordinate system.
 174      * Modifies this graphics context so that its new origin corresponds




 134      * Its clip area is determined by the intersection of the original
 135      * clip area with the specified rectangle.  The arguments are all
 136      * interpreted in the coordinate system of the original
 137      * <code>Graphics</code> object. The new graphics context is
 138      * identical to the original, except in two respects:
 139      *
 140      * <ul>
 141      * <li>
 142      * The new graphics context is translated by (<i>x</i>,&nbsp;<i>y</i>).
 143      * That is to say, the point (<code>0</code>,&nbsp;<code>0</code>) in the
 144      * new graphics context is the same as (<i>x</i>,&nbsp;<i>y</i>) in
 145      * the original graphics context.
 146      * <li>
 147      * The new graphics context has an additional clipping rectangle, in
 148      * addition to whatever (translated) clipping rectangle it inherited
 149      * from the original graphics context. The origin of the new clipping
 150      * rectangle is at (<code>0</code>,&nbsp;<code>0</code>), and its size
 151      * is specified by the <code>width</code> and <code>height</code>
 152      * arguments.
 153      * </ul>
 154      *
 155      * @param      x   the <i>x</i> coordinate.
 156      * @param      y   the <i>y</i> coordinate.
 157      * @param      width   the width of the clipping rectangle.
 158      * @param      height   the height of the clipping rectangle.
 159      * @return     a new graphics context.
 160      * @see        java.awt.Graphics#translate
 161      * @see        java.awt.Graphics#clipRect
 162      */
 163     public Graphics create(int x, int y, int width, int height) {
 164         Graphics g = create();
 165         if (g == null) return null;
 166         g.translate(x, y);
 167         g.clipRect(0, 0, width, height);
 168         return g;
 169     }
 170 
 171     /**
 172      * Translates the origin of the graphics context to the point
 173      * (<i>x</i>,&nbsp;<i>y</i>) in the current coordinate system.
 174      * Modifies this graphics context so that its new origin corresponds