jdk/src/share/classes/sun/java2d/loops/DrawParallelogram.java
changeset 7487 9b031d062ede
child 7668 d4a77089c587
equal deleted inserted replaced
7486:6a36b1ebc620 7487:9b031d062ede
       
     1 /*
       
     2  * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 /*
       
    27  * @author Jim Graham
       
    28  */
       
    29 
       
    30 package sun.java2d.loops;
       
    31 
       
    32 import sun.java2d.loops.GraphicsPrimitive;
       
    33 import sun.java2d.SunGraphics2D;
       
    34 import sun.java2d.SurfaceData;
       
    35 
       
    36 /**
       
    37  * DrawParallelogram
       
    38  * 1) fill the area between the 4 edges of an outer parallelogram
       
    39  *    (as specified by an origin and 2 delta vectors)
       
    40  *    but also outside the 4 edges of an inner parallelogram
       
    41  *    (as specified by proportional amounts of the outer delta vectors)
       
    42  */
       
    43 public class DrawParallelogram extends GraphicsPrimitive
       
    44 {
       
    45     public final static String methodSignature =
       
    46         "DrawParallelogram(...)".toString();
       
    47 
       
    48     public final static int primTypeID = makePrimTypeID();
       
    49 
       
    50     public static DrawParallelogram locate(SurfaceType srctype,
       
    51                                            CompositeType comptype,
       
    52                                            SurfaceType dsttype)
       
    53     {
       
    54         return (DrawParallelogram)
       
    55             GraphicsPrimitiveMgr.locate(primTypeID,
       
    56                                         srctype, comptype, dsttype);
       
    57     }
       
    58 
       
    59     protected DrawParallelogram(SurfaceType srctype,
       
    60                                 CompositeType comptype,
       
    61                                 SurfaceType dsttype)
       
    62     {
       
    63         super(methodSignature, primTypeID,
       
    64               srctype, comptype, dsttype);
       
    65     }
       
    66 
       
    67     public DrawParallelogram(long pNativePrim,
       
    68                              SurfaceType srctype,
       
    69                              CompositeType comptype,
       
    70                              SurfaceType dsttype)
       
    71     {
       
    72         super(pNativePrim, methodSignature, primTypeID,
       
    73               srctype, comptype, dsttype);
       
    74     }
       
    75 
       
    76     /**
       
    77      * All DrawParallelogram implementors must have this invoker method
       
    78      */
       
    79     public native void DrawParallelogram(SunGraphics2D sg, SurfaceData dest,
       
    80                                          double x, double y,
       
    81                                          double dx1, double dy1,
       
    82                                          double dx2, double dy2,
       
    83                                          double lw1, double lw2);
       
    84 
       
    85     public GraphicsPrimitive makePrimitive(SurfaceType srctype,
       
    86                                            CompositeType comptype,
       
    87                                            SurfaceType dsttype)
       
    88     {
       
    89         // REMIND: iterate with a FillRect primitive?
       
    90         throw new InternalError("DrawParallelogram not implemented for "+
       
    91                                 srctype+" with "+comptype);
       
    92     }
       
    93 
       
    94     public GraphicsPrimitive traceWrap() {
       
    95         return new TraceDrawParallelogram(this);
       
    96     }
       
    97 
       
    98     private static class TraceDrawParallelogram extends DrawParallelogram {
       
    99         DrawParallelogram target;
       
   100 
       
   101         public TraceDrawParallelogram(DrawParallelogram target) {
       
   102             super(target.getSourceType(),
       
   103                   target.getCompositeType(),
       
   104                   target.getDestType());
       
   105             this.target = target;
       
   106         }
       
   107 
       
   108         public GraphicsPrimitive traceWrap() {
       
   109             return this;
       
   110         }
       
   111 
       
   112         public void DrawParallelogram(SunGraphics2D sg2d, SurfaceData dest,
       
   113                                       double x, double y,
       
   114                                       double dx1, double dy1,
       
   115                                       double dx2, double dy2,
       
   116                                       double lw1, double lw2)
       
   117         {
       
   118             tracePrimitive(target);
       
   119             target.DrawParallelogram(sg2d, dest,
       
   120                                      x, y, dx1, dy1, dx2, dy2, lw1, lw2);
       
   121         }
       
   122     }
       
   123 }