src/share/classes/sun/awt/geom/Curve.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr


  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 package sun.awt.geom;
  27 
  28 import java.awt.geom.Rectangle2D;
  29 import java.awt.geom.QuadCurve2D;
  30 import java.awt.geom.CubicCurve2D;
  31 import java.awt.geom.PathIterator;
  32 import java.awt.geom.IllegalPathStateException;
  33 import java.util.Vector;
  34 
  35 public abstract class Curve {
  36     public static final int INCREASING = 1;
  37     public static final int DECREASING = -1;
  38 
  39     protected int direction;
  40 
  41     public static void insertMove(Vector curves, double x, double y) {
  42         curves.add(new Order0(x, y));
  43     }
  44 
  45     public static void insertLine(Vector curves,
  46                                   double x0, double y0,
  47                                   double x1, double y1)
  48     {
  49         if (y0 < y1) {
  50             curves.add(new Order1(x0, y0,
  51                                   x1, y1,
  52                                   INCREASING));
  53         } else if (y0 > y1) {
  54             curves.add(new Order1(x1, y1,
  55                                   x0, y0,
  56                                   DECREASING));
  57         } else {
  58             // Do not add horizontal lines
  59         }
  60     }
  61 
  62     public static void insertQuad(Vector curves,
  63                                   double x0, double y0,
  64                                   double coords[])
  65     {
  66         double y1 = coords[3];
  67         if (y0 > y1) {
  68             Order2.insert(curves, coords,
  69                           coords[2], y1,
  70                           coords[0], coords[1],
  71                           x0, y0,
  72                           DECREASING);
  73         } else if (y0 == y1 && y0 == coords[1]) {
  74             // Do not add horizontal lines
  75             return;
  76         } else {
  77             Order2.insert(curves, coords,
  78                           x0, y0,
  79                           coords[0], coords[1],
  80                           coords[2], y1,
  81                           INCREASING);
  82         }
  83     }
  84 
  85     public static void insertCubic(Vector curves,
  86                                    double x0, double y0,
  87                                    double coords[])
  88     {
  89         double y1 = coords[5];
  90         if (y0 > y1) {
  91             Order3.insert(curves, coords,
  92                           coords[4], y1,
  93                           coords[2], coords[3],
  94                           coords[0], coords[1],
  95                           x0, y0,
  96                           DECREASING);
  97         } else if (y0 == y1 && y0 == coords[1] && y0 == coords[3]) {
  98             // Do not add horizontal lines
  99             return;
 100         } else {
 101             Order3.insert(curves, coords,
 102                           x0, y0,
 103                           coords[0], coords[1],
 104                           coords[2], coords[3],
 105                           coords[4], y1,




  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 package sun.awt.geom;
  27 
  28 import java.awt.geom.Rectangle2D;
  29 import java.awt.geom.QuadCurve2D;
  30 import java.awt.geom.CubicCurve2D;
  31 import java.awt.geom.PathIterator;
  32 import java.awt.geom.IllegalPathStateException;
  33 import java.util.Vector;
  34 
  35 public abstract class Curve {
  36     public static final int INCREASING = 1;
  37     public static final int DECREASING = -1;
  38 
  39     protected int direction;
  40 
  41     public static void insertMove(Vector<Curve> curves, double x, double y) {
  42         curves.add(new Order0(x, y));
  43     }
  44 
  45     public static void insertLine(Vector<Curve> curves,
  46                                   double x0, double y0,
  47                                   double x1, double y1)
  48     {
  49         if (y0 < y1) {
  50             curves.add(new Order1(x0, y0,
  51                                   x1, y1,
  52                                   INCREASING));
  53         } else if (y0 > y1) {
  54             curves.add(new Order1(x1, y1,
  55                                   x0, y0,
  56                                   DECREASING));
  57         } else {
  58             // Do not add horizontal lines
  59         }
  60     }
  61 
  62     public static void insertQuad(Vector<Curve> curves,
  63                                   double x0, double y0,
  64                                   double coords[])
  65     {
  66         double y1 = coords[3];
  67         if (y0 > y1) {
  68             Order2.insert(curves, coords,
  69                           coords[2], y1,
  70                           coords[0], coords[1],
  71                           x0, y0,
  72                           DECREASING);
  73         } else if (y0 == y1 && y0 == coords[1]) {
  74             // Do not add horizontal lines
  75             return;
  76         } else {
  77             Order2.insert(curves, coords,
  78                           x0, y0,
  79                           coords[0], coords[1],
  80                           coords[2], y1,
  81                           INCREASING);
  82         }
  83     }
  84 
  85     public static void insertCubic(Vector<Curve> curves,
  86                                    double x0, double y0,
  87                                    double coords[])
  88     {
  89         double y1 = coords[5];
  90         if (y0 > y1) {
  91             Order3.insert(curves, coords,
  92                           coords[4], y1,
  93                           coords[2], coords[3],
  94                           coords[0], coords[1],
  95                           x0, y0,
  96                           DECREASING);
  97         } else if (y0 == y1 && y0 == coords[1] && y0 == coords[3]) {
  98             // Do not add horizontal lines
  99             return;
 100         } else {
 101             Order3.insert(curves, coords,
 102                           x0, y0,
 103                           coords[0], coords[1],
 104                           coords[2], coords[3],
 105                           coords[4], y1,