net.sf.jaxodraw.object.arc
Class JaxoArcObject

java.lang.Object
  extended by net.sf.jaxodraw.object.JaxoObject
      extended by net.sf.jaxodraw.object.JaxoExtendedObject
          extended by net.sf.jaxodraw.object.JaxoParticleObject
              extended by net.sf.jaxodraw.object.Jaxo3PointObject
                  extended by net.sf.jaxodraw.object.arc.JaxoArcObject
All Implemented Interfaces:
Shape, PropertyChangeListener, Serializable, Cloneable, EventListener
Direct Known Subclasses:
JaxoDashArc, JaxoFArc, JaxoGlArc, JaxoPArc

public abstract class JaxoArcObject
extends Jaxo3PointObject

The mother of all arc objects.

Since:
2.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.jaxodraw.object.Jaxo3PointObject
SELECT_P3
 
Fields inherited from class net.sf.jaxodraw.object.JaxoParticleObject
GHOST_DASH, GLUON_FREQ, PHOTON_FREQ, SCALAR_DASH
 
Fields inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
SELECT_DX, SELECT_DY, SELECT_P2
 
Fields inherited from class net.sf.jaxodraw.object.JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1
 
Constructor Summary
JaxoArcObject()
           
 
Method Summary
 JaxoArrow.Coordinates arrowCoordinates()
          Returns the coordinates of the arrow of the current object.
 double getArcLength()
          Calculates the length of this arc.
protected  double[] getArcParameters()
          Returns the parameters for the arc calculated from the three points.
 Point2D.Double getArcPoint(double t)
          This routine returns an arc point that is t * arcLength away from P1.
 Point2D.Double getCenterPoint()
          Get the center point of the circle that contains the arc.
 Point2D.Double getEquidistantPoint(int i, int n)
          Get equidistant points on the arc.
 Point2D.Float[] getEquidistantPoints(int n)
          Get equidistant points on the arc.
 Point2D.Double getMidArcPoint()
          Calculates the point in the middle of the arc.
 double getOpeningAngle()
          Calculates the opening angle of this arc.
 double getRadius()
          Calculates the radius of this arc.
 boolean isClockwise()
          Determines the 'handed-ness' of this arc, ie whether the three points (in click order) lie in clock- or anti-clockwise direction.
 boolean isCopy(JaxoObject comp)
          Determines if this JaxoObject is a copy of the specified one.
 boolean isSingular()
          Checks if this arc is singular.
 void paintVisualAid(JaxoGraphics2D g2)
          Paints a visual aid for the user during dragging (moving or resizing) of this JaxoObject.
 void setArcPts(int x1, int y1, int x2, int y2, int p3, int q3)
          Deprecated. unused. Use Jaxo3PointObject.setLocation(int,int,int,int,int,int) instead.
 void setState(JaxoObject o)
          Restore state to the values of 'o'.
protected  boolean tooSingular(double epsilon)
          Tests if the current arc is too close to the singularity where all three points are aligned and the middle click-point (P2) is on the outside from the other two.
 
Methods inherited from class net.sf.jaxodraw.object.Jaxo3PointObject
canBeSelected, copyFrom, getGrabbedHandle, getPointCount, getX, getX3, getY, getY3, isOneLine, moveBy, paintHandles, rescaleObject, set3Pts, setLocation, setX, setX3, setY, setY3, smallestDistanceTo
 
Methods inherited from class net.sf.jaxodraw.object.JaxoParticleObject
arrowPositionIs, copy, copyFrom, dashIs, dlSepIs, getAmp, getArrow, getArrowPosition, getDash, getDLSeparation, getWiggles, isDoubleLine, isFlip, isPaintArrow, paintArrow, setAmp, setArrow, setArrowPosition, setDash, setDLSeparation, setDoubleLine, setFlip, setPaintArrow, setPreferences, setWiggles
 
Methods inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
copyFrom, getHeight, getRelh, getRelSize, getRelw, getSize, getStroke, getStrokeWidth, getWidth, getX2, getY2, latexWidth, resetStroke, setLocation, setRadius, setRelativeHeight, setRelativeWidth, setRelWAndH, setStroke, setStrokeWidth, setX2, setY2, strokeIs
 
Methods inherited from class net.sf.jaxodraw.object.JaxoObject
addPropertyChangeListener, contains, contains, contains, contains, copyFrom, firePropertyChange, getBounds2D, getBoundsWithHandles, getColor, getGeneralPath, getLaTexLocation, getName, getPathIterator, getPathIterator, getPoints, getX, getY, intersects, intersects, isAround, isMarked, latexCommand, paint, prepareEditPanel, propertyChange, removePropertyChangeListener, setAsMarked, setColor, setLocation, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setPointCount, setPoints, setTransient, setX, setXPosition, setY, setYPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
getBounds
 

Constructor Detail

JaxoArcObject

public JaxoArcObject()
Method Detail

setArcPts

public final void setArcPts(int x1,
                            int y1,
                            int x2,
                            int y2,
                            int p3,
                            int q3)
Deprecated. unused. Use Jaxo3PointObject.setLocation(int,int,int,int,int,int) instead.

Sets the points of this arc.

Parameters:
x1 - The x coordinate of the first click point of this arc.
y1 - The y coordinate of the first click point of this arc.
x2 - The x coordinate of the second click point of this arc.
y2 - The y coordinate of the second click point of this arc.
p3 - The x coordinate of the third click point of this arc.
q3 - The y coordinate of the third click point of this arc.

