Class Box

java.lang.Object
org.pepsoft.util.Box
All Implemented Interfaces:
Cloneable

public final class Box extends Object implements Cloneable
A rectangular three dimensional volume, defined by two corners, the corner with the lowest x, y and z coordinates being inclusive and the opposite corner being exclusive.
  • Constructor Details

    • Box

      public Box()
    • Box

      public Box(int x1, int x2, int y1, int y2, int z1, int z2)
  • Method Details

    • getX1

      public int getX1()
    • setX1

      public void setX1(int x1)
    • getX2

      public int getX2()
    • setX2

      public void setX2(int x2)
    • getY1

      public int getY1()
    • setY1

      public void setY1(int y1)
    • getY2

      public int getY2()
    • setY2

      public void setY2(int y2)
    • getZ1

      public int getZ1()
    • setZ1

      public void setZ1(int z1)
    • getZ2

      public int getZ2()
    • setZ2

      public void setZ2(int z2)
    • getWidth

      public int getWidth()
      Get the size of the box along the X axis.
      Returns:
      The size of the box along the X axis.
    • getLength

      public int getLength()
      Get the size of the box along the Y axis.
      Returns:
      The size of the box along the Y axis.
    • getHeight

      public int getHeight()
      Get the size of the box along the Z axis.
      Returns:
      The size of the box along the Z axis.
    • getVolume

      public int getVolume()
      Get the volume of the box.
      Returns:
      The volume of the box.
    • getSurface

      public int getSurface()
      Get the total surface area of the box.
      Returns:
      The total surface area of the box.
    • translate

      public void translate(int dx, int dy, int dz)
    • encompass

      public void encompass(Box box)
      Extends this box so that it encompasses the other box
      Parameters:
      box - The box to encompass.
    • intersect

      public void intersect(Box box)
      Sets this box to the intersection of it and the specified box; in other words to the volume encompassed by both boxes.

      If the boxes don't intersect, the x2, y2 and z2 coordinates of this box will be made equal to the x1, y1 and z1 coordinates so that it becomes empty.

      Parameters:
      box - The box to intersect this box with.
    • isEmpty

      public boolean isEmpty()
    • contains

      public boolean contains(int x, int y, int z)
    • containsXY

      public boolean containsXY(int x, int y)
    • getFootPrint

      public Rectangle getFootPrint()
    • expand

      public void expand(int delta)
      Expand the box by a particular amount in every direction.
      Parameters:
      delta - The delta by which to move every face of the box outwards.
    • toString

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

      public Box clone()
      Overrides:
      clone in class Object