Class GeomUtil


  • public final class GeomUtil
    extends java.lang.Object
    Some utility methods for working with geometry in Java2D.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GeomUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.geom.Point2D calculateIntersectionPoint​(java.awt.geom.Line2D lineA, java.awt.geom.Line2D lineB)
      Calculates the intersection point of lineA with lineB, possibly null if no intersection point exists (i.e.
      static java.awt.geom.Point2D[] calculateIntersectionPoints​(java.awt.geom.Line2D lineA, java.awt.geom.Line2D... lines)
      For each line in lines, calculates its intersection point with lineA, possibly no intersection point exists (i.e.
      static java.awt.geom.Line2D[] getLines​(java.awt.Shape shape, java.awt.geom.AffineTransform at)
      Returns all line segments building up a shape.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeomUtil

        private GeomUtil()
    • Method Detail

      • calculateIntersectionPoints

        public static java.awt.geom.Point2D[] calculateIntersectionPoints​(java.awt.geom.Line2D lineA,
                                                                          java.awt.geom.Line2D... lines)
        For each line in lines, calculates its intersection point with lineA, possibly no intersection point exists (i.e. parallel lines).
        Parameters:
        lineA - line to calculate the intersection point for.
        lines - lines to calculate the intersection points with.
        Returns:
        all intersections points between lineA and lines.
        See Also:
        calculateIntersectionPoint(Line2D, Line2D)
      • calculateIntersectionPoint

        public static java.awt.geom.Point2D calculateIntersectionPoint​(java.awt.geom.Line2D lineA,
                                                                       java.awt.geom.Line2D lineB)
        Calculates the intersection point of lineA with lineB, possibly null if no intersection point exists (i.e. parallel lines).
        Parameters:
        lineA - the first line for the calculation
        lineB - the second line for the calculation
        Returns:
        the intersection point of lineA with lineB, possibly null if no intersection point exists
      • getLines

        public static java.awt.geom.Line2D[] getLines​(java.awt.Shape shape,
                                                      java.awt.geom.AffineTransform at)
                                               throws java.lang.IllegalArgumentException
        Returns all line segments building up a shape.
        Parameters:
        shape - a shape that is built up of PathIterator.SEG_LINETO elements.
        at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
        Returns:
        all line segments building up the shape
        Throws:
        java.lang.IllegalArgumentException - if shape contains non-straight line segments (i.e. PathIterator.SEG_CUBICTO or PathIterator.SEG_QUADTO)