net.rim.device.api.ui
Class XYPoint

java.lang.Object
  extended by net.rim.device.api.ui.XYPoint

public final class XYPoint
extends Object

Represents a point on a two dimensional, cartesian plane.

Typically, these objects are used to represent drawing positions or corners of drawing fields. In these cases, it's handy to remember that the point (0,0) represents the top, left-hand corner of a graphics extent, with increasing positive values describing the plane downwards and to the right.

See Also:
XYRect

Field Summary
 int x
          Distance of point along horizontal axis.
 int y
          Distance of point along vertical axis.
 
Constructor Summary
XYPoint()
          Constructs an origin point.
XYPoint(int x, int y)
          Constructs a specified point.
XYPoint(XYPoint point)
          Constructs a copy of a point.
 
Method Summary
 void reset()
          Resets the point to (0,0).
 void set(int x, int y)
          Provides new value for this point.
 void set(XYPoint point)
          Sets this point equal to the given point.
 String toString()
          Retrieves string form of this point.
 void translate(int dx, int dy)
          Moves this point within the plane.
 void translate(XYPoint point)
          Moves this point using existing point as reference.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 



Field Detail

x

public int x
Distance of point along horizontal axis.


y

public int y
Distance of point along vertical axis.



Constructor Detail

XYPoint

public XYPoint()
Constructs an origin point.

Points built with this constructor are initialized at (0,0).


XYPoint

public XYPoint(int x,
               int y)
Constructs a specified point.

Pass two values to this constructor to build a point within the plane.

Parameters:
x - Horizontal distance from origin.
y - Vertical distance from origin.

XYPoint

public XYPoint(XYPoint point)
Constructs a copy of a point.

Provide an existing point to this constructor to build a new, identical point.

Parameters:
point - Point to copy.


Method Detail

reset

public void reset()
Resets the point to (0,0).

Since:
BlackBerry API 4.6.0

set

public void set(int x,
                int y)
Provides new value for this point.

Parameters:
x - Horizontal distance from origin.
y - Vertical distance from origin.

set

public void set(XYPoint point)
Sets this point equal to the given point.

Pass a point to this method to set this point equal to your reference point.

Parameters:
point - Reference point.

toString

public String toString()
Retrieves string form of this point.

Overrides:
toString in class Object
Returns:
This point's position described in a string like this: (x,y).

translate

public void translate(int dx,
                      int dy)
Moves this point within the plane.

Parameters:
dx - Horizontal distance to move this point.
dy - Vertical distance to move this point.

translate

public void translate(XYPoint point)
Moves this point using existing point as reference.

Parameters:
point - Horizontal position of parameter point used as distance to move this point horizontally; the vertical position of parameter point used as distance to move this point vertically.





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal