1 7 8 package java.awt.geom; 9 10 24 class GeneralPathIterator implements PathIterator { 25 int typeIdx = 0; 26 int pointIdx = 0; 27 GeneralPath path; 28 AffineTransform affine; 29 30 private static final int curvesize[] = {2, 2, 4, 6, 0}; 31 32 36 GeneralPathIterator(GeneralPath path) { 37 this(path, null); 38 } 39 40 45 GeneralPathIterator(GeneralPath path, AffineTransform at) { 46 this.path = path; 47 this.affine = at; 48 } 49 50 56 public int getWindingRule() { 57 return path.getWindingRule(); 58 } 59 60 64 public boolean isDone() { 65 return (typeIdx >= path.numTypes); 66 } 67 68 73 public void next() { 74 int type = path.pointTypes[typeIdx++]; 75 pointIdx += curvesize[type]; 76 } 77 78 96 public int currentSegment(float[] coords) { 97 int type = path.pointTypes[typeIdx]; 98 int numCoords = curvesize[type]; 99 if (numCoords > 0 && affine != null) { 100 affine.transform(path.pointCoords, pointIdx, 101 coords, 0, 102 numCoords / 2); 103 } else { 104 System.arraycopy(path.pointCoords, pointIdx, coords, 0, numCoords); 105 } 106 return type; 107 } 108 109 127 public int currentSegment(double[] coords) { 128 int type = path.pointTypes[typeIdx]; 129 int numCoords = curvesize[type]; 130 if (numCoords > 0 && affine != null) { 131 affine.transform(path.pointCoords, pointIdx, 132 coords, 0, 133 numCoords / 2); 134 } else { 135 for (int i=0; i < numCoords; i++) { 136 coords[i] = path.pointCoords[pointIdx + i]; 137 } 138 } 139 return type; 140 } 141 } 142 | Popular Tags |