1 /* 2 * Copyright (c) 1998, 2006, 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 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, | 1 /* 2 * Copyright (c) 1998, 2014, 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 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, |