Class Line

    • Constructor Detail

      • Line

        public Line​(double... coordinates)
        Constructs a new Line from the given coordinate values.
        Parameters:
        coordinates - A varargs of 4 doubles, providing the x and y coordinates of the start point, followed by those of the end point
        See Also:
        BezierCurve(double[])
      • Line

        public Line​(double x1,
                    double y1,
                    double x2,
                    double y2)
        Constructs a new Line, which connects the two Points given indirectly by their coordinates
        Parameters:
        x1 - the x-coordinate of the start point
        y1 - the y-coordinate of the start point
        x2 - the x-coordinate of the end point
        y2 - the y-coordinate of the end point
      • Line

        public Line​(Point... points)
        Constructs a new Line, which connects the two Points given.
        Parameters:
        points - A varargs of two points serving as the start and end point of this line
      • Line

        public Line​(Point p1,
                    Point p2)
        Constructs a new Line which connects the two given Points
        Parameters:
        p1 - the start point
        p2 - the end point
    • Method Detail

      • equals

        public boolean equals​(double x1,
                              double y1,
                              double x2,
                              double y2)
        Tests whether this Line is equal to the line given implicitly by the given point coordinates.
        Parameters:
        x1 - the x-coordinate of the start point of the line to test
        y1 - the y-coordinate of the start point of the line to test
        x2 - the x-coordinate of the end point of the line to test
        y2 - the y-coordinate of the end point of the line to test
        Returns:
        true if the given start and end point coordinates are (imprecisely) equal to this Line 's start and end point coordinates
      • get

        public Point get​(double t)
        Description copied from class: BezierCurve
        Computes the Point on this BezierCurve at parameter value t, which is expected to lie in the parameter BezierCurve.Interval [0;1].
        Overrides:
        get in class BezierCurve
        Parameters:
        t - the parameter value for which this BezierCurve is evaluated
        Returns:
        the Point on this BezierCurve at the given parameter value
      • getCopy

        public Line getCopy()
        Returns a new Line, which has the same start and end point coordinates as this one.
        Specified by:
        getCopy in interface IGeometry
        Overrides:
        getCopy in class BezierCurve
        Returns:
        a new Line with the same start and end point coordinates
      • getDirectionCCW

        public Angle getDirectionCCW()
        Returns the counter-clockwise angle between the x axis and this Line.
        Returns:
        Returns the counter-clockwise angle between the x axis and this Line.
      • getDirectionCW

        public Angle getDirectionCW()
        Returns the clockwise angle between the x axis and this Line.
        Returns:
        Returns the clockwise angle between the x axis and this Line.
      • getIntersection

        public Point getIntersection​(Line l)
        Returns the single intersection point between this Line and the given one, in case it exists. Note that even in case intersects(org.eclipse.gef.geometry.planar.ICurve) returns true, there may not be a single intersection point in case both lines overlap in more than one point.
        Parameters:
        l - the Line, for which to compute the intersection point
        Returns:
        the single intersection point between this Line and the given one, in case it intersects, null instead
      • getPoints

        public Point[] getPoints()
        Returns an array, which contains two Points representing the start and end points of this Line
        Overrides:
        getPoints in class BezierCurve
        Returns:
        an array with two Points, whose x and y coordinates match those of this Line's start and end point
      • overlaps

        public boolean overlaps​(Line l)
        Tests whether this Line and the given other Line overlap, i.e. they share an infinite number of Points.
        Parameters:
        l - the other Line to test for overlap with this Line
        Returns:
        true if this Line and the other Line overlap, otherwise false
        See Also:
        ICurve.overlaps(ICurve)
      • setLine

        public Line setLine​(double x1,
                            double y1,
                            double x2,
                            double y2)
        Initializes this Line with the given start and end point coordinates
        Parameters:
        x1 - the x-coordinate of the start point
        y1 - the y-coordinate of the start point
        x2 - the x-coordinate of the end point
        y2 - the y-coordinate of the end point
        Returns:
        this for convenience
      • setLine

        public Line setLine​(Line l)
        Initializes this Line with the start and end point coordinates of the given one.
        Parameters:
        l - the Line whose start and end point coordinates should be used for initialization
        Returns:
        this for convenience
      • setLine

        public Line setLine​(Point p1,
                            Point p2)
        Initializes this Line with the start and end point coordinates provided by the given points
        Parameters:
        p1 - the Point whose coordinates should be used as the start point coordinates of this Line
        p2 - the Point whose coordinates should be used as the end point coordinates of this Line
        Returns:
        this for convenience
      • setX1

        public Line setX1​(double x1)
        Sets the x-coordinate of the start Point of this Line to the given value.
        Parameters:
        x1 - The new x-coordinate for the start Point of this Line.
        Returns:
        this for convenience
      • setX2

        public Line setX2​(double x2)
        Sets the x-coordinate of the end Point of this Line to the given value.
        Parameters:
        x2 - The new x-coordiante for the end Point of this Line.
        Returns:
        this for convenience
      • setY1

        public Line setY1​(double y1)
        Sets the y-coordinate of the start Point of this Line to the given value.
        Parameters:
        y1 - The new y-coordinate for the start Point of this Line.
        Returns:
        this for convenience
      • setY2

        public Line setY2​(double y2)
        Sets the y-coordinate of the end Point of this Line to the given value.
        Parameters:
        y2 - The new y-coordinate for the end Point of this Line.
        Returns:
        this for convenience
      • touches

        public boolean touches​(Line l)
        Tests whether this Line and the given one share at least one common point.
        Parameters:
        l - The Line to test.
        Returns:
        true if this Line and the given one share at least one common point, false otherwise.
      • clone

        public java.lang.Object clone()
        Overridden with public visibility as recommended within Cloneable .
        Overrides:
        clone in class java.lang.Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()