001: /*
002: * Copyright 1998-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 Jim Graham
028: * @author Charlton Innovations, Inc.
029: */
030:
031: package sun.java2d.loops;
032:
033: import sun.java2d.loops.GraphicsPrimitive;
034: import sun.java2d.pipe.SpanIterator;
035: import java.awt.Color;
036: import java.awt.image.ColorModel;
037: import java.awt.image.Raster;
038: import sun.java2d.SunGraphics2D;
039: import sun.java2d.SurfaceData;
040:
041: /**
042: * FillSpans
043: * 1) draw solid color onto destination surface
044: * 2) rectangular areas to fill come from SpanIterator
045: */
046: public class FillSpans extends GraphicsPrimitive {
047: public final static String methodSignature = "FillSpans(...)"
048: .toString();
049:
050: public final static int primTypeID = makePrimTypeID();
051:
052: public static FillSpans locate(SurfaceType srctype,
053: CompositeType comptype, SurfaceType dsttype) {
054: return (FillSpans) GraphicsPrimitiveMgr.locate(primTypeID,
055: srctype, comptype, dsttype);
056: }
057:
058: protected FillSpans(SurfaceType srctype, CompositeType comptype,
059: SurfaceType dsttype) {
060: super (methodSignature, primTypeID, srctype, comptype, dsttype);
061: }
062:
063: public FillSpans(long pNativePrim, SurfaceType srctype,
064: CompositeType comptype, SurfaceType dsttype) {
065: super (pNativePrim, methodSignature, primTypeID, srctype,
066: comptype, dsttype);
067: }
068:
069: private native void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
070: int pixel, long pIterator, SpanIterator si);
071:
072: /**
073: * All FillSpan implementors must have this invoker method
074: */
075: public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
076: SpanIterator si) {
077: FillSpans(sg2d, dest, sg2d.pixel, si.getNativeIterator(), si);
078: }
079:
080: public GraphicsPrimitive makePrimitive(SurfaceType srctype,
081: CompositeType comptype, SurfaceType dsttype) {
082: // REMIND: iterate with a FillRect primitive?
083: throw new InternalError("FillSpans not implemented for "
084: + srctype + " with " + comptype);
085: }
086:
087: public GraphicsPrimitive traceWrap() {
088: return new TraceFillSpans(this );
089: }
090:
091: private static class TraceFillSpans extends FillSpans {
092: FillSpans target;
093:
094: public TraceFillSpans(FillSpans target) {
095: super (target.getSourceType(), target.getCompositeType(),
096: target.getDestType());
097: this .target = target;
098: }
099:
100: public GraphicsPrimitive traceWrap() {
101: return this ;
102: }
103:
104: public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
105: SpanIterator si) {
106: tracePrimitive(target);
107: target.FillSpans(sg2d, dest, si);
108: }
109: }
110: }
|