1 8 package com.nightlabs.editor2d.j2d; 9 10 import java.awt.Shape ; 11 import java.awt.geom.PathIterator ; 12 import java.awt.geom.Point2D ; 13 14 15 public class LineShape 16 extends GeneralShape 17 { 18 19 22 public LineShape() { 23 super(); 24 } 25 26 29 public LineShape(int rule) { 30 super(rule); 31 } 32 33 37 public LineShape(int rule, int initialCapacity) { 38 super(rule, initialCapacity); 39 } 40 41 46 public LineShape(int rule, int initialTypes, int initialCoords) { 47 super(rule, initialTypes, initialCoords); 48 } 49 50 53 public LineShape(Shape s) { 54 super(s); 55 } 56 57 64 public LineShape(int windingRule, byte[] pointTypes, int numTypes, 65 float[] pointCoords, int numCoords) { 66 super(windingRule, pointTypes, numTypes, pointCoords, numCoords); 67 } 68 69 public void addPoint(int x, int y) 70 { 71 lineTo(x,y); 72 } 73 74 public void addPoint(float x, float y) 75 { 76 lineTo(x,y); 77 } 78 79 86 public synchronized void setLastPoint(float x, float y) 87 { 88 if (numTypes < 1 || numCoords < 2) { 89 return; 90 } 91 int index = numCoords; 92 if (pointTypes[numTypes - 1] == PathIterator.SEG_CLOSE) { 93 loop: 94 for (int i = numTypes - 2; i > 0; i--) { 95 switch (pointTypes[i]) { 96 case PathIterator.SEG_MOVETO: 97 break loop; 98 case PathIterator.SEG_LINETO: 99 index -= 2; 100 break; 101 case PathIterator.SEG_QUADTO: 102 index -= 4; 103 break; 104 case PathIterator.SEG_CUBICTO: 105 index -= 6; 106 break; 107 case PathIterator.SEG_CLOSE: 108 break; 109 } 110 } 111 } 112 pointCoords[index - 2] = x; 115 pointCoords[index - 1] = y; 116 } 117 } 118 | Popular Tags |