1 /*
2 * Copyright (c) 2010, 2017, 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
89 int transY2 = Region.clipAdd(y2, sg2d.transY);
90
91 SunToolkit.awtLock();
92 try {
93 validateSurface(sg2d);
94 lineGen.rasterizeLine(rectBuffer, transX1, transY1,
95 transX2, transY2, compClip.getLoX(), compClip.getLoY(),
96 compClip.getHiX(), compClip.getHiY(), true, true);
97 tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
98 } finally {
99 SunToolkit.awtUnlock();
100 }
101 }
102
103 public void drawRect(SunGraphics2D sg2d,
104 int x, int y, int width, int height) {
105 draw(sg2d, new Rectangle2D.Float(x, y, width, height));
106 }
107
108 public void drawPolyline(SunGraphics2D sg2d,
109 int xpoints[], int ypoints[], int npoints) {
110 Path2D.Float p2d = new Path2D.Float();
111 if (npoints > 1) {
112 p2d.moveTo(xpoints[0], ypoints[0]);
113 for (int i = 1; i < npoints; i++) {
114 p2d.lineTo(xpoints[i], ypoints[i]);
115 }
116 }
117
118 draw(sg2d, p2d);
119 }
120
121 public void drawPolygon(SunGraphics2D sg2d,
122 int xpoints[], int ypoints[], int npoints) {
123 draw(sg2d, new Polygon(xpoints, ypoints, npoints));
124 }
125
126 public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) {
127 x = Region.clipAdd(x, sg2d.transX);
128 y = Region.clipAdd(y, sg2d.transY);
129
130 /*
131 * Limit x/y to signed short, width/height to unsigned short,
132 * to match the X11 coordinate limits for rectangles.
133 * Correct width/height in case x/y have been modified by clipping.
134 */
135 if (x > Short.MAX_VALUE || y > Short.MAX_VALUE) {
136 return;
137 }
138
139 int x2 = Region.dimAdd(x, width);
140 int y2 = Region.dimAdd(y, height);
141
142 if (x2 < Short.MIN_VALUE || y2 < Short.MIN_VALUE) {
146 x = clampToShort(x);
147 y = clampToShort(y);
148 width = clampToUShort(x2 - x);
149 height = clampToUShort(y2 - y);
150
151 if (width == 0 || height == 0) {
152 return;
153 }
154
155 SunToolkit.awtLock();
156 try {
157 validateSurface(sg2d);
158 rectBuffer.pushRectValues(x, y, width, height);
159 tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
160 } finally {
161 SunToolkit.awtUnlock();
162 }
163 }
164
165 public void fillPolygon(SunGraphics2D sg2d,
166 int xpoints[], int ypoints[], int npoints) {
167 fill(sg2d, new Polygon(xpoints, ypoints, npoints));
168 }
169
170 public void drawRoundRect(SunGraphics2D sg2d,
171 int x, int y, int width, int height,
172 int arcWidth, int arcHeight) {
173 draw(sg2d, new RoundRectangle2D.Float(x, y, width, height,
174 arcWidth, arcHeight));
175 }
176
177 public void fillRoundRect(SunGraphics2D sg2d, int x, int y,
178 int width, int height,
179 int arcWidth, int arcHeight) {
180 fill(sg2d, new RoundRectangle2D.Float(x, y, width, height,
181 arcWidth, arcHeight));
182 }
183
184 public void drawOval(SunGraphics2D sg2d,
185 int x, int y, int width, int height) {
186 draw(sg2d, new Ellipse2D.Float(x, y, width, height));
|
1 /*
2 * Copyright (c) 2010, 2018, 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
89 int transY2 = Region.clipAdd(y2, sg2d.transY);
90
91 SunToolkit.awtLock();
92 try {
93 validateSurface(sg2d);
94 lineGen.rasterizeLine(rectBuffer, transX1, transY1,
95 transX2, transY2, compClip.getLoX(), compClip.getLoY(),
96 compClip.getHiX(), compClip.getHiY(), true, true);
97 tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
98 } finally {
99 SunToolkit.awtUnlock();
100 }
101 }
102
103 public void drawRect(SunGraphics2D sg2d,
104 int x, int y, int width, int height) {
105 draw(sg2d, new Rectangle2D.Float(x, y, width, height));
106 }
107
108 public void drawPolyline(SunGraphics2D sg2d,
109 int[] xpoints, int[] ypoints, int npoints) {
110 Path2D.Float p2d = new Path2D.Float();
111 if (npoints > 1) {
112 p2d.moveTo(xpoints[0], ypoints[0]);
113 for (int i = 1; i < npoints; i++) {
114 p2d.lineTo(xpoints[i], ypoints[i]);
115 }
116 }
117
118 draw(sg2d, p2d);
119 }
120
121 public void drawPolygon(SunGraphics2D sg2d,
122 int[] xpoints, int[] ypoints, int npoints) {
123 draw(sg2d, new Polygon(xpoints, ypoints, npoints));
124 }
125
126 public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) {
127 x = Region.clipAdd(x, sg2d.transX);
128 y = Region.clipAdd(y, sg2d.transY);
129
130 /*
131 * Limit x/y to signed short, width/height to unsigned short,
132 * to match the X11 coordinate limits for rectangles.
133 * Correct width/height in case x/y have been modified by clipping.
134 */
135 if (x > Short.MAX_VALUE || y > Short.MAX_VALUE) {
136 return;
137 }
138
139 int x2 = Region.dimAdd(x, width);
140 int y2 = Region.dimAdd(y, height);
141
142 if (x2 < Short.MIN_VALUE || y2 < Short.MIN_VALUE) {
146 x = clampToShort(x);
147 y = clampToShort(y);
148 width = clampToUShort(x2 - x);
149 height = clampToUShort(y2 - y);
150
151 if (width == 0 || height == 0) {
152 return;
153 }
154
155 SunToolkit.awtLock();
156 try {
157 validateSurface(sg2d);
158 rectBuffer.pushRectValues(x, y, width, height);
159 tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
160 } finally {
161 SunToolkit.awtUnlock();
162 }
163 }
164
165 public void fillPolygon(SunGraphics2D sg2d,
166 int[] xpoints, int[] ypoints, int npoints) {
167 fill(sg2d, new Polygon(xpoints, ypoints, npoints));
168 }
169
170 public void drawRoundRect(SunGraphics2D sg2d,
171 int x, int y, int width, int height,
172 int arcWidth, int arcHeight) {
173 draw(sg2d, new RoundRectangle2D.Float(x, y, width, height,
174 arcWidth, arcHeight));
175 }
176
177 public void fillRoundRect(SunGraphics2D sg2d, int x, int y,
178 int width, int height,
179 int arcWidth, int arcHeight) {
180 fill(sg2d, new RoundRectangle2D.Float(x, y, width, height,
181 arcWidth, arcHeight));
182 }
183
184 public void drawOval(SunGraphics2D sg2d,
185 int x, int y, int width, int height) {
186 draw(sg2d, new Ellipse2D.Float(x, y, width, height));
|