GeoSoft API

no.geosoft.cc.geometry
Class Rect

Object
  extended byRect

public class Rect
extends Object

A integer based rectangle. The strange name is to avoid name clash with java.awt.Rectangle.

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

Author:
GeoSoft

Field Summary
 int height
           
 int width
           
 int x
           
 int y
           
 
Constructor Summary
Rect()
          Create a default rectangle.
Rect(Box box)
          Create a rectnagle based on specified box.
Rect(int x, int y, int width, int height)
          Create a rectangle.
Rect(Rect rectangle)
          Create a rectangle as a copy of the specified rectangle.
 
Method Summary
 Object clone()
          Clone this rectangle
 void copy(Rect rectangle)
          Copy the specified rectangle.
 boolean equals(Object object)
          Check if this rectangle equals the specified object.
 void expand(int dx, int dy)
          Expand this rectangle the specified amount in each direction.
 int getCenterX()
          Return X coordinate of center of this rectangle.
 int getCenterY()
          Return Y coordinate of center of this rectangle.
 boolean isEmpty()
          Return true if this rectangle is empty.
 void set(int[] xArray, int[] yArray)
          Set this rectangle as extent of specified polyline.
 void set(int x, int y, int width, int height)
          Set the parameters for this rectangle.
 String toString()
          Return a string representation of this rectangle.
 
Methods inherited from class Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

height

public int height

width

public int width
Constructor Detail

Rect

public Rect(int x,
            int y,
            int width,
            int height)
Create a rectangle.

Parameters:
x - X coordinate of upper left corner.
y - Y coordinate of upper left corner.
width - Width of rectangle.
height - Height of rectangle.

Rect

public Rect()
Create a default rectangle.


Rect

public Rect(Rect rectangle)
Create a rectangle as a copy of the specified rectangle.

Parameters:
rectangle -

Rect

public Rect(Box box)
Create a rectnagle based on specified box.

Parameters:
box - Box to create rectangle from.
Method Detail

copy

public void copy(Rect rectangle)
Copy the specified rectangle.

Parameters:
rectangle - Rectangle to copy.

clone

public Object clone()
Clone this rectangle

Returns:
Clone of this rectangle.

equals

public boolean equals(Object object)
Check if this rectangle equals the specified object.

Parameters:
object - Object to chack.
Returns:
True if the two equals, false otherwise.

isEmpty

public boolean isEmpty()
Return true if this rectangle is empty.

Returns:
True if this rectangle is empty, false otherwise.

expand

public void expand(int dx,
                   int dy)
Expand this rectangle the specified amount in each direction.

Parameters:
dx - Amount to expand to left and right.
dy - Amount to expand on top and botton.

set

public void set(int x,
                int y,
                int width,
                int height)
Set the parameters for this rectangle.

Parameters:
x - X coordinate of upper left corner.
y - Y coordinate of upper left corner.
width - Width of rectangle.
height - Height of rectangle.

set

public void set(int[] xArray,
                int[] yArray)
Set this rectangle as extent of specified polyline.

Parameters:
xArray - X coordinates of polyline.
yArray - Y coordinates of polyline.

getCenterX

public int getCenterX()
Return X coordinate of center of this rectangle.

Returns:
X coordinate of center of this rectangle.

getCenterY

public int getCenterY()
Return Y coordinate of center of this rectangle.

Returns:
Y coordinate of center of this rectangle.

toString

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

Returns:
String representation of this rectangle.

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no