Class LineSegment

java.lang.Object
com.esri.arcgisruntime.geometry.Segment
com.esri.arcgisruntime.geometry.LineSegment

public final class LineSegment extends Segment
Represents a straight line between a start and end Point.

LineSegments are used to represent the edges of Polygons and Polylines. The SpatialReference of a LineSegment will be null if one is not set in its constructor. If subsequently added to a Part, it will take on the SpatialReference of that part.

LineSegment is immutable. Create new instances by using the constructors and factory methods, instead of changing the properties of an existing LineSegment.

Since:
100.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    LineSegment(double startX, double startY, double endX, double endY)
    Creates a new LineSegment with start and end points at the given x,y coordinates.
    LineSegment(double startX, double startY, double startZ, double endX, double endY, double endZ)
    Creates a new LineSegment with start and end points at the given x,y coordinates and z value.
    LineSegment(double startX, double startY, double startZ, double endX, double endY, double endZ, SpatialReference spatialReference)
    Creates a new LineSegment with start and end points at the given x,y coordinates, z value, and the given SpatialReference.
    LineSegment(double startX, double startY, double endX, double endY, SpatialReference spatialReference)
    Creates a new LineSegment with start and end points at the given x,y coordinates, and the given SpatialReference.
    LineSegment(Point startPoint, Point endPoint)
    Creates a new LineSegment with the given start and end Points.
    LineSegment(Point startPoint, Point endPoint, SpatialReference spatialReference)
    Creates a new line segment with the given start and end Points, and SpatialReference.
  • Method Summary

    Modifier and Type
    Method
    Description
    createLineAtAngleFromPoint(Point startPoint, double angleRadians, double length)
    Creates a new LineSegment with the given start Point, and the given length and angle from the start Point.
    Returns a string representation of this LineSegment instance.

    Methods inherited from class com.esri.arcgisruntime.geometry.Segment

    getEndPoint, getSpatialReference, getStartPoint, isClosed, isCurve

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LineSegment

      public LineSegment(double startX, double startY, double endX, double endY)
      Creates a new LineSegment with start and end points at the given x,y coordinates. The SpatialReference of the new LineSegment will be null.
      Parameters:
      startX - the x coordinate of the start Point of the new LineSegment
      startY - the y coordinate of the start Point of the new LineSegment
      endX - the x coordinate of the end Point of the new LineSegment
      endY - the y coordinate of the end Point of the new LineSegment
      Since:
      100.0.0
    • LineSegment

      public LineSegment(double startX, double startY, double endX, double endY, SpatialReference spatialReference)
      Creates a new LineSegment with start and end points at the given x,y coordinates, and the given SpatialReference.
      Parameters:
      startX - the x coordinate of the start Point of the new LineSegment
      startY - the y coordinate of the start Point of the new LineSegment
      endX - the x coordinate of the end Point of the new LineSegment
      endY - the y coordinate of the end Point of the new LineSegment
      spatialReference - the SpatialReference of the new LineSegment, and of the x,y coordinates
      Since:
      100.0.0
    • LineSegment

      public LineSegment(double startX, double startY, double startZ, double endX, double endY, double endZ)
      Creates a new LineSegment with start and end points at the given x,y coordinates and z value.
      Parameters:
      startX - the x coordinate of the start Point of the new LineSegment
      startY - the y coordinate of the start Point of the new LineSegment
      startZ - the z value of the start Point of the new LineSegment
      endX - the x coordinate of the end Point of the new LineSegment
      endY - the y coordinate of the end Point of the new LineSegment
      endZ - the z value of the end Point of the new LineSegment
      Since:
      100.1.0
    • LineSegment

      public LineSegment(double startX, double startY, double startZ, double endX, double endY, double endZ, SpatialReference spatialReference)
      Creates a new LineSegment with start and end points at the given x,y coordinates, z value, and the given SpatialReference.
      Parameters:
      startX - the x coordinate of the start Point of the new LineSegment
      startY - the y coordinate of the start Point of the new LineSegment
      startZ - the z value of the start Point of the new LineSegment
      endX - the x coordinate of the end Point of the new LineSegment
      endY - the y coordinate of the end Point of the new LineSegment
      endZ - the z value of the end Point of the new LineSegment
      spatialReference - the SpatialReference of the new LineSegment, and of the x,y coordinates
      Since:
      100.1.0
    • LineSegment

      public LineSegment(Point startPoint, Point endPoint)
      Creates a new LineSegment with the given start and end Points. The SpatialReference of the new LineSegment will be null.
      Parameters:
      startPoint - the start Point of the new LineSegment
      endPoint - the end Point of the new LineSegment
      Throws:
      ArcGISRuntimeException - if the SpatialReference of both the Points supplied are non-null and differ.
      Since:
      100.0.0
    • LineSegment

      public LineSegment(Point startPoint, Point endPoint, SpatialReference spatialReference)
      Creates a new line segment with the given start and end Points, and SpatialReference.

      The spatial reference parameter is used if the points have a null spatial reference. If more than one spatial reference is supplied (as a parameter or as a property of a Point parameter), they must all be equal.

      Parameters:
      startPoint - the start Point of the new LineSegment
      endPoint - the end Point of the new LineSegment
      spatialReference - the SpatialReference of the new LineSegment
      Throws:
      ArcGISRuntimeException - if the SpatialReference of the Points and the SpatialReference parameters are non-null and differ.
      Since:
      100.0.0
  • Method Details

    • createLineAtAngleFromPoint

      public static LineSegment createLineAtAngleFromPoint(Point startPoint, double angleRadians, double length)
      Creates a new LineSegment with the given start Point, and the given length and angle from the start Point. The spatial reference of the point is used to determine the segment's spatial reference. The angle is specified in radians relative to the x-axis. The length is in the units of the spatial reference.
      Parameters:
      startPoint - the start Point of the new LineSegment
      angleRadians - the angle, in radians, at which the new LineSegment will be created.
      length - the length of the new LineSegment
      Returns:
      a new LineSegment with the given properties
      Throws:
      IllegalArgumentException - if startPoint is null
      Since:
      100.3.0
    • toString

      public String toString()
      Returns a string representation of this LineSegment instance. The format and content of this string is subject to change without notice.

      This value may be useful for debugging purposes, but cannot be relied upon for persistence purposes.

      Overrides:
      toString in class Object
      Returns:
      a String representation of this segment with useful information for debugging.
      Since:
      100.0.0