1 49 50 package com.lowagie.text.pdf.internal; 51 52 import java.awt.geom.AffineTransform ; 53 import java.awt.geom.PathIterator ; 54 import java.util.NoSuchElementException ; 55 60 public class PolylineShapeIterator implements PathIterator { 61 62 protected PolylineShape poly; 63 64 protected AffineTransform affine; 65 66 protected int index; 67 68 69 PolylineShapeIterator(PolylineShape l, AffineTransform at) { 70 this.poly = l; 71 this.affine = at; 72 } 73 74 92 public int currentSegment(double[] coords) { 93 if (isDone()) { 94 throw new NoSuchElementException ("line iterator out of bounds"); 95 } 96 int type = (index==0)?SEG_MOVETO:SEG_LINETO; 97 coords[0] = (double) poly.x[index]; 98 coords[1] = (double) poly.y[index]; 99 if (affine != null) { 100 affine.transform(coords, 0, coords, 0, 1); 101 } 102 return type; 103 } 104 105 123 public int currentSegment(float[] coords) { 124 if (isDone()) { 125 throw new NoSuchElementException ("line iterator out of bounds"); 126 } 127 int type = (index==0)?SEG_MOVETO:SEG_LINETO; 128 coords[0] = (float) poly.x[index]; 129 coords[1] = (float) poly.y[index]; 130 if (affine != null) { 131 affine.transform(coords, 0, coords, 0, 1); 132 } 133 return type; 134 } 135 136 143 public int getWindingRule() { 144 return WIND_NON_ZERO; 145 } 146 147 152 public boolean isDone() { 153 return (index >= poly.np); 154 } 155 156 162 public void next() { 163 index++; 164 } 165 166 } 167 | Popular Tags |