Package shapes
Class Rectangle
- java.lang.Object
-
- shapes.Shape
-
- shapes.SurfaceShape
-
- shapes.Square
-
- shapes.Rectangle
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<Shape>
,Movable
public class Rectangle extends Square
Class that represent rectangle shape.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
private int
width
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rectangle
clone()
Create new instance of this rectangle.boolean
containsClick(int xCoordinate, int yCoordinate)
Check if this square contains user click.Line
diagonal()
Calculate diagonal of rectangle.void
draw(java.awt.Graphics g)
Draw rectangle.boolean
equals(java.lang.Object obj)
Determine if two rectangles are equal depend on their up left point and width.void
fillUpShape(java.awt.Graphics graphics)
Fill up rectangle.int
getWidth()
void
selected(java.awt.Graphics graphics)
Select rectangle.void
setWidth(int width)
java.lang.String
toString()
Print rectangle values.-
Methods inherited from class shapes.Square
compareTo, getSide, getUpLeft, moveTo, setSide, setUpLeft, surface
-
Methods inherited from class shapes.SurfaceShape
getInteriorColor, setInteriorColor
-
Methods inherited from class shapes.Shape
getColor, isSelected, setColor, setSelected
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
width
private int width
-
-
Constructor Detail
-
Rectangle
public Rectangle()
-
Rectangle
public Rectangle(Point upLeft, int width, int height, java.awt.Color edgeColor, java.awt.Color interiorColor)
-
-
Method Detail
-
draw
public void draw(java.awt.Graphics g)
Draw rectangle.
-
equals
public boolean equals(java.lang.Object obj)
Determine if two rectangles are equal depend on their up left point and width.
-
toString
public java.lang.String toString()
Print rectangle values.
-
selected
public void selected(java.awt.Graphics graphics)
Select rectangle.
-
containsClick
public boolean containsClick(int xCoordinate, int yCoordinate)
Description copied from class:Square
Check if this square contains user click.- Overrides:
containsClick
in classSquare
- Parameters:
xCoordinate
- Represent x coordinate of user click.yCoordinate
- Represent y coordinate of user click.- Returns:
- Boolean indicating if rectangle coints click.
-
clone
public Rectangle clone()
Create new instance of this rectangle.
-
fillUpShape
public void fillUpShape(java.awt.Graphics graphics)
Fill up rectangle.- Overrides:
fillUpShape
in classSquare
- Parameters:
graphics
-
-
diagonal
public Line diagonal()
Calculate diagonal of rectangle.
-
getWidth
public int getWidth()
-
setWidth
public void setWidth(int width)
-
-