Package shapes
Class Point
- java.lang.Object
-
- shapes.Shape
-
- shapes.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
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDprivate intxCoordinateprivate intyCoordinate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pointclone()Create new instance of this point.intcompareTo(Shape shape)Compare two points depend on their distance.booleancontainsClick(int xCoordinate, int yCoordinate)Determine if this point contains user click.doubledistance(Point point)Calculate dinstance between two points.voiddraw(java.awt.Graphics graphics)Draw point.booleanequals(java.lang.Object obj)Determine if two points are equal depends on their coordinates.intgetXcoordinate()intgetYcoordinate()voidmoveTo(int xCoordinate, int yCoordinate)Move point to forwarded coordinates.voidselected(java.awt.Graphics graphics)Select point.voidsetXcoordinate(int xCoordinate)voidsetYcoordinate(int yCoordinate)java.lang.StringtoString()Print point values.-
Methods inherited from class shapes.Shape
getColor, isSelected, setColor, setSelected
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
xCoordinate
private int xCoordinate
-
yCoordinate
private int yCoordinate
-
-
Method Detail
-
draw
public void draw(java.awt.Graphics graphics)
Draw point.
-
equals
public boolean equals(java.lang.Object obj)
Determine if two points are equal depends on their coordinates.- Overrides:
equalsin classjava.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:
toStringin classjava.lang.Object- Returns:
-
moveTo
public void moveTo(int xCoordinate, int yCoordinate)Move point to forwarded coordinates.- Parameters:
xCoordinate- Represent x coordinate where to moveyCoordinate- Represent y coordinate where to move.
-
selected
public void selected(java.awt.Graphics graphics)
Select point.
-
containsClick
public boolean containsClick(int xCoordinate, int yCoordinate)Determine if this point contains user click.- Specified by:
containsClickin classShape- 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:
clonein classjava.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)
-
-