1 /*
2 * Copyright (c) 1997, 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
81
82 public void fillOval(SunGraphics2D sg,
83 int x, int y, int w, int h) {
84 outpipe.fill(sg, new Ellipse2D.Float(x, y, w, h));
85 }
86
87 public void drawArc(SunGraphics2D sg,
88 int x, int y, int w, int h,
89 int start, int extent) {
90 outpipe.draw(sg, new Arc2D.Float(x, y, w, h,
91 start, extent, Arc2D.OPEN));
92 }
93
94 public void fillArc(SunGraphics2D sg,
95 int x, int y, int w, int h,
96 int start, int extent) {
97 outpipe.fill(sg, new Arc2D.Float(x, y, w, h,
98 start, extent, Arc2D.PIE));
99 }
100
101 private Shape makePoly(int xPoints[], int yPoints[],
102 int nPoints, boolean close) {
103 GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
104 if (nPoints > 0) {
105 gp.moveTo(xPoints[0], yPoints[0]);
106 for (int i = 1; i < nPoints; i++) {
107 gp.lineTo(xPoints[i], yPoints[i]);
108 }
109 if (close) {
110 gp.closePath();
111 }
112 }
113 return gp;
114 }
115
116 public void drawPolyline(SunGraphics2D sg,
117 int xPoints[], int yPoints[],
118 int nPoints) {
119 outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, false));
120 }
121
122 public void drawPolygon(SunGraphics2D sg,
123 int xPoints[], int yPoints[],
124 int nPoints) {
125 outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, true));
126 }
127
128 public void fillPolygon(SunGraphics2D sg,
129 int xPoints[], int yPoints[],
130 int nPoints) {
131 outpipe.fill(sg, makePoly(xPoints, yPoints, nPoints, true));
132 }
133 }
|
1 /*
2 * Copyright (c) 1997, 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
81
82 public void fillOval(SunGraphics2D sg,
83 int x, int y, int w, int h) {
84 outpipe.fill(sg, new Ellipse2D.Float(x, y, w, h));
85 }
86
87 public void drawArc(SunGraphics2D sg,
88 int x, int y, int w, int h,
89 int start, int extent) {
90 outpipe.draw(sg, new Arc2D.Float(x, y, w, h,
91 start, extent, Arc2D.OPEN));
92 }
93
94 public void fillArc(SunGraphics2D sg,
95 int x, int y, int w, int h,
96 int start, int extent) {
97 outpipe.fill(sg, new Arc2D.Float(x, y, w, h,
98 start, extent, Arc2D.PIE));
99 }
100
101 private Shape makePoly(int[] xPoints, int[] yPoints,
102 int nPoints, boolean close) {
103 GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
104 if (nPoints > 0) {
105 gp.moveTo(xPoints[0], yPoints[0]);
106 for (int i = 1; i < nPoints; i++) {
107 gp.lineTo(xPoints[i], yPoints[i]);
108 }
109 if (close) {
110 gp.closePath();
111 }
112 }
113 return gp;
114 }
115
116 public void drawPolyline(SunGraphics2D sg,
117 int[] xPoints, int[] yPoints,
118 int nPoints) {
119 outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, false));
120 }
121
122 public void drawPolygon(SunGraphics2D sg,
123 int[] xPoints, int[] yPoints,
124 int nPoints) {
125 outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, true));
126 }
127
128 public void fillPolygon(SunGraphics2D sg,
129 int[] xPoints, int[] yPoints,
130 int nPoints) {
131 outpipe.fill(sg, makePoly(xPoints, yPoints, nPoints, true));
132 }
133 }
|