GeoSoft API

no.geosoft.cc.geometry
Class Box

Object
  extended byBox
All Implemented Interfaces:
Cloneable

public class Box
extends Object
implements Cloneable

A rectangle defined by its upper left (included) and lower right (not included) corners.

   1##############
   ###############
   ###############
                  2
 
This corresponds to a Rect of width = x2 - x1 and height = y2 - y1.

Rect and Box represents the same concept, but their different definition makes them suitable for use in different situations.

Author:
GeoSoft

Field Summary
 int x1
           
 int x2
           
 int y1
           
 int y2
           
 
Constructor Summary
Box()
          Create an empty box.
Box(Box box)
          Create a new box as a copy of the specified box.
Box(int x1, int y1, int x2, int y2)
          Create a new box with specified coordinates.
Box(Rect rectangle)
          Create a new box based on the specified rectangle.
 
Method Summary
 Object clone()
          Clone this box.
 void copy(Box box)
          Copy the specified box.
 boolean isInside(int x, int y)
          Check if the specified point is ionside this box.
 boolean isInsideOf(Box box)
          Return true if this box is inside the specified box.
 boolean isOverlapping(Box box)
          Return true if this box overlaps the specified box.
 boolean isOverlapping(Rect rectangle)
          Return true if this box overlaps the specified rectangle.
 void offset(int dx, int dy)
          Offset this box a specified distance in x and y direction.
 void set(int x1, int y1, int x2, int y2)
          Set the parameters of this box.
 String toString()
          Return a string representation of this box.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x1

public int x1

x2

public int x2

y1

public int y1

y2

public int y2
Constructor Detail

Box

public Box()
Create an empty box.


Box

public Box(Box box)
Create a new box as a copy of the specified box.

Parameters:
box - Box to copy.

Box

public Box(int x1,
           int y1,
           int x2,
           int y2)
Create a new box with specified coordinates. The box includes the (x1,y1) as upper left corner. The lower right corner (x2,y2) is just outside the box.

Parameters:
x1 - X of upper left corner (inclusive).
y1 - Y of upper left corner (inclusive).
x2 - X of lower right corner (not inclusive)
y2 - Y of lower right corner (not inclusive).

Box

public Box(Rect rectangle)
Create a new box based on the specified rectangle.

Parameters:
rectangle - Rectangle to copy.
Method Detail

copy

public void copy(Box box)
Copy the specified box.

Parameters:
box - Box to copy.

clone

public Object clone()
Clone this box.

Returns:
Clone of this box.

set

public void set(int x1,
                int y1,
                int x2,
                int y2)
Set the parameters of this box.

Parameters:
x1 - X coordinate of upper left corner of box.
y1 - Y coordinate of upper left corner of box.
x2 - X coordinate of lower right corner of box.
y2 - Y coordinate of lower right corner of box.

isInside

public boolean isInside(int x,
                        int y)
Check if the specified point is ionside this box.

Parameters:
x - X coordinate of point to check.
y - Y coordinate of point to check.
Returns:
True if the point is inside this box, false otherwise.

isInsideOf

public boolean isInsideOf(Box box)
Return true if this box is inside the specified box.

Parameters:
box - Box to check if this is inside of.
Returns:
True if this box in inside the specified box, false otherwise.

isOverlapping

public boolean isOverlapping(Box box)
Return true if this box overlaps the specified box.

Parameters:
box - Box to check if this is inside of.
Returns:
True if this box overlaps the specified box, false otherwise.

isOverlapping

public boolean isOverlapping(Rect rectangle)
Return true if this box overlaps the specified rectangle.

Parameters:
rectangle - Rectnagle to check if this is inside of.
Returns:
True if this box overlaps the specified rectangle, false otherwise.

offset

public void offset(int dx,
                   int dy)
Offset this box a specified distance in x and y direction.

Parameters:
dx - Offset in x direction.
dy - Offset in y direction.

toString

public String toString()
Return a string representation of this box.

Returns:
String representation of this box.

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no