Package shapes

Class Line

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Shape>, Movable

    public class Line
    extends Shape
    Class that represent line shape.
    See Also:
    Serialized Form
    • Constructor Detail

      • Line

        public Line()
      • Line

        public Line​(Point initial,
                    Point last)
      • Line

        public Line​(Point initial,
                    Point last,
                    java.awt.Color color)
    • Method Detail

      • draw

        public void draw​(java.awt.Graphics graphics)
        Draw line.
        Specified by:
        draw in class Shape
        Parameters:
        graphics -
      • equals

        public boolean equals​(java.lang.Object obj)
        Determine if two lines are equal depend on initial and last point.
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Shape shape)
        Compare two lines depend by length.
      • toString

        public java.lang.String toString()
        Print line values.
        Overrides:
        toString in class java.lang.Object
      • moveTo

        public void moveTo​(int x,
                           int y)
        Not implemented.
      • selected

        public void selected​(java.awt.Graphics graphics)
        Select line.
        Specified by:
        selected in class Shape
        Parameters:
        graphics -
      • containsClick

        public boolean containsClick​(int xCoordinate,
                                     int yCoordinate)
        Determine if this line contains user click.
        Specified by:
        containsClick in class Shape
        Parameters:
        xCoordinate - Represent x coordinate of user click.
        yCoordinate - Represent y coordinate of user click.
        Returns:
        Boolean that indicate if this line contain user click.
      • clone

        public Line clone()
        Create new instance of this line.
        Overrides:
        clone in class java.lang.Object
      • distance

        public double distance()
        Calculate length of line (distance between initial and last point).
        Returns:
        Represent length of line.
      • centerOfLine

        public Point centerOfLine()
        Return center of line.
        Returns:
        Center of line.
      • getInitial

        public Point getInitial()
      • setInitial

        public void setInitial​(Point initial)
      • getLast

        public Point getLast()
      • setLast

        public void setLast​(Point last)