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 Point
initial
private Point
last
private static long
serialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Point
centerOfLine()
Return center of line.Line
clone()
Create new instance of this line.int
compareTo(Shape shape)
Compare two lines depend by length.boolean
containsClick(int xCoordinate, int yCoordinate)
Determine if this line contains user click.double
distance()
Calculate length of line (distance between initial and last point).void
draw(java.awt.Graphics graphics)
Draw line.boolean
equals(java.lang.Object obj)
Determine if two lines are equal depend on initial and last point.Point
getInitial()
Point
getLast()
void
moveTo(int x, int y)
Not implemented.void
selected(java.awt.Graphics graphics)
Select line.void
setInitial(Point initial)
void
setLast(Point last)
java.lang.String
toString()
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:
equals
in 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:
toString
in 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:
containsClick
in 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:
clone
in 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)
-
-