Package shapes
Class Line
- java.lang.Object
-
- shapes.Shape
-
- shapes.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
-
-
Field Summary
Fields Modifier and Type Field Description private Pointinitialprivate Pointlastprivate static longserialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointcenterOfLine()Return center of line.Lineclone()Create new instance of this line.intcompareTo(Shape shape)Compare two lines depend by length.booleancontainsClick(int xCoordinate, int yCoordinate)Determine if this line contains user click.doubledistance()Calculate length of line (distance between initial and last point).voiddraw(java.awt.Graphics graphics)Draw line.booleanequals(java.lang.Object obj)Determine if two lines are equal depend on initial and last point.PointgetInitial()PointgetLast()voidmoveTo(int x, int y)Not implemented.voidselected(java.awt.Graphics graphics)Select line.voidsetInitial(Point initial)voidsetLast(Point last)java.lang.StringtoString()Print line values.-
Methods inherited from class shapes.Shape
getColor, isSelected, setColor, setSelected
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
initial
private Point initial
-
last
private Point last
-
-
Method Detail
-
draw
public void draw(java.awt.Graphics graphics)
Draw line.
-
equals
public boolean equals(java.lang.Object obj)
Determine if two lines are equal depend on initial and last point.- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(Shape shape)
Compare two lines depend by length.
-
toString
public java.lang.String toString()
Print line values.- Overrides:
toStringin classjava.lang.Object
-
moveTo
public void moveTo(int x, int y)Not implemented.
-
selected
public void selected(java.awt.Graphics graphics)
Select line.
-
containsClick
public boolean containsClick(int xCoordinate, int yCoordinate)Determine if this line contains user click.- Specified by:
containsClickin classShape- 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:
clonein classjava.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)
-
-