Class ShapeUtils



  • public class ShapeUtils
    extends Object
    This is a collection of static methods relating to java.awt.Shapes.
    • Constructor Detail

      • ShapeUtils

        public ShapeUtils()
    • Method Detail

      • isValid

        public static boolean isValid(Shape shape)
        Return false if any coordinates in this shape contain NaN or Infinite values.
      • traceShape

        public static GeneralPath traceShape(Shape shape,
                                             float progress)
        This traces the shape provided. This can be used to create a "drawing" effect.

        This assumes every segment is equally important/long, which is not always the case.

        Parameters:
        shape -
        progress - a float from [0,1], indicating what fraction of the shape provided should be traced.
        Returns:
        a portion of the shape provided
      • getPoint

        public static Point2D getPoint(Shape shape,
                                       float progress)
        TSimilar to tracing, this progresses a dot from the beginning to the end of this path.
        Parameters:
        shape -
        progress - a float from [0,1]
      • getSubPathCount

        public static int getSubPathCount(Shape s)
        Returns the number of separate paths in the shape provided.
      • getSubPaths

        public static GeneralPath[] getSubPaths(Shape s)
        Returns each path in s as a separate GeneralPath
      • equals

        public static boolean equals(Shape shape,
                                     Shape shape2)
        Return true if two shapes are equal.
      • isClosed

        public static boolean isClosed(Shape shape)
        Return true if every subpath in the shape provided is closed.
        Parameters:
        shape - the shape to inspect
        Returns:
        true if every subpath in the shape provided ends with a SEG_CLOSE.