Class Rectangle

java.lang.Object
de.aristaflow.adept2.model.graphical.Rectangle
All Implemented Interfaces:
Serializable

public class Rectangle extends Object implements Serializable
A simple data class for rectangular areas and points. The area can be either absolute (having coordinates for the top-left corner) or relative.
Author:
Ulrich Kreher
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    The height of the rectangular area.
    protected final boolean
    Wether the rectangular area is relative that is, it does not have valid coordinates.
    protected final int
    The width of the rectangular area.
    protected final int
    The x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
    protected final int
    The y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle(int x, int y, boolean point)
    Creates a new point having the designated coordinates or a relative rectangle with the designated extent.
    Rectangle(int x, int y, int width, int height)
    Creates a new rectangle area with the designated coordinates of the top-left corner, and the designated extent.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the height of the rectangular area or 0 for a point.
    int
    Gets the width of the rectangular area or 0 for a point.
    int
    Gets the x-coordinate of the top-left corner of the rectangular area.
    int
    Gets the y-coordinate of the top-left corner of the rectangular area.
    boolean
    Gets whether the rectangular area is relative and therefore the coordinates are invalid.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      protected final int x
      The x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
    • y

      protected final int y
      The y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
    • width

      protected final int width
      The width of the rectangular area.
    • height

      protected final int height
      The height of the rectangular area.
    • isRelative

      protected final boolean isRelative
      Wether the rectangular area is relative that is, it does not have valid coordinates.
  • Constructor Details

    • Rectangle

      public Rectangle(int x, int y, int width, int height)
      Creates a new rectangle area with the designated coordinates of the top-left corner, and the designated extent.
      Parameters:
      x - The x-coordinate of the top-left corner of the rectangular area.
      y - The y-coordinate of the top-left corner of the rectangular area
      width - The width of the rectangular area.
      height - The height of the rectangular area.
    • Rectangle

      public Rectangle(int x, int y, boolean point)
      Creates a new point having the designated coordinates or a relative rectangle with the designated extent.
      Parameters:
      x - The x-coordinate of the point or the width of the relative rectangular area.
      y - The y-coordinate of the point or the height of the relative rectangular area.
      point - Whether to create a point (having no extent) or a relative rectangular area.
  • Method Details

    • getX

      public int getX()
      Gets the x-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
      Returns:
      The x-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
    • getY

      public int getY()
      Gets the y-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
      Returns:
      The y-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
    • getWidth

      public int getWidth()
      Gets the width of the rectangular area or 0 for a point.
      Returns:
      The width of the rectangular area or 0 for a point.
    • getHeight

      public int getHeight()
      Gets the height of the rectangular area or 0 for a point.
      Returns:
      The height of the rectangular area or 0 for a point.
    • isRelative

      public boolean isRelative()
      Gets whether the rectangular area is relative and therefore the coordinates are invalid.
      Returns:
      Whether the rectangular area is relative and therefore the coordinates are invalid.