public class WidgetLocation extends AbstractLocation
Constructor and Description |
---|
WidgetLocation(com.google.gwt.user.client.ui.Widget widget,
com.google.gwt.user.client.ui.Widget reference)
Determine location of
widget relative to reference , such that
referencePanel.add(widget, location.getLeft(), location.getTop()) leaves the
widget in the exact same location on the screen. |
Modifier and Type | Method and Description |
---|---|
void |
constrain(int minLeft,
int minTop,
int maxLeft,
int maxTop)
Constrain the widget location to the provided minimum and maximum values.
|
int |
getLeft()
Get x coordinate.
|
int |
getTop()
Get the y coordinate.
|
java.lang.String |
toString()
Textual representation of this location formatted as
(x, y) . |
newLocationSnappedToGrid
public WidgetLocation(com.google.gwt.user.client.ui.Widget widget, com.google.gwt.user.client.ui.Widget reference)
widget
relative to reference
, such that
referencePanel.add(widget, location.getLeft(), location.getTop())
leaves the
widget in the exact same location on the screen. Note that reference
need not be
the parent node, or even an ancestor of widget
. Therefore coordinates returned may
be negative or may exceed the dimensions of reference
.widget
- the widget whose coordinates we seekreference
- the widget relative to which we seek our coordinatespublic void constrain(int minLeft, int minTop, int maxLeft, int maxTop)
minLeft
- the minimum left valueminTop
- the minimum top valuemaxLeft
- the maximum left valuemaxTop
- the maximum top valuepublic int getLeft()
Location
public int getTop()
Location
public java.lang.String toString()
AbstractLocation
(x, y)
.toString
in class AbstractLocation