jfig.objects
Class FigBbox

java.lang.Object
  extended byjfig.objects.FigBbox

public final class FigBbox
extends java.lang.Object

manage bounding boxes for jfig objects.

FigBbox: a simple bounding box with x_left, y_top, x_right, y_bottom coordinates, better suited than the rectangle class provided in java.awt.


Constructor Summary
FigBbox(FigBbox src)
           
FigBbox(int xl, int yt, int xr, int yb)
          construct a FigBbox from two (x,y) pairs.
FigBbox(java.awt.Point lt, java.awt.Point rb)
          construct a FigBbox from two Points.
 
Method Summary
 FigBbox get()
           
 java.awt.Point getCenterPoint()
           
 java.awt.Point getNearestCorner(java.awt.Point wp)
           
 java.awt.Point getOppositeCorner(java.awt.Point wp)
           
 java.awt.Rectangle getRectangle()
           
 int getXl()
           
 int getXr()
           
 int getYb()
           
 int getYt()
           
 boolean inside(FigBbox region)
          check whether this bounding box is completely inside region (this function is used for delete region and create compound by region in the jfig graphics editor)
 boolean inside(int x, int y)
          check whether coordinates (x,y) are inside this bbox
 boolean isInside(java.awt.Point WP)
          check whether point PW lies inside this bounding box object.
 boolean isOnBorder(java.awt.Point wp, int dist)
          check whether the Point wp is on the border (that is, within distance dist) from the outline of this bounding box.
 boolean isVisible(FigBbox viewport)
          check whether this bounding box is visible (lies inside) the parameter bounding box (e.g.
 double minDistance(java.awt.Point wp)
          minDistance(): return the minimium distance of Point wp from the corners of this bounding box.
 double minDistanceInside(java.awt.Point wp)
          return a distance between point wp and this FigBBox useful for object selection.
 double minDistanceInsideZero(java.awt.Point wp)
          return the Manhattan distance of point wp to the nearest corner of this bounding box, or zero if point wp lies inside.
 void set(FigBbox bbox)
           
 void set(int xl, int yt, int xr, int yb)
           
 java.lang.String toString()
          toString(): print the bbox coordinates
 FigBbox union(FigBbox bbox2)
          construct and return a FigBbox that represents the bounding box of the union of 'this' FigBbox and FigBbox bbox2
static FigBbox union(FigBbox bbox1, FigBbox bbox2)
          construct and return a FigBbox that represents the bounding box of the union of FigBbox'es bbox1 and bbox2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FigBbox

public FigBbox(int xl,
               int yt,
               int xr,
               int yb)
construct a FigBbox from two (x,y) pairs. We sort the coords to satisfy xl

FigBbox

public FigBbox(java.awt.Point lt,
               java.awt.Point rb)
construct a FigBbox from two Points. Despite the variable names, we sort the coords to satisfy xl

FigBbox

public FigBbox(FigBbox src)
Method Detail

set

public final void set(int xl,
                      int yt,
                      int xr,
                      int yb)

set

public final void set(FigBbox bbox)

get

public final FigBbox get()

getXl

public int getXl()

getYt

public int getYt()

getXr

public int getXr()

getYb

public int getYb()

isInside

public final boolean isInside(java.awt.Point WP)
check whether point PW lies inside this bounding box object.


inside

public final boolean inside(int x,
                            int y)
check whether coordinates (x,y) are inside this bbox


inside

public final boolean inside(FigBbox region)
check whether this bounding box is completely inside region (this function is used for delete region and create compound by region in the jfig graphics editor)


isVisible

public final boolean isVisible(FigBbox viewport)
check whether this bounding box is visible (lies inside) the parameter bounding box (e.g. the editor viewport bbox)


isOnBorder

public final boolean isOnBorder(java.awt.Point wp,
                                int dist)
check whether the Point wp is on the border (that is, within distance dist) from the outline of this bounding box.


union

public final FigBbox union(FigBbox bbox2)
construct and return a FigBbox that represents the bounding box of the union of 'this' FigBbox and FigBbox bbox2


union

public static final FigBbox union(FigBbox bbox1,
                                  FigBbox bbox2)
construct and return a FigBbox that represents the bounding box of the union of FigBbox'es bbox1 and bbox2


minDistance

public final double minDistance(java.awt.Point wp)
minDistance(): return the minimium distance of Point wp from the corners of this bounding box. This function currently uses the Manhattan distance.


minDistanceInsideZero

public final double minDistanceInsideZero(java.awt.Point wp)
return the Manhattan distance of point wp to the nearest corner of this bounding box, or zero if point wp lies inside.


minDistanceInside

public final double minDistanceInside(java.awt.Point wp)
return a distance between point wp and this FigBBox useful for object selection. This method dispatches to minDistance() to calculate the Manhattan distance d and to isInside() to check whether wp lies inside this bounding box. If wp lies outside, we return d, and if wp lies inside, we return 0.9*d.


getNearestCorner

public final java.awt.Point getNearestCorner(java.awt.Point wp)

getOppositeCorner

public final java.awt.Point getOppositeCorner(java.awt.Point wp)

getCenterPoint

public final java.awt.Point getCenterPoint()

getRectangle

public java.awt.Rectangle getRectangle()

toString

public java.lang.String toString()
toString(): print the bbox coordinates