Package shapes

Class Point

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

    public class Point
    extends Shape
    Class that represent point shape.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Point()  
      Point​(int xCoordinate, int yCoordinate)  
      Point​(int xCoordinate, int yCoordinate, java.awt.Color color)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Point clone()
      Create new instance of this point.
      int compareTo​(Shape shape)
      Compare two points depend on their distance.
      boolean containsClick​(int xCoordinate, int yCoordinate)
      Determine if this point contains user click.
      double distance​(Point point)
      Calculate dinstance between two points.
      void draw​(java.awt.Graphics graphics)
      Draw point.
      boolean equals​(java.lang.Object obj)
      Determine if two points are equal depends on their coordinates.
      int getXcoordinate()  
      int getYcoordinate()  
      void moveTo​(int xCoordinate, int yCoordinate)
      Move point to forwarded coordinates.
      void selected​(java.awt.Graphics graphics)
      Select point.
      void setXcoordinate​(int xCoordinate)  
      void setYcoordinate​(int yCoordinate)  
      java.lang.String toString()
      Print point values.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • xCoordinate

        private int xCoordinate
      • yCoordinate

        private int yCoordinate
    • Constructor Detail

      • Point

        public Point()
      • Point

        public Point​(int xCoordinate,
                     int yCoordinate)
      • Point

        public Point​(int xCoordinate,
                     int yCoordinate,
                     java.awt.Color color)
    • Method Detail

      • draw

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

        public boolean equals​(java.lang.Object obj)
        Determine if two points are equal depends on their coordinates.
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Shape shape)
        Compare two points depend on their distance.
      • toString

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

        public void moveTo​(int xCoordinate,
                           int yCoordinate)
        Move point to forwarded coordinates.
        Parameters:
        xCoordinate - Represent x coordinate where to move
        yCoordinate - Represent y coordinate where to move.
      • selected

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

        public boolean containsClick​(int xCoordinate,
                                     int yCoordinate)
        Determine if this point 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 indicating if this point contain user click.
      • clone

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

        public double distance​(Point point)
        Calculate dinstance between two points.
        Parameters:
        point - Point in relation to which the distance is calculated
        Returns:
        Distance between two points.
      • getXcoordinate

        public int getXcoordinate()
      • setXcoordinate

        public void setXcoordinate​(int xCoordinate)
      • getYcoordinate

        public int getYcoordinate()
      • setYcoordinate

        public void setYcoordinate​(int yCoordinate)