Debian Codegraph @

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

raw
1 // Copyright 2002, FreeHEP.
2 package org.freehep.graphicsio.emf.gdi;
3
4 import java.awt.Point;
5 import java.awt.geom.GeneralPath;
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 import org.freehep.graphicsio.emf.EMFRenderer;
12
13 /**
14 * MoveToEx TAG.
15 *
16 * @author Mark Donszelmann
17 * @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/MoveToEx.java c0f15e7696d3 2007/01/22 19:26:48 duns $
18 */
19 public class MoveToEx extends EMFTag {
20
21 private Point point;
22
23 public MoveToEx() {
24 super(27, 1);
25 }
26
27 public MoveToEx(Point point) {
28 this();
29 this.point = point;
30 }
31
32 public EMFTag read(int tagID, EMFInputStream emf, int len)
33 throws IOException {
34
35 return new MoveToEx(emf.readPOINTL());
36 }
37
38 public void write(int tagID, EMFOutputStream emf) throws IOException {
39 emf.writePOINTL(point);
40 }
41
42 public String toString() {
43 return super.toString() + "\n point: " + point;
44 }
45
46 /**
47 * displays the tag using the renderer
48 *
49 * @param renderer EMFRenderer storing the drawing session data
50 */
51 public void render(EMFRenderer renderer) {
52 // The MoveToEx function updates the current position to the
53 // specified point
54 // and optionally returns the previous position.
55 GeneralPath currentFigure = new GeneralPath(
56 renderer.getWindingRule());
57 currentFigure.moveTo(
58 (float) point.getX(),
59 (float) point.getY());
60 renderer.setFigure(currentFigure);
61 }
62 }