Debian Codegraph @

freehep-graphicsio-cgm/src/main/java/org/freehep/graphicsio/cgm/CGMPathConstructor.java

raw symbols SCIP
1 // Copyright 2001 FreeHEP.
2 package org.freehep.graphicsio.cgm;
3
4 import java.awt.geom.AffineTransform;
5 import java.awt.geom.Point2D;
6 import java.io.IOException;
7 import java.util.Vector;
8
9 import org.freehep.graphicsio.PolylinePathConstructor;
10 import org.freehep.util.io.TaggedOutput;
11
12 /**
13 * @author Mark Donszelmann
14 * @version $Id: freehep-graphicsio-cgm/src/main/java/org/freehep/graphicsio/cgm/CGMPathConstructor.java 278fac7cefaa 2005/12/05 04:00:43 duns $
15 */
16 public class CGMPathConstructor extends PolylinePathConstructor {
17 private TaggedOutput os;
18
19 private AffineTransform matrix;
20
21 public CGMPathConstructor(TaggedOutput os, boolean fill,
22 AffineTransform matrix, double resolution) {
23 super(fill, resolution);
24 this.os = os;
25 this.matrix = matrix;
26 }
27
28 protected void writePolyline(Vector polyline) throws IOException {
29 int n = polyline.size();
30 Point2D[] src = new Point2D[n];
31 polyline.copyInto(src);
32 Point2D[] dst = new Point2D[n];
33 matrix.transform(src, 0, dst, 0, n);
34 if (fill) {
35 os.writeTag(new Polygon(dst));
36 } else if (closed) {
37 os.writeTag(new EdgeVisibility(true));
38 os.writeTag(new InteriorStyle(InteriorStyle.HOLLOW));
39 os.writeTag(new Polygon(dst));
40 os.writeTag(new InteriorStyle(InteriorStyle.SOLID));
41 os.writeTag(new EdgeVisibility(false));
42 } else {
43 os.writeTag(new Polyline(dst));
44 }
45 }
46
47 }