isCopy

public boolean isCopy(JaxoObject comp)
Determines if this JaxoObject is a copy of the specified one.

Overrides:
isCopy in class Jaxo3PointObject
Parameters:
comp - The JaxoObject to compare against.
Returns:
True if the JaxoObjects are identical.

setState

public void setState(JaxoObject o)
Restore state to the values of 'o'. The object 'o' must be an object of the same "type" obtained by JaxoObject.copy().

Overrides:
setState in class JaxoParticleObject
Parameters:
o - the object to copy from.

paintVisualAid

public void paintVisualAid(JaxoGraphics2D g2)
Paints a visual aid for the user during dragging (moving or resizing) of this JaxoObject.

Overrides:
paintVisualAid in class JaxoObject
Parameters:
g2 - The graphics context to paint the visual aid.

getArcParameters

protected final double[] getArcParameters()
Returns the parameters for the arc calculated from the three points.

Returns:
An array with 5 elements: {cx, cy, r, oa, sa} where cx = center-x, cy = center-y, r = radius, oa = opening angle, sa = start angle. The start angle is the angle of the first click point with respect to the center point, and the opening angle is negative (positive) for clockwise (anti-clockwise) arcs. Angles are returned in degrees.

isSingular

public boolean isSingular()
Checks if this arc is singular.

An arc is considered singular if its arc length goes to infinity. This is the case when all three points are co-linear and the middle click-point is on the outside from the other two. In practice it is checked if the angle at the middle click-point is below a cutoff value of one degree.

Note that there is another type of singularity where the arc radius goes to infinity while the arc length stays finite. This is the case when the three points are co-linear and the middle click-point is between the other two. Such an arc is not considered singular, it only degenerates into a line.

Arc-specific methods generally return simplified values for singular arcs, eg the radius is set to infinity, so one should call this method first to make sure that returned values can be expected to be accurate.

Returns:
true if the angle at P2 is smaller than one degree.

tooSingular

protected boolean tooSingular(double epsilon)
Tests if the current arc is too close to the singularity where all three points are aligned and the middle click-point (P2) is on the outside from the other two.

Parameters:
epsilon - upper bound for the angle at P2 (in radians).
Returns:
true if the angle at P2 is smaller than epsilon.

arrowCoordinates

public JaxoArrow.Coordinates arrowCoordinates()
Returns the coordinates of the arrow of the current object.

Specified by:
arrowCoordinates in class JaxoParticleObject
Returns:
The coordinates of the arrow of the current object.

isClockwise

public final boolean isClockwise()
Determines the 'handed-ness' of this arc, ie whether the three points (in click order) lie in clock- or anti-clockwise direction. A straight line and a singular arc are considered clock-wise.

Returns:
True if this is a clock-wise arc, false otherwise.

getArcLength

public final double getArcLength()
Calculates the length of this arc.

Returns:
The length of this arc. If the arc is singular, Double.POSITIVE_INFINITY is returned.

getOpeningAngle

public final double getOpeningAngle()
Calculates the opening angle of this arc. For clockwise arcs this angle is positive, for anti-clockwise arcs it is negative.

Returns:
The opening angle of this arc in radians. If the arc is singular, 2 * PI is returned. If the three arc points are co-linear, 0 is returned.

getRadius

public final double getRadius()
Calculates the radius of this arc.

Overrides:
getRadius in class JaxoExtendedObject
Returns:
The radius of this arc. If the arc is singular or the three arc points are co-linear, Double.POSITIVE_INFINITY is returned.

getEquidistantPoint

public final Point2D.Double getEquidistantPoint(int i,
                                                int n)
Get equidistant points on the arc. We divide the arc into n equidistant segments of length d, so n * d = l is the total length of the arc. This routine returns an arc point that is i * d away from P1.

Parameters:
i - The index of the point to return.
n - The number of segments to divide the arc.
Returns:
A point on the arc. If the arc is singular, a point with arguments NaN is returned.

getEquidistantPoints

public Point2D.Float[] getEquidistantPoints(int n)
Get equidistant points on the arc. Dividing the arc into n equidistant segments of length d, so n * d = l is the total length of the arc, this routine returns the n+1 arc points that are i * d away from P1, where 0 <= i <= n.

Parameters:
n - The number of segments to divide the arc.
Returns:
The equidistant points of the arc. If the arc is singular, an array of points with argument NaN is returned.

getArcPoint

public final Point2D.Double getArcPoint(double t)
This routine returns an arc point that is t * arcLength away from P1.

Parameters:
t - The parameter, has to be between 0 and 1.
Returns:
A point on the arc. If the arc is singular, a point witha rguments NaN is returned.

getCenterPoint

public final Point2D.Double getCenterPoint()
Get the center point of the circle that contains the arc.

Returns:
The center point of this arc. If the arc is singular or the three arc points are co-linear, a Point with arguments NaN is returned.

getMidArcPoint

public final Point2D.Double getMidArcPoint()
Calculates the point in the middle of the arc. This is the point halfway between P1 and P3.

Returns:
The mid-arc point of this arc. If the arc is singular, a point with arguments NaN is returned.


Copyright © 2003-2011 The JaxoDraw team. All Rights Reserved.