Class 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:
  • Constructor Details

    • JaxoArcObject

      public JaxoArcObject()
  • Method Details

    • setArcPts

      public final void setArcPts(int x1, int y1, int x2, int y2, int p3, int q3)
      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 invalid input: '<'= i invalid input: '<'= 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.