0N/A/*
6049N/A * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pipe;
0N/A
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.Shape;
0N/Aimport java.awt.geom.Arc2D;
0N/Aimport java.awt.geom.Ellipse2D;
0N/Aimport java.awt.geom.Line2D;
0N/Aimport java.awt.geom.RoundRectangle2D;
0N/Aimport java.awt.geom.GeneralPath;
0N/Aimport sun.java2d.SunGraphics2D;
0N/A
0N/A/**
0N/A * This class converts calls to the basic pixel rendering methods
0N/A * into calls to a generic Shape rendering pipeline.
0N/A */
0N/Apublic class PixelToShapeConverter
0N/A implements PixelDrawPipe, PixelFillPipe
0N/A{
0N/A ShapeDrawPipe outpipe;
0N/A
0N/A public PixelToShapeConverter(ShapeDrawPipe pipe) {
0N/A outpipe = pipe;
0N/A }
0N/A
0N/A public void drawLine(SunGraphics2D sg,
0N/A int x1, int y1, int x2, int y2) {
0N/A outpipe.draw(sg, new Line2D.Float(x1, y1, x2, y2));
0N/A }
0N/A
0N/A public void drawRect(SunGraphics2D sg,
0N/A int x, int y, int w, int h) {
0N/A outpipe.draw(sg, new Rectangle(x, y, w, h));
0N/A }
0N/A
0N/A public void fillRect(SunGraphics2D sg,
0N/A int x, int y, int w, int h) {
0N/A outpipe.fill(sg, new Rectangle(x, y, w, h));
0N/A }
0N/A
0N/A public void drawRoundRect(SunGraphics2D sg,
0N/A int x, int y, int w, int h,
0N/A int aW, int aH) {
0N/A outpipe.draw(sg, new RoundRectangle2D.Float(x, y, w, h, aW, aH));
0N/A }
0N/A
0N/A public void fillRoundRect(SunGraphics2D sg,
0N/A int x, int y, int w, int h,
0N/A int aW, int aH) {
0N/A outpipe.fill(sg, new RoundRectangle2D.Float(x, y, w, h, aW, aH));
0N/A }
0N/A
0N/A public void drawOval(SunGraphics2D sg,
0N/A int x, int y, int w, int h) {
0N/A outpipe.draw(sg, new Ellipse2D.Float(x, y, w, h));
0N/A }
0N/A
0N/A public void fillOval(SunGraphics2D sg,
0N/A int x, int y, int w, int h) {
0N/A outpipe.fill(sg, new Ellipse2D.Float(x, y, w, h));
0N/A }
0N/A
0N/A public void drawArc(SunGraphics2D sg,
0N/A int x, int y, int w, int h,
0N/A int start, int extent) {
0N/A outpipe.draw(sg, new Arc2D.Float(x, y, w, h,
0N/A start, extent, Arc2D.OPEN));
0N/A }
0N/A
0N/A public void fillArc(SunGraphics2D sg,
0N/A int x, int y, int w, int h,
0N/A int start, int extent) {
0N/A outpipe.fill(sg, new Arc2D.Float(x, y, w, h,
0N/A start, extent, Arc2D.PIE));
0N/A }
0N/A
0N/A private Shape makePoly(int xPoints[], int yPoints[],
0N/A int nPoints, boolean close) {
0N/A GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
0N/A if (nPoints > 0) {
0N/A gp.moveTo(xPoints[0], yPoints[0]);
6049N/A for (int i = 1; i < nPoints; i++) {
6049N/A gp.lineTo(xPoints[i], yPoints[i]);
6049N/A }
6049N/A if (close) {
6049N/A gp.closePath();
6049N/A }
0N/A }
0N/A return gp;
0N/A }
0N/A
0N/A public void drawPolyline(SunGraphics2D sg,
0N/A int xPoints[], int yPoints[],
0N/A int nPoints) {
0N/A outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, false));
0N/A }
0N/A
0N/A public void drawPolygon(SunGraphics2D sg,
0N/A int xPoints[], int yPoints[],
0N/A int nPoints) {
0N/A outpipe.draw(sg, makePoly(xPoints, yPoints, nPoints, true));
0N/A }
0N/A
0N/A public void fillPolygon(SunGraphics2D sg,
0N/A int xPoints[], int yPoints[],
0N/A int nPoints) {
0N/A outpipe.fill(sg, makePoly(xPoints, yPoints, nPoints, true));
0N/A }
0N/A}