Debian Codegraph @

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

raw symbols SCIP
1 // Copyright 2001, FreeHEP.
2 package org.freehep.graphicsio.cgm;
3
4 import java.awt.geom.Point2D;
5 import java.io.IOException;
6
7 /**
8 * PolygonSet TAG.
9 *
10 * @author Mark Donszelmann
11 * @author Charles Loomis
12 * @version $Id: freehep-graphicsio-cgm/src/main/java/org/freehep/graphicsio/cgm/PolygonSet.java 278fac7cefaa 2005/12/05 04:00:43 duns $
13 */
14 public class PolygonSet extends CGMTag {
15
16 public static final int INVISIBLE = 0;
17
18 public static final int VISIBLE = 1;
19
20 public static final int CLOSE_INVISIBLE = 2;
21
22 public static final int CLOSE_VISIBLE = 3;
23
24 private Point2D[] p;
25
26 private int[] flags;
27
28 public PolygonSet() {
29 super(4, 8, 1);
30 }
31
32 public PolygonSet(Point2D[] p, int[] flags) {
33 this();
34 this.p = p;
35 this.flags = flags;
36 }
37
38 public void write(int tagID, CGMOutputStream cgm) throws IOException {
39 for (int i = 0; i < p.length; i++) {
40 cgm.writePoint(p[i]);
41 cgm.writeEnumerate(flags[i]);
42 }
43 }
44
45 public void write(int tagID, CGMWriter cgm) throws IOException {
46 cgm.println("POLYGONSET");
47 for (int i = 0; i < p.length; i++) {
48 cgm.writePoint(p[i]);
49 cgm.print(", ");
50 switch (flags[i]) {
51 default:
52 case INVISIBLE:
53 cgm.print("INVIS");
54 break;
55 case VISIBLE:
56 cgm.print("VIS");
57 break;
58 case CLOSE_INVISIBLE:
59 cgm.print("CLOSEINVIS");
60 break;
61 case CLOSE_VISIBLE:
62 cgm.print("CLOSEVIS");
63 break;
64 }
65 cgm.println();
66 }
67 }
68 }