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: * FillRect
041: * 1) draw solid color 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 FillRect extends GraphicsPrimitive {
046: public final static String methodSignature = "FillRect(...)"
047: .toString();
048:
049: public final static int primTypeID = makePrimTypeID();
050:
051: public static FillRect locate(SurfaceType srctype,
052: CompositeType comptype, SurfaceType dsttype) {
053: return (FillRect) GraphicsPrimitiveMgr.locate(primTypeID,
054: srctype, comptype, dsttype);
055: }
056:
057: protected FillRect(SurfaceType srctype, CompositeType comptype,
058: SurfaceType dsttype) {
059: super (methodSignature, primTypeID, srctype, comptype, dsttype);
060: }
061:
062: public FillRect(long pNativePrim, SurfaceType srctype,
063: CompositeType comptype, SurfaceType dsttype) {
064: super (pNativePrim, methodSignature, primTypeID, srctype,
065: comptype, dsttype);
066: }
067:
068: /**
069: * All FillRect implementors must have this invoker method
070: */
071: public native void FillRect(SunGraphics2D sg2d, SurfaceData dest,
072: int x, int y, int w, int h);
073:
074: static {
075: GraphicsPrimitiveMgr.registerGeneral(new FillRect(null, null,
076: null));
077: }
078:
079: public GraphicsPrimitive makePrimitive(SurfaceType srctype,
080: CompositeType comptype, SurfaceType dsttype) {
081: return new General(srctype, comptype, dsttype);
082: }
083:
084: public static class General extends FillRect {
085: public MaskFill fillop;
086:
087: public General(SurfaceType srctype, CompositeType comptype,
088: SurfaceType dsttype) {
089: super (srctype, comptype, dsttype);
090: fillop = MaskFill.locate(srctype, comptype, dsttype);
091: }
092:
093: public void FillRect(SunGraphics2D sg2d, SurfaceData dest,
094: int x, int y, int w, int h) {
095: fillop.MaskFill(sg2d, dest, sg2d.composite, x, y, w, h,
096: null, 0, 0);
097: }
098: }
099:
100: public GraphicsPrimitive traceWrap() {
101: return new TraceFillRect(this );
102: }
103:
104: private static class TraceFillRect extends FillRect {
105: FillRect target;
106:
107: public TraceFillRect(FillRect target) {
108: super (target.getSourceType(), target.getCompositeType(),
109: target.getDestType());
110: this .target = target;
111: }
112:
113: public GraphicsPrimitive traceWrap() {
114: return this ;
115: }
116:
117: public void FillRect(SunGraphics2D sg2d, SurfaceData dest,
118: int x, int y, int w, int h) {
119: tracePrimitive(target);
120: target.FillRect(sg2d, dest, x, y, w, h);
121: }
122: }
123: }
|