001: /*
002: * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: /*
027: * @author Charlton Innovations, Inc.
028: */
029:
030: package sun.java2d.loops;
031:
032: import sun.java2d.loops.GraphicsPrimitive;
033: import sun.java2d.SunGraphics2D;
034: import sun.java2d.SurfaceData;
035:
036: /**
037: * DrawPolygons
038: * 1) draw single-width line polygons onto destination surface
039: * 2) must accept output area [x, y, dx, dy]
040: * from within the surface description data for clip rect
041: */
042: public class DrawPolygons extends GraphicsPrimitive {
043: public final static String methodSignature = "DrawPolygons(...)"
044: .toString();
045:
046: public final static int primTypeID = makePrimTypeID();
047:
048: public static DrawPolygons locate(SurfaceType srctype,
049: CompositeType comptype, SurfaceType dsttype) {
050: return (DrawPolygons) GraphicsPrimitiveMgr.locate(primTypeID,
051: srctype, comptype, dsttype);
052: }
053:
054: protected DrawPolygons(SurfaceType srctype, CompositeType comptype,
055: SurfaceType dsttype) {
056: super (methodSignature, primTypeID, srctype, comptype, dsttype);
057: }
058:
059: public DrawPolygons(long pNativePrim, SurfaceType srctype,
060: CompositeType comptype, SurfaceType dsttype) {
061: super (pNativePrim, methodSignature, primTypeID, srctype,
062: comptype, dsttype);
063: }
064:
065: /**
066: * All DrawPolygon implementors must have this invoker method
067: */
068: public native void DrawPolygons(SunGraphics2D sg2d,
069: SurfaceData sData, int xPoints[], int yPoints[],
070: int nPoints[], int numPolys, int transX, int transY,
071: boolean close);
072:
073: public GraphicsPrimitive makePrimitive(SurfaceType srctype,
074: CompositeType comptype, SurfaceType dsttype) {
075: // REMIND: use FillSpans or converter object?
076: throw new InternalError("DrawPolygons not implemented for "
077: + srctype + " with " + comptype);
078: }
079:
080: public GraphicsPrimitive traceWrap() {
081: return new TraceDrawPolygons(this );
082: }
083:
084: private static class TraceDrawPolygons extends DrawPolygons {
085: DrawPolygons target;
086:
087: public TraceDrawPolygons(DrawPolygons target) {
088: super (target.getSourceType(), target.getCompositeType(),
089: target.getDestType());
090: this .target = target;
091: }
092:
093: public GraphicsPrimitive traceWrap() {
094: return this ;
095: }
096:
097: public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData,
098: int xPoints[], int yPoints[], int nPoints[],
099: int numPolys, int transX, int transY, boolean close) {
100: tracePrimitive(target);
101: target.DrawPolygons(sg2d, sData, xPoints, yPoints, nPoints,
102: numPolys, transX, transY, close);
103: }
104: }
105: }
|