jfig.objects
Class FigArc

java.lang.Object
  extended byjfig.objects.FigPolyline
      extended byjfig.objects.FigArc
All Implemented Interfaces:
FigDrawable, FigObject
Direct Known Subclasses:
Arc

public class FigArc
extends FigPolyline

xfig-style arcs specified by three points.

FigArc: a class to manage and draw circular arcs specified by three control points (two end-points, one additional point on the diameter). Because the AWT supports only 1-pixel wide arcs, we construct a polyline approximation for drawing the arc.


Field Summary
(package private)  double alpha0
           
(package private)  double alpha1
           
(package private)  double alpha2
           
static int ccw
           
(package private)  double center_x
           
(package private)  double center_y
           
static int cw
           
(package private)  double dalpha10
           
(package private)  double dalpha21
           
protected  int direction
           
static int OPEN_ARC
           
static int PIE_WEDGE
           
(package private)  java.awt.Point[] pp
           
static double r
           
protected  int radius
           
protected  int type
           
protected  java.awt.Point[] wcp_arc
           
 
Fields inherited from class jfig.objects.FigPolyline
attribs, bbox, comment, debug, is_closed, min_i, min_num_points, painter, renderer, selected, showPoints, syncRedrawFlag, trafo, visible, wcp
 
Constructor Summary
FigArc()
           
FigArc(java.awt.Point P1, java.awt.Point P2, java.awt.Point P3, FigAttribs attribs, FigTrafo2D trafo)
          FigArc(): construct an arc object that starts in point P1, runs through p2 and ends in P3.
 
Method Summary
 void appendPoint(java.awt.Point wp)
          does nothing; we cannot append a point to a three-point arc.
protected  boolean build_arc()
          Given the three control points, calculate the arc center point and the direction (clockwise or counter-clockwise).
 FigObject copy()
          build a copy of this FigArc
 void createRenderer()
           
 java.awt.Point deletePoint(java.awt.Point wp)
          returns null; we cannot delete single points from a three-point arc.
 java.awt.Point getCenter()
           
 int getDirection()
           
 java.awt.Point[] getInterpolatedArcPoints()
          return the array with the interpolated arc points
 void insertPoint(java.awt.Point prev, java.awt.Point wp)
          does nothing; we cannot insert new points to a three-point arc.
 void rebuild()
          rebuild all internal data-structures for this polyline.
 void setPoints(java.awt.Point[] pp)
          set a new array of world-coordinate Points for this polyline.
 java.lang.String toString()
          toString() for debug purposes.
 void update_bbox()
          calculate the bounding box of this arc object.
 
Methods inherited from class jfig.objects.FigPolyline
calc_dist, canRotate, deselect, get_min_dist_index, get_sc_bbox, getAttributes, getBbox, getComment, getLayer, getMinDistPoint1, getMinDistPoint2, getMinPerpendicularDistance, getMinPerpendicularDistance, getMovePointNeighbors, getNearestPoint, getNeighborPoints, getObjectPainter, getPoints, getPosition, getSegmentDistance, getSyncRedrawFlag, getText, getTrafo, indexOfNearestNeighbor, initialize, isClosed, isSelected, isShowPoints, isVisible, isVisible, keyPressed, manhattan, message, minDistance, minDistanceEuclid, mirrorX, mirrorY, move, movePoint, nearerPoint, numPoints, paint, paint, paintSave, printCost, reset_debug, rotate, scale, select, set_debug, setArrowMode, setAttributes, setBackwardArrow, setComment, setFillColor, setFillStyle, setForwardArrow, setIsClosed, setLayer, setLineColor, setLineStyle, setLineWidth, setObjectPainter, setSyncRedrawFlag, setText, setTrafo, setVisible, showPoints, supportsPointOps, update, updateAttributes, writeAsResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wcp_arc

protected java.awt.Point[] wcp_arc

radius

protected int radius

direction

protected int direction

type

protected int type

r

