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 java.awt.Color;
034: import java.awt.image.ColorModel;
035: import java.awt.image.Raster;
036: import sun.java2d.SunGraphics2D;
037: import sun.java2d.SurfaceData;
038:
039: /**
040: * DrawRect
041: * 1) draw single-width line rectangle onto destination surface
042: * 2) must accept output area [x, y, dx, dy]
043: * from within the surface description data for clip rect
044: */
045: public class DrawRect extends GraphicsPrimitive {
046: public final static String methodSignature = "DrawRect(...)"
047: .toString();
048:
049: public final static int primTypeID = makePrimTypeID();
050:
051: public static DrawRect locate(SurfaceType srctype,
052: CompositeType comptype, SurfaceType dsttype) {
053: return (DrawRect) GraphicsPrimitiveMgr.locate(primTypeID,
054: srctype, comptype, dsttype);
055: }
056:
057: protected DrawRect(SurfaceType srctype, CompositeType comptype,
058: SurfaceType dsttype) {
059: super (methodSignature, primTypeID, srctype, comptype, dsttype);
060: }
061:
062: public DrawRect(long pNativePrim, SurfaceType srctype,
063: CompositeType comptype, SurfaceType dsttype) {
064: super (pNativePrim, methodSignature, primTypeID, srctype,
065: comptype, dsttype);
066: }
067:
068: /**
069: * All DrawRect implementors must have this invoker method
070: */
071: public native void DrawRect(SunGraphics2D sg2d, SurfaceData dest,
072: int x1, int y1, int w, int h);
073:
074: public GraphicsPrimitive makePrimitive(SurfaceType srctype,
075: CompositeType comptype, SurfaceType dsttype) {
076: // REMIND: use FillSpans or converter object?
077: throw new InternalError("DrawRect not implemented for "
078: + srctype + " with " + comptype);
079: }
080:
081: public GraphicsPrimitive traceWrap() {
082: return new TraceDrawRect(this );
083: }
084:
085: private static class TraceDrawRect extends DrawRect {
086: DrawRect target;
087:
088: public TraceDrawRect(DrawRect target) {
089: super (target.getSourceType(), target.getCompositeType(),
090: target.getDestType());
091: this .target = target;
092: }
093:
094: public GraphicsPrimitive traceWrap() {
095: return this ;
096: }
097:
098: public void DrawRect(SunGraphics2D sg2d, SurfaceData dest,
099: int x1, int y1, int w, int h) {
100: tracePrimitive(target);
101: target.DrawRect(sg2d, dest, x1, y1, w, h);
102: }
103: }
104: }
|