Class Box2D

java.lang.Object
org.jgrapht.alg.drawing.model.Box2D
All Implemented Interfaces:
Serializable

public class Box2D extends Object implements Serializable
A 2-dimensional box (rectangle).
Author:
Dimitrios Michail
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double[]
    The coordinates of the lower corner
    protected double[]
    The side lengths
  • Constructor Summary

    Constructors
    Constructor
    Description
    Box2D(double[] coordinates, double[] sides)
    Create a new box
    Box2D(double width, double height)
    Create a new box
    Box2D(double x, double y, double width, double height)
    Create a new box
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    double
    Get the height
    double
    Get the maximum x coordinate
    double
    Get the maximum y coordinate
    double
    Get the minimum x coordinate
    double
    Get the minimum y coordinate
    double
    Get the width
    int
     
    static Box2D
    of(double width, double height)
    Create a new box
    static Box2D
    of(double x, double y, double width, double height)
    Create a new box
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • coordinates

      protected double[] coordinates
      The coordinates of the lower corner
    • sides

      protected double[] sides
      The side lengths
  • Constructor Details

    • Box2D

      public Box2D(double width, double height)
      Create a new box
      Parameters:
      width - the width
      height - the height
    • Box2D

      public Box2D(double x, double y, double width, double height)
      Create a new box
      Parameters:
      x - the x coordinate of the lower-left corner
      y - the y coordinate of the lower-left corner
      width - the width
      height - the height
    • Box2D

      public Box2D(double[] coordinates, double[] sides)
      Create a new box
      Parameters:
      coordinates - the lower left corner coordinates
      sides - width and height
  • Method Details

    • getMinX

      public double getMinX()
      Get the minimum x coordinate
      Returns:
      the minimum x coordinate
    • getMinY

      public double getMinY()
      Get the minimum y coordinate
      Returns:
      the minimum y coordinate
    • getWidth

      public double getWidth()
      Get the width
      Returns:
      the width
    • getHeight

      public double getHeight()
      Get the height
      Returns:
      the height
    • getMaxX

      public double getMaxX()
      Get the maximum x coordinate
      Returns:
      the maximum x coordinate
    • getMaxY

      public double getMaxY()
      Get the maximum y coordinate
      Returns:
      the maximum y coordinate
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static Box2D of(double width, double height)
      Create a new box
      Parameters:
      width - the width
      height - the height
      Returns:
      the box
    • of

      public static Box2D of(double x, double y, double width, double height)
      Create a new box
      Parameters:
      x - the x coordinate of the lower-left corner
      y - the y coordinate of the lower-left corner
      width - the width
      height - the height
      Returns:
      the box