Debian Codegraph @

freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/PolyPolyline16.java

raw
1 // Copyright 2002, FreeHEP.
2 package org.freehep.graphicsio.emf.gdi;
3
4 import java.awt.Point;
5 import java.awt.Rectangle;
6 import java.io.IOException;
7
8 import org.freehep.graphicsio.emf.EMFInputStream;
9 import org.freehep.graphicsio.emf.EMFOutputStream;
10 import org.freehep.graphicsio.emf.EMFTag;
11
12 /**
13 * PolyPolyline16 TAG.
14 *
15 * @author Mark Donszelmann
16 * @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/PolyPolyline16.java 9c0688d78e6b 2007/01/30 23:58:16 duns $
17 */
18 public class PolyPolyline16 extends AbstractPolyPolyline {
19
20 private int numberOfPolys;
21
22 public PolyPolyline16() {
23 super(90, 1, null, null, null);
24 }
25
26 public PolyPolyline16(
27 Rectangle bounds,
28 int numberOfPolys,
29 int[] numberOfPoints,
30 Point[][] points) {
31
32 super(90, 1, bounds, numberOfPoints, points);
33 this.numberOfPolys = numberOfPolys;
34 }
35
36 public EMFTag read(int tagID, EMFInputStream emf, int len)
37 throws IOException {
38
39 Rectangle bounds = emf.readRECTL();
40 int np = emf.readDWORD();
41 /* int totalNumberOfPoints = */ emf.readDWORD();
42 int[] pc = new int[np];
43 Point[][] points = new Point[np][];
44 for (int i = 0; i < np; i++) {
45 pc[i] = emf.readDWORD();
46 points[i] = new Point[pc[i]];
47 }
48 for (int i = 0; i < np; i++) {
49 points[i] = emf.readPOINTS(pc[i]);
50 }
51 return new PolyPolyline16(bounds, np, pc, points);
52 }
53
54 public void write(int tagID, EMFOutputStream emf) throws IOException {
55 int[] numberOfPoints = getNumberOfPoints();
56 Point[][] points = getPoints();
57
58 emf.writeRECTL(getBounds());
59 emf.writeDWORD(numberOfPolys);
60 int c = 0;
61 for (int i = 0; i < numberOfPolys; i++) {
62 c += numberOfPoints[i];
63 }
64 emf.writeDWORD(c);
65 for (int i = 0; i < numberOfPolys; i++) {
66 emf.writeDWORD(numberOfPoints[i]);
67 }
68 for (int i = 0; i < numberOfPolys; i++) {
69 emf.writePOINTS(numberOfPoints[i], points[i]);
70 }
71 }
72 }