1
2 package org.freehep.graphicsio.emf.gdi;
3
4 import java.awt.Point;
5 import java.awt.Rectangle;
6 import java.awt.geom.GeneralPath;
7 import java.io.IOException;
8
9 import org.freehep.graphicsio.emf.EMFInputStream;
10 import org.freehep.graphicsio.emf.EMFTag;
11 import org.freehep.graphicsio.emf.EMFRenderer;
12
13
14
15
16
17
18
19 public class PolyBezierTo extends AbstractPolygon {
20
21 public PolyBezierTo() {
22 super(5, 1, null, 0, null);
23 }
24
25 public PolyBezierTo(Rectangle bounds, int numberOfPoints, Point[] points) {
26 super(5, 1, bounds, numberOfPoints, points);
27 }
28
29 protected PolyBezierTo (int id, int version, Rectangle bounds, int numberOfPoints, Point[] points) {
30 super(id, version, bounds, numberOfPoints, points);
31 }
32
33 public EMFTag read(int tagID, EMFInputStream emf, int len)
34 throws IOException {
35
36 Rectangle r = emf.readRECTL();
37 int n = emf.readDWORD();
38 return new PolyBezierTo(r, n, emf.readPOINTL(n));
39 }
40
41
42
43
44
45
46 public void render(EMFRenderer renderer) {
47 Point[] points = getPoints();
48 int numberOfPoints = getNumberOfPoints();
49 GeneralPath currentFigure = renderer.getFigure();
50
51 if (points != null && points.length > 0) {
52
53 Point p1, p2, p3;
54 for (int point = 0; point < numberOfPoints; point = point + 3) {
55
56 p1 = points[point];
57 p2 = points[point + 1];
58 p3 = points[point + 2];
59 currentFigure.curveTo(
60 (float)p1.getX(), (float)p1.getY(),
61 (float)p2.getX(), (float)p2.getY(),
62 (float)p3.getX(), (float)p3.getY());
63 }
64 }
65 }
66 }