Class PointListUtils

java.lang.Object
org.eclipse.gef.geometry.internal.utils.PointListUtils

public class PointListUtils extends Object
Common utilities for point manipulations as needed e.g. within Polygon and Polyline.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    Converts a given array of Point into an array of doubles containing the x and y coordinates of the given points, where the x and y coordinates of the n-th Point can be found at positions 2*n and 2*n+1.
    static int[]
    toIntegerArray(double[] doubles)
    Converts an array of double values into an array of integer values by casting them.
    static Point[]
    toPointsArray(double[] coordinates)
    Converts a given array of x/y coordinate values into an array of Points.
    static Point[]
    toPointsArray(Line[] segmentsArray, boolean open)
    Transforms a sequence of Lines into a list of Points.
    static Line[]
    toSegmentsArray(Point[] points, boolean close)
    Transforms a sequence of Point coordinates into a sequence of Line segments, by creating a Line segment for each two adjacent points in the array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toCoordinatesArray

      public static double[] toCoordinatesArray(Point[] points)
      Converts a given array of Point into an array of doubles containing the x and y coordinates of the given points, where the x and y coordinates of the n-th Point can be found at positions 2*n and 2*n+1.
      Parameters:
      points - an array of Points to convert
      Returns:
      a new array of doubles, containing the x and y coordinates of the given Points
    • toIntegerArray

      public static int[] toIntegerArray(double[] doubles)
      Converts an array of double values into an array of integer values by casting them.
      Parameters:
      doubles - an array of doubles to convert
      Returns:
      a new array of integer values, which is created by casting the double values
    • toPointsArray

      public static Point[] toPointsArray(double[] coordinates)
      Converts a given array of x/y coordinate values into an array of Points.
      Parameters:
      coordinates - The array of coordinates.
      Returns:
      a new array of Points, representing the given x and y coordinates
    • toPointsArray

      public static Point[] toPointsArray(Line[] segmentsArray, boolean open)
      Transforms a sequence of Lines into a list of Points. Consecutive Lines are expected to share one of their end Points. The start Points of the Lines are returned. Additionally, the end Point of the last Line is returned, too if the given boolean flag open is set to false.
      Parameters:
      segmentsArray - The array of Lines.
      open - indicates whether to omit the end Point of the last Line
      Returns:
      the start Points of the Lines and the end Point of the last Line according to open
    • toSegmentsArray

      public static Line[] toSegmentsArray(Point[] points, boolean close)
      Transforms a sequence of Point coordinates into a sequence of Line segments, by creating a Line segment for each two adjacent points in the array. In case it is specified to close the segment list, a Line segment is furthermore created between the last and the first point in the list.
      Parameters:
      points - the array of Points to convert
      close - a flag indicating whether a line segment will be created from the last point in the list back to the first one
      Returns:
      an array of Line segments, which is created by creating a Line for each two adjacent Points in the given array, which includes a Line segment between the last point in the given array in the first one, if and only if the parameter close is given as true