Interface Shape2D<ST extends Shape2D<?,​?,​I,​P,​V,​B>,​IT extends Shape2D<?,​?,​I,​P,​V,​B>,​I extends PathIterator2D<?>,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Shape2D<?,​?,​I,​P,​V,​B>>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void clear()
      Reset this shape to be equivalent to an just-created instance of this shape type.
      IT clone()
      Clone this shape.
      boolean contains​(Point2D<?,​?> point)
      Replies if the given point is inside this shape.
      boolean contains​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies if this shape is inside the given shape.
      ST createTransformedShape​(Transform2D transform)
      Apply the transformation to the shape and reply the result.
      static <IT extends Shape2D<?,​?,​?,​?,​?,​?>>
      boolean
      equals​(Shape2D<?,​IT,​?,​?,​?,​?> obj1, Object obj2)
      Do a safe equality test between the two shapes.
      default boolean equalsToPathIterator​(PathIterator2D<?> pathIterator)
      Replies this shape as the same path iterator as the given one.
      boolean equalsToShape​(IT shape)
      Replies this shape is equal to the given shape.
      P getClosestPointTo​(Point2D<?,​?> point)
      Replies the point on the shape that is closest to the given point.
      P getClosestPointTo​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies the point on the shape that is closest to the given shape.
      default double getDistance​(Point2D<?,​?> point)
      Replies the minimal distance from this shape to the given point.
      default double getDistance​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies the minimal distance from this shape to the given shape.
      double getDistanceL1​(Point2D<?,​?> point)
      Computes the L-1 (Manhattan) distance between this shape and point p1.
      double getDistanceLinf​(Point2D<?,​?> point)
      Computes the L-infinite distance between this shape and point p1.
      double getDistanceSquared​(Point2D<?,​?> point)
      Replies the squared value of the minimal distance from this shape to the given point.
      double getDistanceSquared​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies the squared value of the minimal distance from this shape to the given shape.
      P getFarthestPointTo​(Point2D<?,​?> point)
      Replies the point on the shape that is farthest the given point.
      GeomFactory2D<V,​P> getGeomFactory()
      Replies the geometry factory associated to this point.
      default I getPathIterator()
      Replies an iterator on the path elements.
      I getPathIterator​(Transform2D transform)
      Replies the elements of the paths.
      boolean intersects​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies if this shape is intersecting the given shape.
      boolean isEmpty()
      Replies if this shape is empty.
      default void operator_add​(Vector2D<?,​?> v)
      Translate this shape by adding the given vector: this += v
      default boolean operator_and​(Point2D<?,​?> point)
      Replies if the given point is inside the shape: this && b
      default boolean operator_and​(Shape2D<?,​?,​?,​?,​?,​?> shape)
      Replies if the given shape has an intersection with this shape: this && b
      default IT operator_minus​(Vector2D<?,​?> v)
      Create a new shape by translating this shape of the given vector: this - v
      default ST operator_multiply​(Transform2D t)
      Create a new shape by applying the given transformation: this * t
      default IT operator_plus​(Vector2D<?,​?> v)
      Create a new shape by translating this shape of the given vector: this + v
      default void operator_remove​(Vector2D<?,​?> v)
      Translate this shape by substracting the given vector: this -= v
      default double operator_upTo​(Point2D<?,​?> pt)
      Replies the distance between the given point and this shape: this .. p
      void set​(IT shape)
      Set this shape with the attributes of the given shape.
      B toBoundingBox()
      Replies the bounding box of this shape.
      void toBoundingBox​(B box)
      Replies the bounds of the shape.
      void translate​(Vector2D<?,​?> vector)
      Translate the shape.
    • Method Detail

      • getGeomFactory

        @Pure
        GeomFactory2D<V,​P> getGeomFactory()
        Replies the geometry factory associated to this point.
        Returns:
        the factory.
      • isEmpty

        @Pure
        boolean isEmpty()
        Replies if this shape is empty. The semantic associated to the state "empty" depends on the implemented shape. See the subclasses for details.
        Returns:
        true if the shape is empty; false otherwise.
      • clone

        @Pure
        IT clone()
        Clone this shape.
        Returns:
        the clone.
      • equals

        @Pure
        static <IT extends Shape2D<?,​?,​?,​?,​?,​?>> boolean equals​(Shape2D<?,​IT,​?,​?,​?,​?> obj1,
                                                                                              Object obj2)
        Do a safe equality test between the two shapes.

        This function should be used for implementing the Object.equals(Object) functions of the shapes.

        Type Parameters:
        IT - type of the shapes to compare.
        Parameters:
        obj1 - the first object to compare.
        obj2 - the second object to compare.
        Returns:
        true if the two shapes are equal.
        Since:
        13.0
      • equalsToPathIterator

        @Pure
        default boolean equalsToPathIterator​(PathIterator2D<?> pathIterator)
        Replies this shape as the same path iterator as the given one.

        The equality test does not flatten the paths. It means that is function has is functionnality equivalent to:

        
         PathIterator2D it = this.getPathIterator();
         while (it.hasNext() && pathIterator.hasNext()) {
           PathElement2D e1 = it.next();
           PathElement2D e2 = it.next();
           if (!e1.equals(e2)) return false;
         }
         return !it.hasNext() && !pathIterator.hasNext();
         
        Parameters:
        pathIterator - the path iterator to compare to the one of this shape.
        Returns:
        true if the path iterator of this shape replies the same elements as the given path iterator.
      • equalsToShape

        @Pure
        boolean equalsToShape​(IT shape)
        Replies this shape is equal to the given shape.
        Parameters:
        shape - the shape to compare to.
        Returns:
        true if this shape is equal is equal to the given path.
      • clear

        void clear()
        Reset this shape to be equivalent to an just-created instance of this shape type.
      • contains

        @Pure
        boolean contains​(Point2D<?,​?> point)
        Replies if the given point is inside this shape.
        Parameters:
        point - the point.
        Returns:
        true if the given shape is intersecting this shape, otherwise false.
      • contains

        @Pure
        boolean contains​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies if this shape is inside the given shape.

        You must use the containing functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.

        Parameters:
        shape - the shape to compare to.
        Returns:
        true if the given shape is inside this shape; false otherwise.
      • getClosestPointTo

        @Pure
        P getClosestPointTo​(Point2D<?,​?> point)
        Replies the point on the shape that is closest to the given point.
        Parameters:
        point - the point.
        Returns:
        the closest point on the shape; or the point itself if it is inside the shape.
      • getClosestPointTo

        @Pure
        P getClosestPointTo​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies the point on the shape that is closest to the given shape.

        If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.

        Parameters:
        shape - the shape.
        Returns:
        the closest point on the shape.
      • getFarthestPointTo

        @Pure
        P getFarthestPointTo​(Point2D<?,​?> point)
        Replies the point on the shape that is farthest the given point.
        Parameters:
        point - the point.
        Returns:
        the farthest point on the shape.
      • getDistance

        @Pure
        default double getDistance​(Point2D<?,​?> point)
        Replies the minimal distance from this shape to the given point.
        Parameters:
        point - the point.
        Returns:
        the minimal distance between this shape and the point.
      • getDistance

        @Pure
        default double getDistance​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies the minimal distance from this shape to the given shape.
        Parameters:
        shape - the shape.
        Returns:
        the minimal distance between this shape and the given shape.
      • getDistanceSquared

        @Pure
        double getDistanceSquared​(Point2D<?,​?> point)
        Replies the squared value of the minimal distance from this shape to the given point.
        Parameters:
        point - the point.
        Returns:
        squared value of the minimal distance between this shape and the point.
      • getDistanceSquared

        @Pure
        double getDistanceSquared​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies the squared value of the minimal distance from this shape to the given shape.
        Parameters:
        shape - the shape.
        Returns:
        squared value of the minimal distance between this shape and the given shape.
      • getDistanceL1

        @Pure
        double getDistanceL1​(Point2D<?,​?> point)
        Computes the L-1 (Manhattan) distance between this shape and point p1. The L-1 distance is equal to abs(x1-x2) + abs(y1-y2).
        Parameters:
        point - the point
        Returns:
        the distance.
      • getDistanceLinf

        @Pure
        double getDistanceLinf​(Point2D<?,​?> point)
        Computes the L-infinite distance between this shape and point p1. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].
        Parameters:
        point - the point
        Returns:
        the distance.
      • set

        void set​(IT shape)
        Set this shape with the attributes of the given shape.
        Parameters:
        shape - the shape to copy.
      • getPathIterator

        @Pure
        default I getPathIterator()
        Replies an iterator on the path elements.

        The iterator for this class is not multi-threaded safe.

        Returns:
        an iterator on the path elements.
      • getPathIterator

        @Pure
        I getPathIterator​(Transform2D transform)
        Replies the elements of the paths.
        Parameters:
        transform - is the transformation to apply to the path.
        Returns:
        the elements of the path.
      • createTransformedShape

        @Pure
        ST createTransformedShape​(Transform2D transform)
        Apply the transformation to the shape and reply the result. This function does not change the current shape.
        Parameters:
        transform - is the transformation to apply to the shape.
        Returns:
        the result of the transformation.
      • translate

        void translate​(Vector2D<?,​?> vector)
        Translate the shape.
        Parameters:
        vector - the translation vector.
      • toBoundingBox

        @Pure
        B toBoundingBox()
        Replies the bounding box of this shape.
        Returns:
        the bounding box of this shape.
      • toBoundingBox

        void toBoundingBox​(B box)
        Replies the bounds of the shape.
        Parameters:
        box - is set with the bounds of the shape.
      • intersects

        @Pure
        boolean intersects​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies if this shape is intersecting the given shape.

        You must use the intersection functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.

        Parameters:
        shape - the shape to compare to.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • operator_add

        default void operator_add​(Vector2D<?,​?> v)
        Translate this shape by adding the given vector: this += v

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        v - the vector
        See Also:
        translate(Vector2D)
      • operator_plus

        @Pure
        default IT operator_plus​(Vector2D<?,​?> v)
        Create a new shape by translating this shape of the given vector: this + v

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        v - the vector
        Returns:
        the transformed shape.
        See Also:
        translate(Vector2D)
      • operator_remove

        default void operator_remove​(Vector2D<?,​?> v)
        Translate this shape by substracting the given vector: this -= v

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        v - the vector
        See Also:
        translate(Vector2D)
      • operator_minus

        @Pure
        default IT operator_minus​(Vector2D<?,​?> v)
        Create a new shape by translating this shape of the given vector: this - v

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        v - the vector
        Returns:
        the transformed shape.
        See Also:
        translate(Vector2D)
      • operator_multiply

        @Pure
        default ST operator_multiply​(Transform2D t)
        Create a new shape by applying the given transformation: this * t

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        t - the transformation
        Returns:
        the transformed shape.
        See Also:
        createTransformedShape(Transform2D)
      • operator_and

        @Pure
        default boolean operator_and​(Point2D<?,​?> point)
        Replies if the given point is inside the shape: this && b

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        point - the point to test.
        Returns:
        true if the point is inside the shape. Otherwise, false.
        See Also:
        createTransformedShape(Transform2D)
      • operator_and

        @Pure
        default boolean operator_and​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Replies if the given shape has an intersection with this shape: this && b

        You must use the intersection functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        shape - the shape to test.
        Returns:
        true if the shapes are intersecting. Otherwise, false.
        See Also:
        intersects(Shape2D)
      • operator_upTo

        @Pure
        default double operator_upTo​(Point2D<?,​?> pt)
        Replies the distance between the given point and this shape: this .. p

        This function is an implementation of the operator for the languages that defined or based on the Xtext framework.

        Parameters:
        pt - the point to test.
        Returns:
        the distance.
        See Also:
        getDistance(Point2D)