public static final double r
See Also:
Constant Field Values

ccw

public static final int ccw
See Also:
Constant Field Values

cw

public static final int cw
See Also:
Constant Field Values

PIE_WEDGE

public static final int PIE_WEDGE
See Also:
Constant Field Values

OPEN_ARC

public static final int OPEN_ARC
See Also:
Constant Field Values

alpha0

double alpha0

alpha1

double alpha1

alpha2

double alpha2

dalpha21

double dalpha21

dalpha10

double dalpha10

center_x

double center_x

center_y

double center_y

pp

java.awt.Point[] pp
Constructor Detail

FigArc

public FigArc()

FigArc

public FigArc(java.awt.Point P1,
              java.awt.Point P2,
              java.awt.Point P3,
              FigAttribs attribs,
              FigTrafo2D trafo)
FigArc(): construct an arc object that starts in point P1, runs through p2 and ends in P3.

If all points are linearly dependent, a straight line results.

Method Detail

createRenderer

public void createRenderer()
Overrides:
createRenderer in class FigPolyline

rebuild

public void rebuild()
Description copied from class: FigPolyline
rebuild all internal data-structures for this polyline. This method re-calculates all internal data required for fast rendering from the world-coordinate control points, attributes, and FigTrafo2D coordinate transformation data. Therefore, this method is computationally expensive and should only be called when necessary.

Specified by:
rebuild in interface FigObject
Overrides:
rebuild in class FigPolyline

update_bbox

public void update_bbox()
calculate the bounding box of this arc object. To match the visual appearance of the arc, we have to distinguish between "normal" and "filled" arc objects here. For a standard, open arc object, it is sufficient to calculate the bounding box from the three control points specified by the user. However, filled arc objects can extend far beyound the rectangle spanned by the control points, especially when the three control points are almost collinear. Therefore, we calculate the bounding box from the control points and the virtual radius point for filled arc objects. Note that changing the arc fill style can (dramatically) change the bounding box for the arc.

FIXME: In degenerated cases, it might even be better to calculate the bounding box from the full interpolated points array...

Overrides:
update_bbox in class FigPolyline

getCenter

public java.awt.Point getCenter()

getDirection

public int getDirection()

getInterpolatedArcPoints

public java.awt.Point[] getInterpolatedArcPoints()
return the array with the interpolated arc points


setPoints

public void setPoints(java.awt.Point[] pp)
Description copied from class: FigPolyline
set a new array of world-coordinate Points for this polyline. This function should be called by input parsers to construct a new polyline with many points: setPoints() is much faster than a loop with successive appendPoints().

Specified by:
setPoints in interface FigObject
Overrides:
setPoints in class FigPolyline

build_arc

protected boolean build_arc()
Given the three control points, calculate the arc center point and the direction (clockwise or counter-clockwise). Prepare the array wcp_arc[] with the screen coords of this arc. Return true, if the arc could be constructed, and false if the construction failed (singular equations).


toString

public java.lang.String toString()
Description copied from class: FigPolyline
toString() for debug purposes.

Specified by:
toString in interface FigObject
Overrides:
toString in class FigPolyline

copy

public FigObject copy()
build a copy of this FigArc

Specified by:
copy in interface FigObject
Overrides:
copy in class FigPolyline

appendPoint

public void appendPoint(java.awt.Point wp)
does nothing; we cannot append a point to a three-point arc.

Specified by:
appendPoint in interface FigObject
Overrides:
appendPoint in class FigPolyline

insertPoint

public void insertPoint(java.awt.Point prev,
                        java.awt.Point wp)
does nothing; we cannot insert new points to a three-point arc.

Specified by:
insertPoint in interface FigObject
Overrides:
insertPoint in class FigPolyline

deletePoint

public java.awt.Point deletePoint(java.awt.Point wp)
returns null; we cannot delete single points from a three-point arc.

Specified by:
deletePoint in interface FigObject
Overrides:
deletePoint in class FigPolyline