1 /*
2 * Copyright (c) 1999, 2016, 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
75 new RoundRectangle2D.Float(x, y, width, height,
76 arcWidth, arcHeight));
77 }
78
79 public void drawOval(SunGraphics2D sg2d,
80 int x, int y, int width, int height)
81 {
82 sg2d.shapepipe.draw(sg2d, new Ellipse2D.Float(x, y, width, height));
83 }
84
85 public void drawArc(SunGraphics2D sg2d,
86 int x, int y, int width, int height,
87 int startAngle, int arcAngle)
88 {
89 sg2d.shapepipe.draw(sg2d, new Arc2D.Float(x, y, width, height,
90 startAngle, arcAngle,
91 Arc2D.OPEN));
92 }
93
94 public void drawPolyline(SunGraphics2D sg2d,
95 int xPoints[], int yPoints[],
96 int nPoints)
97 {
98 int nPointsArray[] = { nPoints };
99 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
100 xPoints, yPoints,
101 nPointsArray, 1,
102 sg2d.transX, sg2d.transY,
103 false);
104 }
105
106 public void drawPolygon(SunGraphics2D sg2d,
107 int xPoints[], int yPoints[],
108 int nPoints)
109 {
110 int nPointsArray[] = { nPoints };
111 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
112 xPoints, yPoints,
113 nPointsArray, 1,
114 sg2d.transX, sg2d.transY,
115 true);
116 }
117
118 public void fillRect(SunGraphics2D sg2d,
119 int x, int y, int width, int height)
120 {
121 sg2d.loops.fillRectLoop.FillRect(sg2d, sg2d.getSurfaceData(),
122 x + sg2d.transX,
123 y + sg2d.transY,
124 width, height);
125 }
126
127 public void fillRoundRect(SunGraphics2D sg2d,
128 int x, int y, int width, int height,
129 int arcWidth, int arcHeight)
130 {
132 new RoundRectangle2D.Float(x, y, width, height,
133 arcWidth, arcHeight));
134 }
135
136 public void fillOval(SunGraphics2D sg2d,
137 int x, int y, int width, int height)
138 {
139 sg2d.shapepipe.fill(sg2d, new Ellipse2D.Float(x, y, width, height));
140 }
141
142 public void fillArc(SunGraphics2D sg2d,
143 int x, int y, int width, int height,
144 int startAngle, int arcAngle)
145 {
146 sg2d.shapepipe.fill(sg2d, new Arc2D.Float(x, y, width, height,
147 startAngle, arcAngle,
148 Arc2D.PIE));
149 }
150
151 public void fillPolygon(SunGraphics2D sg2d,
152 int xPoints[], int yPoints[],
153 int nPoints)
154 {
155 ShapeSpanIterator sr = getFillSSI(sg2d);
156
157 try {
158 sr.setOutputArea(sg2d.getCompClip());
159 sr.appendPoly(xPoints, yPoints, nPoints, sg2d.transX, sg2d.transY);
160 fillSpans(sg2d, sr);
161 } finally {
162 sr.dispose();
163 }
164 }
165
166
167 public void draw(SunGraphics2D sg2d, Shape s) {
168 if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
169 Path2D.Float p2df;
170 int transX;
171 int transY;
172 if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
316 } finally {
317 sr.dispose();
318 }
319 }
320
321 private static void fillSpans(SunGraphics2D sg2d, SpanIterator si) {
322 // REMIND: Eventually, the plan is that it will not be possible for
323 // fs to be null since the FillSpans loop will be the fundamental
324 // loop implemented for any destination type...
325 if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
326 si = sg2d.clipRegion.filter(si);
327 // REMIND: Region.filter produces a Java-only iterator
328 // with no native counterpart...
329 } else {
330 sun.java2d.loops.FillSpans fs = sg2d.loops.fillSpansLoop;
331 if (fs != null) {
332 fs.FillSpans(sg2d, sg2d.getSurfaceData(), si);
333 return;
334 }
335 }
336 int spanbox[] = new int[4];
337 SurfaceData sd = sg2d.getSurfaceData();
338 while (si.nextSpan(spanbox)) {
339 int x = spanbox[0];
340 int y = spanbox[1];
341 int w = spanbox[2] - x;
342 int h = spanbox[3] - y;
343 sg2d.loops.fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
344 }
345 }
346
347 public void fillParallelogram(SunGraphics2D sg2d,
348 double ux1, double uy1,
349 double ux2, double uy2,
350 double x, double y,
351 double dx1, double dy1,
352 double dx2, double dy2)
353 {
354 FillParallelogram fp = sg2d.loops.fillParallelogramLoop;
355 fp.FillParallelogram(sg2d, sg2d.getSurfaceData(),
356 x, y, dx1, dy1, dx2, dy2);
|
1 /*
2 * Copyright (c) 1999, 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
75 new RoundRectangle2D.Float(x, y, width, height,
76 arcWidth, arcHeight));
77 }
78
79 public void drawOval(SunGraphics2D sg2d,
80 int x, int y, int width, int height)
81 {
82 sg2d.shapepipe.draw(sg2d, new Ellipse2D.Float(x, y, width, height));
83 }
84
85 public void drawArc(SunGraphics2D sg2d,
86 int x, int y, int width, int height,
87 int startAngle, int arcAngle)
88 {
89 sg2d.shapepipe.draw(sg2d, new Arc2D.Float(x, y, width, height,
90 startAngle, arcAngle,
91 Arc2D.OPEN));
92 }
93
94 public void drawPolyline(SunGraphics2D sg2d,
95 int[] xPoints, int[] yPoints,
96 int nPoints)
97 {
98 int[] nPointsArray = { nPoints };
99 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
100 xPoints, yPoints,
101 nPointsArray, 1,
102 sg2d.transX, sg2d.transY,
103 false);
104 }
105
106 public void drawPolygon(SunGraphics2D sg2d,
107 int[] xPoints, int[] yPoints,
108 int nPoints)
109 {
110 int[] nPointsArray = { nPoints };
111 sg2d.loops.drawPolygonsLoop.DrawPolygons(sg2d, sg2d.getSurfaceData(),
112 xPoints, yPoints,
113 nPointsArray, 1,
114 sg2d.transX, sg2d.transY,
115 true);
116 }
117
118 public void fillRect(SunGraphics2D sg2d,
119 int x, int y, int width, int height)
120 {
121 sg2d.loops.fillRectLoop.FillRect(sg2d, sg2d.getSurfaceData(),
122 x + sg2d.transX,
123 y + sg2d.transY,
124 width, height);
125 }
126
127 public void fillRoundRect(SunGraphics2D sg2d,
128 int x, int y, int width, int height,
129 int arcWidth, int arcHeight)
130 {
132 new RoundRectangle2D.Float(x, y, width, height,
133 arcWidth, arcHeight));
134 }
135
136 public void fillOval(SunGraphics2D sg2d,
137 int x, int y, int width, int height)
138 {
139 sg2d.shapepipe.fill(sg2d, new Ellipse2D.Float(x, y, width, height));
140 }
141
142 public void fillArc(SunGraphics2D sg2d,
143 int x, int y, int width, int height,
144 int startAngle, int arcAngle)
145 {
146 sg2d.shapepipe.fill(sg2d, new Arc2D.Float(x, y, width, height,
147 startAngle, arcAngle,
148 Arc2D.PIE));
149 }
150
151 public void fillPolygon(SunGraphics2D sg2d,
152 int[] xPoints, int[] yPoints,
153 int nPoints)
154 {
155 ShapeSpanIterator sr = getFillSSI(sg2d);
156
157 try {
158 sr.setOutputArea(sg2d.getCompClip());
159 sr.appendPoly(xPoints, yPoints, nPoints, sg2d.transX, sg2d.transY);
160 fillSpans(sg2d, sr);
161 } finally {
162 sr.dispose();
163 }
164 }
165
166
167 public void draw(SunGraphics2D sg2d, Shape s) {
168 if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
169 Path2D.Float p2df;
170 int transX;
171 int transY;
172 if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
316 } finally {
317 sr.dispose();
318 }
319 }
320
321 private static void fillSpans(SunGraphics2D sg2d, SpanIterator si) {
322 // REMIND: Eventually, the plan is that it will not be possible for
323 // fs to be null since the FillSpans loop will be the fundamental
324 // loop implemented for any destination type...
325 if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
326 si = sg2d.clipRegion.filter(si);
327 // REMIND: Region.filter produces a Java-only iterator
328 // with no native counterpart...
329 } else {
330 sun.java2d.loops.FillSpans fs = sg2d.loops.fillSpansLoop;
331 if (fs != null) {
332 fs.FillSpans(sg2d, sg2d.getSurfaceData(), si);
333 return;
334 }
335 }
336 int[] spanbox = new int[4];
337 SurfaceData sd = sg2d.getSurfaceData();
338 while (si.nextSpan(spanbox)) {
339 int x = spanbox[0];
340 int y = spanbox[1];
341 int w = spanbox[2] - x;
342 int h = spanbox[3] - y;
343 sg2d.loops.fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
344 }
345 }
346
347 public void fillParallelogram(SunGraphics2D sg2d,
348 double ux1, double uy1,
349 double ux2, double uy2,
350 double x, double y,
351 double dx1, double dy1,
352 double dx2, double dy2)
353 {
354 FillParallelogram fp = sg2d.loops.fillParallelogramLoop;
355 fp.FillParallelogram(sg2d, sg2d.getSurfaceData(),
356 x, y, dx1, dy1, dx2, dy2);
|