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 SummaryFields Modifier and Type Field Description private Pointinitialprivate Pointlastprivate static longserialVersionUID
 - 
Method SummaryAll 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.ShapegetColor, isSelected, setColor, setSelected
 
- 
 
- 
- 
- 
Field Detail- 
serialVersionUIDprivate static final long serialVersionUID - See Also:
- Constant Field Values
 
 - 
initialprivate Point initial 
 - 
lastprivate Point last 
 
- 
 - 
Method Detail- 
drawpublic void draw(java.awt.Graphics graphics) Draw line.
 - 
equalspublic boolean equals(java.lang.Object obj) Determine if two lines are equal depend on initial and last point.- Overrides:
- equalsin class- java.lang.Object
 
 - 
compareTopublic int compareTo(Shape shape) Compare two lines depend by length.
 - 
toStringpublic java.lang.String toString() Print line values.- Overrides:
- toStringin class- java.lang.Object
 
 - 
moveTopublic void moveTo(int x, int y)Not implemented.
 - 
selectedpublic void selected(java.awt.Graphics graphics) Select line.
 - 
containsClickpublic boolean containsClick(int xCoordinate, int yCoordinate)Determine if this line contains user click.- Specified by:
- containsClickin 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.
 
 - 
clonepublic Line clone() Create new instance of this line.- Overrides:
- clonein class- java.lang.Object
 
 - 
distancepublic double distance() Calculate length of line (distance between initial and last point).- Returns:
- Represent length of line.
 
 - 
centerOfLinepublic Point centerOfLine() Return center of line.- Returns:
- Center of line.
 
 - 
getInitialpublic Point getInitial() 
 - 
setInitialpublic void setInitial(Point initial) 
 - 
getLastpublic Point getLast() 
 - 
setLastpublic void setLast(Point last) 
 
- 
 
-