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   * ArcTo TAG.
15   * 
16   * @author Mark Donszelmann
17   * @version $Id: ArcTo.java 10377 2007-01-23 15:44:34Z duns $
18   */
19  public class ArcTo extends AbstractArc {
20  
21      public ArcTo() {
22          super(55, 1, null, null, null);
23      }
24  
25      public ArcTo(Rectangle bounds, Point start, Point end) {
26          super(55, 1, bounds, start, end);
27      }
28  
29      public EMFTag read(int tagID, EMFInputStream emf, int len)
30              throws IOException {
31  
32          return new ArcTo(
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 ArcTo function draws an elliptical arc.
45          //
46          // BOOL ArcTo(
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 nXRadial1, // x-coord of first radial ending point
53          // int nYRadial1, // y-coord of first radial ending point
54          // int nXRadial2, // x-coord of second radial ending point
55          // int nYRadial2 // y-coord of second radial ending point
56          // );
57          // ArcTo is similar to the Arc function, except that the current
58          // position is updated.
59          //
60          // The points (nLeftRect, nTopRect) and (nRightRect, nBottomRect)
61          // specify the bounding rectangle.
62          // An ellipse formed by the specified bounding rectangle defines the
63          // curve of the arc. The arc extends
64          // counterclockwise from the point where it intersects the radial
65          // line from the center of the bounding
66          // rectangle to the (nXRadial1, nYRadial1) point. The arc ends where
67          // it intersects the radial line from
68          // the center of the bounding rectangle to the (nXRadial2,
69          // nYRadial2) point. If the starting point and
70          // ending point are the same, a complete ellipse is drawn.
71          //
72          // A line is drawn from the current position to the starting point
73          // of the arc.
74          // If no error occurs, the current position is set to the ending
75          // point of the arc.
76          //
77          // The arc is drawn using the current pen; it is not filled.
78  
79          renderer.getFigure().append(
80              getShape(renderer, Arc2D.OPEN), true);
81      }
82  }