History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/java2d/pipe/PixelToShapeConverter.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/java2d/pipe/PixelToShapeConverter.java+133−0
@@ -0,0 +1,133 @@
1+/*
2+ * Copyright (c) 1997, 1998, 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
23+ * questions.
24+ */
25+
26+package sun.java2d.pipe;
27+
28+import java.awt.Rectangle;
29+import java.awt.Shape;
30+import java.awt.geom.Arc2D;
31+import java.awt.geom.Ellipse2D;
32+import java.awt.geom.Line2D;
33+import java.awt.geom.RoundRectangle2D;
34+import java.awt.geom.GeneralPath;
35+import sun.java2d.SunGraphics2D;
36+
37+/**
38+ * This class converts calls to the basic pixel rendering methods
39+ * into calls to a generic Shape rendering pipeline.
40+ */
41+public class PixelToShapeConverter
42+ implements PixelDrawPipe, PixelFillPipe
43+{
44+ ShapeDrawPipe outpipe;
45+
46+ public PixelToShapeConverter(ShapeDrawPipe pipe) {
47+ outpipe = pipe;
48+ }
49+
50+ public void drawLine(SunGraphics2D sg,
51+ int x1, int y1, int x2, int y2) {
52+ outpipe.draw(sg, new Line2D.Float(x1, y1, x2, y2));
53+ }
54+
55+ public void drawRect(SunGraphics2D sg,
56+ int x, int y, int w, int h) {
57+ outpipe.draw(sg, new Rectangle(x, y, w, h));
58+ }
59+
60+ public void fillRect(SunGraphics2D sg,
61+ int x, int y, int w, int h) {
62+ outpipe.fill(sg, new Rectangle(x, y, w, h));
63+ }
64+
65+ public void drawRoundRect(SunGraphics2D sg,
66+ int x, int y, int w, int h,
67+ int aW, int aH) {
68+ outpipe.draw(sg, new RoundRectangle2D.Float(x, y, w, h, aW, aH));
69+ }
70+
71+ public void fillRoundRect(SunGraphics2D sg,
72+ int x, int y, int w, int h,
73+ int aW, int aH) {
74+ outpipe.fill(sg, new RoundRectangle2D.Float(x, y, w, h, aW, aH));
75+ }
76+
77+ public void drawOval(SunGraphics2D sg,
78+ int x, int y, int w, int h) {
79+ outpipe.draw(sg, new Ellipse2D.Float(x, y, w, h));
80+ }
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+ }
107+ for (int i = 1; i < nPoints; i++) {
108+ gp.lineTo(xPoints[i], yPoints[i]);
109+ }
110+ if (close) {
111+ gp.closePath();
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+}