com.allen_sauer.gwt.dnd.client.util
Class AbstractArea

java.lang.Object
  extended by com.allen_sauer.gwt.dnd.client.util.AbstractArea
All Implemented Interfaces:
Area
Direct Known Subclasses:
CoordinateArea, WidgetArea

public abstract class AbstractArea
extends java.lang.Object
implements Area

Provides implementations for common Area calculations.


Constructor Summary
AbstractArea()
           
 
Method Summary
 Area copyOf()
          Clone our area.
 int distanceToEdge(Location location)
          Determine the shortest distance from the location to the edge of the area.
 int getBottom()
          Get the area's bottom coordinate in pixels.
 Location getCenter()
          Get the area's center Location.
 int getHeight()
          Get the area's height.
 int getLeft()
          Get the area's left coordinate in pixels.
 int getRight()
          Get the area's right coordinate in pixels.
 int getSize()
          Determine area (width * height).
 int getTop()
          Get the area's top coordinate in pixels.
 int getWidth()
          Get the area's width.
 boolean inBottomRight(Location location)
          Determine if location is to the bottom-right of the following 45 degree line.
 boolean intersects(Area targetArea)
          Determine if the target area intersects our area.
 boolean intersects(Location location)
          Determine if the provided location intersects with our area.
 void moveTo(Location location)
          Translate our top left position to the new location.
protected  void setBottom(int bottom)
          Set bottom coordinate.
protected  void setLeft(int left)
          Set left coordinate.
protected  void setRight(int right)
          Set right coordinate.
protected  void setTop(int top)
          Set top coordinate.
 java.lang.String toString()
          Textual representation of this area formatted as [(left, top) - (right, bottom) ].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractArea

public AbstractArea()
Method Detail

copyOf

public Area copyOf()
Description copied from interface: Area
Clone our area.

Specified by:
copyOf in interface Area
Returns:
the new area

distanceToEdge

public int distanceToEdge(Location location)
Description copied from interface: Area
Determine the shortest distance from the location to the edge of the area. Zero indicates a location on the edge. Negative distances indicate a location inside the area.

Specified by:
distanceToEdge in interface Area
Parameters:
location - the reference location
Returns:
shortest distance to edge of area

getBottom

public final int getBottom()
Description copied from interface: Area
Get the area's bottom coordinate in pixels.

Specified by:
getBottom in interface Area
Returns:
the bottom coordinate in pixels

getCenter

public Location getCenter()
Description copied from interface: Area
Get the area's center Location.

Specified by:
getCenter in interface Area
Returns:
the area's center Location

getHeight

public int getHeight()
Description copied from interface: Area
Get the area's height.

Specified by:
getHeight in interface Area
Returns:
the area's height in pixels

getLeft

public final int getLeft()
Description copied from interface: Area
Get the area's left coordinate in pixels.

Specified by:
getLeft in interface Area
Returns:
the left coordinate in pixels

getRight

public final int getRight()
Description copied from interface: Area
Get the area's right coordinate in pixels.

Specified by:
getRight in interface Area
Returns:
the right coordinate in pixels

getSize

public int getSize()
Description copied from interface: Area
Determine area (width * height).

Specified by:
getSize in interface Area
Returns:
size of area

getTop

public final int getTop()
Description copied from interface: Area
Get the area's top coordinate in pixels.

Specified by:
getTop in interface Area
Returns:
the top coordinate in pixels

getWidth

public int getWidth()
Description copied from interface: Area
Get the area's width.

Specified by:
getWidth in interface Area
Returns:
the area's width in pixels

inBottomRight

public boolean inBottomRight(Location location)
Description copied from interface: Area
Determine if location is to the bottom-right of the following 45 degree line.
             y  45
             | /
             |/   
        -----+----- x
            /|
           / |
 
 

Specified by:
inBottomRight in interface Area
Parameters:
location - the location to consider
Returns:
true if the location is to below the 45 degree line

intersects

public boolean intersects(Area targetArea)
Description copied from interface: Area
Determine if the target area intersects our area.

Specified by:
intersects in interface Area
Parameters:
targetArea - the area to compare to
Returns:
true if target area intersects our area

intersects

public boolean intersects(Location location)
Description copied from interface: Area
Determine if the provided location intersects with our area.

Specified by:
intersects in interface Area
Parameters:
location - the location to examine
Returns:
true if the location falls within our area

moveTo

public void moveTo(Location location)
Description copied from interface: Area
Translate our top left position to the new location.

Specified by:
moveTo in interface Area
Parameters:
location - the position to translate to

toString

public java.lang.String toString()
Textual representation of this area formatted as [(left, top) - (right, bottom) ].

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this area

setBottom

protected final void setBottom(int bottom)
Set bottom coordinate.

Parameters:
bottom - the bottom coordinate in pixels

setLeft

protected final void setLeft(int left)
Set left coordinate.

Parameters:
left - the left coordinate in pixels

setRight

protected final void setRight(int right)
Set right coordinate.

Parameters:
right - the right coordinate in pixels

setTop

protected final void setTop(int top)
Set top coordinate.

Parameters:
top - the top coordinate in pixels


Copyright © 2011 Sage Software, Inc. All rights reserved.