View Javadoc

1   // Copyright 2002-2007, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.awt.Point;
5   import java.awt.Rectangle;
6   import java.awt.geom.Arc2D;
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   * Arc TAG.
15   * 
16   * @author Mark Donszelmann
17   * @version $Id: Arc.java 10377 2007-01-23 15:44:34Z duns $
18   */
19  public class Arc extends AbstractArc {
20  
21      public Arc() {
22          super(45, 1, null, null, null);
23      }
24  
25      public Arc(Rectangle bounds, Point start, Point end) {
26          super(45, 1, bounds, start, end);
27      }
28  
29      public EMFTag read(int tagID, EMFInputStream emf, int len)
30              throws IOException {
31  
32          return new Arc(
33              emf.readRECTL(), 
34              emf.readPOINTL(), 
35              emf.readPOINTL());
36      }
37  
38      /**
39       * displays the tag using the renderer
40       *
41       * @param renderer EMFRenderer storing the drawing session data
42       */
43      public void render(EMFRenderer renderer) {
44          // The Arc function draws an elliptical arc.
45          //
46          // BOOL Arc(
47          // HDC hdc, // handle to device context
48          // int nLeftRect, // x-coord of rectangle's upper-left corner
49          // int nTopRect, // y-coord of rectangle's upper-left corner
50          // int nRightRect, // x-coord of rectangle's lower-right corner
51          // int nBottomRect, // y-coord of rectangle's lower-right corner
52          // int nXStartArc, // x-coord of first radial ending point
53          // int nYStartArc, // y-coord of first radial ending point
54          // int nXEndArc, // x-coord of second radial ending point
55          // int nYEndArc // y-coord of second radial ending point
56          // );
57          // The points (nLeftRect, nTopRect) and (nRightRect, nBottomRect)
58          // specify the bounding rectangle.
59          // An ellipse formed by the specified bounding rectangle defines the
60          // curve of the arc.
61          // The arc extends in the current drawing direction from the point
62          // where it intersects the
63          // radial from the center of the bounding rectangle to the
64          // (nXStartArc, nYStartArc) point.
65          // The arc ends where it intersects the radial from the center of
66          // the bounding rectangle to
67          // the (nXEndArc, nYEndArc) point. If the starting point and ending
68          // point are the same,
69          // a complete ellipse is drawn.
70  
71          renderer.fillAndDrawOrAppend(
72              getShape(renderer, Arc2D.OPEN));
73      }
74  }