Package shapes

Class 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 Detail

      • 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.
        Overrides:
        draw in class Square
        Parameters:
        g -
      • equals

        public boolean equals​(java.lang.Object obj)
        Determine if two rectangles are equal depend on their up left point and width.
        Overrides:
        equals in class Square
      • toString

        public java.lang.String toString()
        Print rectangle values.
        Overrides:
        toString in class Square
      • selected

        public void selected​(java.awt.Graphics graphics)
        Select rectangle.
        Overrides:
        selected in class Square
        Parameters:
        graphics -
      • containsClick

        public boolean containsClick​(int xCoordinate,
                                     int yCoordinate)
        Description copied from class: Square
        Check if this square contains user click.
        Overrides:
        containsClick in class Square
        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.
        Overrides:
        clone in class Square
      • fillUpShape

        public void fillUpShape​(java.awt.Graphics graphics)
        Fill up rectangle.
        Overrides:
        fillUpShape in class Square
        Parameters:
        graphics -
      • diagonal

        public Line diagonal()
        Calculate diagonal of rectangle.
        Overrides:
        diagonal in class Square
        Returns:
        Line which represent diagonal of rectangle.
      • getWidth

        public int getWidth()
      • setWidth

        public void setWidth​(int width)