| 1 |
|
| 2 |
package org.freehep.graphicsio.cgm; |
| 3 |
|
| 4 |
import java.awt.geom.Point2D; |
| 5 |
import java.io.IOException; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
public class Polyline extends CGMTag { |
| 15 |
|
| 16 |
protected Point2D[] p; |
| 17 |
|
| 18 |
public Polyline() { |
| 19 |
super(4, 1, 1); |
| 20 |
} |
| 21 |
|
| 22 |
public Polyline(Point2D[] p) { |
| 23 |
this(); |
| 24 |
this.p = p; |
| 25 |
} |
| 26 |
|
| 27 |
protected Polyline(int elementClass, int elementID, int version) { |
| 28 |
super(elementClass, elementID, version); |
| 29 |
} |
| 30 |
|
| 31 |
public void write(int tagID, CGMOutputStream cgm) throws IOException { |
| 32 |
for (int i = 0; i < p.length; i++) { |
| 33 |
cgm.writePoint(p[i]); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
public void write(int tagID, CGMWriter cgm) throws IOException { |
| 38 |
cgm.println("LINE"); |
| 39 |
writePointList(cgm); |
| 40 |
} |
| 41 |
|
| 42 |
protected void writePointList(CGMWriter cgm) throws IOException { |
| 43 |
cgm.indent(); |
| 44 |
cgm.writePoint(p[0]); |
| 45 |
cgm.println(); |
| 46 |
for (int i = 1; i < p.length; i++) { |
| 47 |
cgm.print(", "); |
| 48 |
cgm.writePoint(p[i]); |
| 49 |
cgm.println(); |
| 50 |
} |
| 51 |
cgm.outdent(); |
| 52 |
} |
| 53 |
} |