Debian Codegraph @

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

raw
1 // Copyright 2002, FreeHEP.
2 package org.freehep.graphicsio.emf.gdi;
3
4 import java.awt.Rectangle;
5 import java.awt.geom.Ellipse2D;
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 * Ellipse TAG.
15 *
16 * @author Mark Donszelmann
17 * @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/Ellipse.java c0f15e7696d3 2007/01/22 19:26:48 duns $
18 */
19 public class Ellipse extends EMFTag {
20 private Rectangle bounds;
21
22 public Ellipse(Rectangle bounds) {
23 this();
24 this.bounds = bounds;
25 }
26
27 public Ellipse() {
28 super(42, 1);
29 }
30
31 public EMFTag read(int tagID, EMFInputStream emf, int len)
32 throws IOException {
33
34 return new Ellipse(emf.readRECTL());
35 }
36
37 public void write(int tagID, EMFOutputStream emf) throws IOException {
38 emf.writeRECTL(bounds);
39 }
40
41 public String toString() {
42 return super.toString() + "\n bounds: " + bounds;
43 }
44
45 /**
46 * displays the tag using the renderer
47 *
48 * @param renderer EMFRenderer storing the drawing session data
49 */
50 public void render(EMFRenderer renderer) {
51 // The Ellipse function draws an ellipse. The center of the ellipse
52 // is the center of the specified bounding rectangle.
53 // The ellipse is outlined by using the current pen and is filled by
54 // using the current brush.
55 // The current position is neither used nor updated by Ellipse.
56 renderer.fillAndDrawOrAppend(new Ellipse2D.Double(
57 bounds.getX(),
58 bounds.getY(),
59 bounds.getWidth(),
60 bounds.getHeight()));
61 }
62 }