1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
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>, <i>y</i>).
143 * That is to say, the point (<code>0</code>, <code>0</code>) in the
144 * new graphics context is the same as (<i>x</i>, <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>, <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>, <i>y</i>) in the current coordinate system.
174 * Modifies this graphics context so that its new origin corresponds
|
1 /*
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
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>, <i>y</i>).
143 * That is to say, the point (<code>0</code>, <code>0</code>) in the
144 * new graphics context is the same as (<i>x</i>, <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>, <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>, <i>y</i>) in the current coordinate system.
174 * Modifies this graphics context so that its new origin corresponds
|