Class Line

  • All Implemented Interfaces:
    IShape

    public class Line
    extends java.lang.Object
    implements IShape
    Represents a line.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Point p1  
      private Point p2  
    • Constructor Summary

      Constructors 
      Constructor Description
      Line()
      Constructs a new zero-length line starting at zero.
      Line​(float x1, float y1, float x2, float y2)
      Constructs a new line based on the given coordinates.
      Line​(Point p1, Point p2)
      Constructs a new line based on the given coordinates.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<Point> getBasePoints()
      Treat base points as the points which are enough to construct a shape.
      • Methods inherited from class java.lang.Object

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

      • p1

        private final Point p1
      • p2

        private final Point p2
    • Constructor Detail

      • Line

        public Line()
        Constructs a new zero-length line starting at zero.
      • Line

        public Line​(float x1,
                    float y1,
                    float x2,
                    float y2)
        Constructs a new line based on the given coordinates.
        Parameters:
        x1 - x-coordinate of start point of this Line
        y1 - y-coordinate of start point of this Line
        x2 - x-coordinate of end point of this Line
        y2 - y-coordinate of end point of this Line
      • Line

        public Line​(Point p1,
                    Point p2)
        Constructs a new line based on the given coordinates.
        Parameters:
        p1 - start point of this Line
        p2 - end point of this Line
    • Method Detail

      • getBasePoints

        public java.util.List<Point> getBasePoints()
        Description copied from interface: IShape
        Treat base points as the points which are enough to construct a shape. E.g. for a bezier curve they are control points, for a line segment - the start and the end points of the segment.
        Specified by:
        getBasePoints in interface IShape
        Returns:
        Ordered List consisting of shape's base points.