com.partnersoft.v3x.graphics
Class IntegerRectangle

java.lang.Object
  extended by com.partnersoft.v3x.graphics.IntegerRectangle
All Implemented Interfaces:
java.io.Serializable

public class IntegerRectangle
extends java.lang.Object
implements java.io.Serializable

A rectangle in whole-number space. Because whole numbers are part of this nutritious breakfast.

See Also:
Serialized Form

Field Summary
 int east
           
 int north
           
 int south
           
 int west
           
 
Constructor Summary
IntegerRectangle()
          Create a new IntegerRectangle.
IntegerRectangle(int west, int south, int east, int north)
          Create a new IntegerRectangle with given west, south, east and north.
 
Method Summary
 java.lang.Object clone()
           
 boolean covers(IntegerRectangle nother)
          Returns true if this rectangle covers the given one.
 int getArea()
          Area (width * height)
 int getEast()
          Maximum x coordinate (east edge)
 int getHeight()
          Height - keep in mind a rectangle with the same north and south coords has a height of 1, not zero.
 int getNorth()
          Maximum y coordinate (north edge)
 int getSouth()
          Minimum y coordinate (southern edge)
 int getWest()
          Minimum x coordinate (western edge)
 int getWidth()
          Width - keep in mind a rectangle with the same east and west coords has a width of 1, not zero
 int getX()
          Minimum x (same as west)
 int getY()
          Minimum y (same as south)
 IntegerRectangle intersection(IntegerRectangle nother)
          Returns the intersection of the given rectangle with this (returns null if there is none)
 boolean intersects(IntegerRectangle nother)
          Returns true if the given rectangle intersects this one.
 void setEast(int newEast)
          Maximum x coordinate (east edge)
 void setNorth(int newNorth)
          Maximum y coordinate (north edge)
 void setSouth(int newSouth)
          Minimum y coordinate (southern edge)
 void setWest(int newWest)
          Minimum x coordinate (western edge)
 java.lang.String toString()
           
 java.util.ArrayList trimmings(IntegerRectangle nother)
          Returns a list of rectangles formed when the given rectangle is cropped by this one.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

west

public int west

south

public int south

east

public int east

north

public int north
Constructor Detail

IntegerRectangle

public IntegerRectangle()
Create a new IntegerRectangle.


IntegerRectangle

public IntegerRectangle(int west,
                        int south,
                        int east,
                        int north)
Create a new IntegerRectangle with given west, south, east and north.

Method Detail

intersects

public boolean intersects(IntegerRectangle nother)
Returns true if the given rectangle intersects this one.


covers

public boolean covers(IntegerRectangle nother)
Returns true if this rectangle covers the given one.


intersection

public IntegerRectangle intersection(IntegerRectangle nother)
Returns the intersection of the given rectangle with this (returns null if there is none)


trimmings

public java.util.ArrayList trimmings(IntegerRectangle nother)
Returns a list of rectangles formed when the given rectangle is cropped by this one. It's possible the list could be empty (the given rectangle is contained by this one). Opposite case is when the given rectangle contains this one, in which case you get 4 trimmings. Another case is no intersection, in which case you get a copy of the rectangle given. More usual is two.


clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getWest

public int getWest()
Minimum x coordinate (western edge)


setWest

public void setWest(int newWest)
Minimum x coordinate (western edge)


getSouth

public int getSouth()
Minimum y coordinate (southern edge)


setSouth

public void setSouth(int newSouth)
Minimum y coordinate (southern edge)


getEast

public int getEast()
Maximum x coordinate (east edge)


setEast

public void setEast(int newEast)
Maximum x coordinate (east edge)


getNorth

public int getNorth()
Maximum y coordinate (north edge)


setNorth

public void setNorth(int newNorth)
Maximum y coordinate (north edge)


getArea

public int getArea()
Area (width * height)


getX

public int getX()
Minimum x (same as west)


getY

public int getY()
Minimum y (same as south)


getWidth

public int getWidth()
Width - keep in mind a rectangle with the same east and west coords has a width of 1, not zero


getHeight

public int getHeight()
Height - keep in mind a rectangle with the same north and south coords has a height of 1, not zero.