Class TLcdXYArc

All Implemented Interfaces:
ILcdArc, ILcdBounded, ILcdCurve, ILcdShape, ILcd2DEditableArc, ILcd2DEditableShape, ILcdCache, ILcdCloneable, Serializable, Cloneable
Direct Known Subclasses:
TLcdCGMArc, TLcdDGNArc2D, TLcdDWGArc, TLcdDWGEllipse

public class TLcdXYArc extends ALcd2DEditableShape implements ILcd2DEditableArc, ILcdCurve, ILcdCache
This class provides an implementation of ILcd2DEditableArc in the cartesian space.

It implements ILcdCache, thus providing a cache to store expensive calculations, e.g. for painters, to store model-world transformations. The cache is cleared whenever the shape is modified.

This class is thread-safe for concurrent read-only access of its contents. For read-write access, external locking must be used. Such locking is typically done at the model level.

See Also:
  • Constructor Details

    • TLcdXYArc

      public TLcdXYArc()
      Creates a new full TLcdXYArc with all other parameters set to 0.
    • TLcdXYArc

      public TLcdXYArc(ILcd2DEditableArc aArc)
      Creates a new TLcdXYArc with its parameters copied from the given arc.
      Parameters:
      aArc - the arc from which the parameters are copied.
    • TLcdXYArc

      public TLcdXYArc(ILcdPoint aCenter, double aA, double aB, double aRotAngle, double aStartAngle, double aArcAngle)
      Creates a new TLcdXYArc with the specified parameters.
      Parameters:
      aCenter - the center of the arc.
      aA - the length of the semi-major axis.
      aB - the length of the semi-minor axis.
      aRotAngle - the rotation angle (in degrees).
      aStartAngle - the start angle (in degrees).
      aArcAngle - the arc angle (in degrees).
      Throws:
      IllegalArgumentException - if the length of the semi-major axis or the semi-minor axis of the ellipse on which this arc resides is negative.
    • TLcdXYArc

      public TLcdXYArc(double aCenterX, double aCenterY, double aA, double aB, double aRotAngle, double aStartAngle, double aArcAngle)
      Creates a new TLcdXYArc with the specified parameters.
      Parameters:
      aCenterX - the x coordinate of the center.
      aCenterY - the y coordinate of the center.
      aA - the length of the semi-major axis.
      aB - the length of the semi-minor axis.
      aRotAngle - the rotation angle (in degrees).
      aStartAngle - the start angle (in degrees).
      aArcAngle - the sweep angle (in degrees).
      Throws:
      IllegalArgumentException - if the length of the semi-major axis or the semi-minor axis of the ellipse on which this arc resides is negative.
  • Method Details

    • getCenter

      public ILcdPoint getCenter()
      Description copied from interface: ILcdArc
      Returns the center of this ILcdArc.
      Specified by:
      getCenter in interface ILcdArc
      Returns:
      the center of this ILcdArc.
    • getA

      public final double getA()
      Description copied from interface: ILcdArc
      Returns the length of the semi-major axis.
      Specified by:
      getA in interface ILcdArc
      Returns:
      the length of the semi-major axis.
    • setA

      public void setA(double aA)
      Sets the length of the semi-major axis of the ellipse on which this arc resides. This value must not be negative.
      Specified by:
      setA in interface ILcd2DEditableArc
      Parameters:
      aA - the length of the semi-major axis (in meters) of the ellipse on which this arc resides. This value may not be negative.
      Throws:
      IllegalArgumentException - if the length of the semi-major axis of the ellipse on which this arc resides is negative.
    • getB

      public final double getB()
      Description copied from interface: ILcdArc
      Returns the length of the semi-minor axis.
      Specified by:
      getB in interface ILcdArc
      Returns:
      the length of the semi-minor axis.
    • setB

      public void setB(double aB)
      Sets the length of the semi-minor axis of the ellipse on which this arc resides. This value must not be negative.
      Specified by:
      setB in interface ILcd2DEditableArc
      Parameters:
      aB - the length of the semi-minor axis (in meters) of the ellipse on which this arc resides. This value may not be negative.
      Throws:
      IllegalArgumentException - if the length of the semi-minor axis of the ellipse on which this arc resides is negative.
    • getRotAngle

      public final double getRotAngle()
      Description copied from interface: ILcdArc
      Returns the rotation angle of the major axis (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
      Specified by:
      getRotAngle in interface ILcdArc
      Returns:
      the rotation angle of the major axis (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
    • setRotAngle

      public void setRotAngle(double aRotAngle)
      Description copied from interface: ILcd2DEditableArc
      Sets the rotation angle of the major axis (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
      Specified by:
      setRotAngle in interface ILcd2DEditableArc
      Parameters:
      aRotAngle - the new rotation angle.
    • getStartAngle

      public final double getStartAngle()
      Description copied from interface: ILcdArc
      Returns the start angle of the arc (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
      Specified by:
      getStartAngle in interface ILcdArc
      Returns:
      the start angle of the arc (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
    • setStartAngle

      public void setStartAngle(double aStartAngle)
      Description copied from interface: ILcd2DEditableArc
      Sets the start angle of the arc (in degrees). The angle is measured from 3 o'clock position, positive counter-clockwise.
      Specified by:
      setStartAngle in interface ILcd2DEditableArc
      Parameters:
      aStartAngle - the new start angle.
    • getArcAngle

      public final double getArcAngle()
      Description copied from interface: ILcdArc
      Returns the angle over which the arc extends (in degrees). The angle is positive counter-clockwise.
      Specified by:
      getArcAngle in interface ILcdArc
      Returns:
      the angle over which the arc extends (in degrees). The angle is positive counter-clockwise.
    • setArcAngle

      public void setArcAngle(double aArcAngle)
      Description copied from interface: ILcd2DEditableArc
      Sets the angle over which the arc extends (in degrees). The angle is positive counter-clockwise.
      Specified by:
      setArcAngle in interface ILcd2DEditableArc
      Parameters:
      aArcAngle - the new arc angle.
    • getFocusPoint

      public ILcdPoint getFocusPoint()
      Description copied from interface: ILcdShape
      Returns the focus point of this ILcdShape.
      Specified by:
      getFocusPoint in interface ILcdShape
      Returns:
      the focus point of this ILcdShape.
    • corner2DEditablePointSFCT

      public void corner2DEditablePointSFCT(int aCorner, ILcd2DEditablePoint a2DEditablePointSFCT)
      Description copied from interface: ILcdArc
      Computes the position of the specified corner of this ILcdArc.
      Specified by:
      corner2DEditablePointSFCT in interface ILcdArc
      Parameters:
      aCorner - the corner: ILcdArc.MAJOR_RADIUS_CORNER, ILcdArc.MINOR_RADIUS_CORNER, ILcdArc.MAJOR_RADIUS_OPPOSITE_CORNER, ILcdArc.MINOR_RADIUS_OPPOSITE_CORNER, ILcdArc.ARC_START_CORNER, or ILcdArc.ARC_END_CORNER.
      a2DEditablePointSFCT - an ILcd2DEditablePoint into which the result is written as a side-effect.
    • updateForCornerPoint2D

      public void updateForCornerPoint2D(int aCorner, ILcdPoint aPoint)
      Description copied from interface: ILcd2DEditableArc
      Updates the arc for the specified corner point location. The end points of the axis points should be at the specified location on return of this method. For the start and end point corner only the start and arc angle have to updated.
      Specified by:
      updateForCornerPoint2D in interface ILcd2DEditableArc
      Parameters:
      aCorner - a constant indicating which corner is to be moved: ILcdArc.MAJOR_RADIUS_CORNER, ILcdArc.MINOR_RADIUS_CORNER, ILcdArc.MAJOR_RADIUS_OPPOSITE_CORNER, ILcdArc.MINOR_RADIUS_OPPOSITE_CORNER, ILcdArc.ARC_START_CORNER, or ILcdArc.ARC_END_CORNER.
      aPoint - the new coordinate of the point.
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdBounded
      Returns the ILcdBounds by which the geometry of this ILcdBounded object is bounded.

      If the geometry does not allow retrieving valid bounds (for example a polyline with 0 points) the return value is unspecified. It is highly recommended to return an undefined bounds. You can create undefined bounds using the default constructors of TLcdLonLatBounds or TLcdXYBounds.

      Specified by:
      getBounds in interface ILcdBounded
      Returns:
      the ILcdBounds by which the geometry of this ILcdBounded object is bounded.
    • invalidateBounds

      protected void invalidateBounds()
    • contains2D

      public boolean contains2D(double aX, double aY)
      Description copied from interface: ILcdShape
      Checks whether this ILcdShape contains the given point in the 2D space. Only the first two dimensions of the ILcdShape are considered.
      Specified by:
      contains2D in interface ILcdShape
      Parameters:
      aX - the x coordinate of the point.
      aY - the y coordinate of the point.
      Returns:
      the boolean result of the containment test.
    • translate2D

      public void translate2D(double x, double y)
      Description copied from interface: ILcd2DEditableShape
      Translates this ILcd2DEditableShape from its current position over the given translation vector in the 2D space. Only the first two dimensions of the ILcdShape are considered. The third dimension is left unchanged.
      Specified by:
      translate2D in interface ILcd2DEditableShape
      Parameters:
      x - the x coordinate of the translation vector.
      y - the y coordinate of the translation vector.
    • move2D

      public void move2D(double x, double y)
      Description copied from class: ALcd2DEditableShape
      Translates this shape so that its focus point ends up at the specified position.
      Specified by:
      move2D in interface ILcd2DEditableShape
      Overrides:
      move2D in class ALcd2DEditableShape
      Parameters:
      x - the x coordinate of the point.
      y - the y coordinate of the point.
    • getStartPoint

      public ILcdPoint getStartPoint()
      Description copied from interface: ILcdCurve
      Retrieves the start point of the curve.

      This is equivalent to computePointSFCT(0).

      Specified by:
      getStartPoint in interface ILcdCurve
      Returns:
      the start point of the curve
    • getEndPoint

      public ILcdPoint getEndPoint()
      Description copied from interface: ILcdCurve
      Retrieves the end point of the curve.

      This is equivalent to computePointSFCT(1).

      Specified by:
      getEndPoint in interface ILcdCurve
      Returns:
      the end point of the curve
    • getStartTangent2D

      public double getStartTangent2D()
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent at the start point, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the start point towards the rest of the shape.

      This is the same as getTangent2D(0).

      Specified by:
      getStartTangent2D in interface ILcdCurve
      Returns:
      the curve's angle in the start point
    • getEndTangent2D

      public double getEndTangent2D()
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent at the end point, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the end point, away from the curve before it.

      This is the same as getTangent2D(1).

      Specified by:
      getEndTangent2D in interface ILcdCurve
      Returns:
      the curve's angle in the end point
    • getTangent2D

      public double getTangent2D(double aParam)
      Description copied from interface: ILcdCurve
      Returns the angle of the curve's tangent in the point defined by the given parameter, in degrees counterclockwise from the direction at 3 o'clock.

      The tangent orientation is from the point at parameter aParam towards the rest of the shape.

      Specified by:
      getTangent2D in interface ILcdCurve
      Parameters:
      aParam - a value of the closed interval [0,1]
      Returns:
      the curve's angle in the point defined by the given parameter
    • getLength2D

      public double getLength2D(double aParam1, double aParam2)
      Description copied from interface: ILcdCurve
      Returns the length between two points of the curve, defined by the given parameters.
      • When aParam1 == aParam2, the length is 0.
      • When aParam1 == 0 and aParam2 == 1, the length is the whole length of the curve.
      • When aParam1 > aParam2, the length is (aParam1 to 1) + (0 to aParam2).
      Specified by:
      getLength2D in interface ILcdCurve
      Parameters:
      aParam1 - a value of the closed interval [0,1]
      aParam2 - a value of the closed interval [0,1]
      Returns:
      the length of the curve.
    • getInterpolation

      public String getInterpolation()
      Returns the interpolation method used by this curve, which is ILcdCurve.INTERPOLATION_ELLIPTICAL.
      Specified by:
      getInterpolation in interface ILcdCurve
      Returns:
      the interpolation method used by this curve, which is INTERPOLATION_ELLIPTICAL.
    • computePointSFCT

      public void computePointSFCT(double aParam, ILcd3DEditablePoint aPointSFCT)
      Description copied from interface: ILcdCurve
      Computes a point of the curve, defined by the given parameter.
      Specified by:
      computePointSFCT in interface ILcdCurve
      Parameters:
      aParam - a value of the closed interval [0,1]
      aPointSFCT - the point to store the computed curve point in
    • insertIntoCache

      public void insertIntoCache(Object aKey, Object aObject)
      Description copied from interface: ILcdCache
      Inserts a cache Object corresponding to the given key Object.
      Specified by:
      insertIntoCache in interface ILcdCache
      Parameters:
      aKey - the key Object that will be used to identify the Object. The key must therefore be a unique identifier, typically the caller itself: insertIntoCache(this, ...).
      aObject - the Object to be cached.
    • getCachedObject

      public Object getCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and returns the cached Object corresponding to the given key.
      Specified by:
      getCachedObject in interface ILcdCache
      Parameters:
      aKey - the key Object that was used for storing the cache Object.
      Returns:
      the cached Object, or null if there is no Object corresponding to the given key.
    • removeCachedObject

      public Object removeCachedObject(Object aKey)
      Description copied from interface: ILcdCache
      Looks up and removes the cached Object corresponding to the given key.
      Specified by:
      removeCachedObject in interface ILcdCache
      Parameters:
      aKey - the key Object that was used for storing the cache Object.
      Returns:
      the cached Object, or null if there was no Object corresponding to the given key.
    • clearCache

      public void clearCache()
      Description copied from interface: ILcdCache
      Clears the cache.
      Specified by:
      clearCache in interface ILcdCache
    • clone

      public Object clone()
      Creates and returns a copy of this object.

      The contained center point is cloned.

      The cache is not copied or cloned at all.

      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class ALcdShape
      See Also:
    • equals

      public boolean equals(Object aObject)
      Returns whether the given object has the same class and the same coordinates and parameters.
      Overrides:
      equals in class ALcdShape
    • hashCode

      public int hashCode()
      Description copied from class: ALcdShape
      The hash code of this shape is the hash code of its class, in order to be consistent with the ALcdShape.equals(Object) method. Extensions should refine this implementation, based on their properties.
      Overrides:
      hashCode in class ALcdShape
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLineSegmentIntersectionCount

      public int getLineSegmentIntersectionCount(ILcdPoint aP1, ILcdPoint aP2)
      Description copied from interface: ILcdCurve
      Returns the number of intersections between this curve and a line segment defined by the two specified points.

      This information can be used to perform containment calculations, if this curve is closed or if this curve is part of a composite closed curve. By determining the number of intersections between this curve and a line segment starting from a given point in a fixed direction, one can determine whether a point is located within the closed curve by using the even-odd rule.

      Specified by:
      getLineSegmentIntersectionCount in interface ILcdCurve
      Parameters:
      aP1 - the first point of the line segment
      aP2 - the second point of the line segment
      Returns:
      the number of intersections between the curve and the line segment