Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.core
Class QPoint

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QPoint

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable

    public class QPoint

extends QtJambiObject
implements java.lang.Cloneable

The QPoint class defines a point in the plane using integer precision. A point is specified by a x coordinate and an y coordinate which can be accessed using the `x()` and `y()` functions. The `isNull()` function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the `setX()` and `setY()` functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p, the following statements are all equivalent:

            QPoint p = new QPoint();

            p.setX(p.x() + 1);
            p.add(new QPoint(1, 0));

A QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPoint object can also be divided or multiplied by an `int` or a `qreal`.

In addition, the QPoint class provides the `manhattanLength()` function which gives an inexpensive approximation of the length of the QPoint object interpreted as a vector. Finally, QPoint objects can be streamed as well as compared.

See also:
  `QPointF`, and `QPolygon`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QPoint()` Constructs a null point, i.
`QPoint(int xpos, int ypos)` Constructs a point with the given coordinates (`x`, `y`).

Method Summary
`QPoint` | `add(QPoint p)` Adds this QPoint to `p` and returns the result.
`QPoint` | `clone()` This method is reimplemented for internal reasons
`QPoint` | `divide(double d)` Divides this QPoint by divisor `d` and returns the result.
`boolean` | `isNull()` Returns true if both the x and y coordinates are set to 0, otherwise returns false.
`int` | `manhattanLength()` Returns the sum of the absolute values of `x()` and `y()`, traditionally known as the "Manhattan length" of the vector from the origin to the point.
`QPoint` | `multiply(double d)` Multiplies this QPoint by factor `d` and returns the result.
`void` | `readFrom(QDataStream arg__1)` Reads a QPoint
`void` | `setX(int x)` Sets the x coordinate of this point to the given `x` coordinate.
`void` | `setY(int y)` Sets the y coordinate of this point to the given `y` coordinate.
`QPoint` | `subtract(QPoint p)` Subtracts this QPoint by `p` and returns the result.
`java.lang.String` | `toString()` Returns a string representation of the `this QPoint`.
`void` | `writeTo(QDataStream arg__1)` Writes thisQPoint
`int` | `x()` Returns the x coordinate of this point.
`int` | `y()` Returns the y coordinate of this point.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QPoint

    public QPoint()

  Constructs a null point, i. . with coordinates (0, 0)

See also:
  `isNull()`.

### QPoint

    public QPoint(int xpos,
                  int ypos)

  Constructs a point with the given coordinates (`x`, `y`).

See also:
  `setX()`, and `setY()`.

Method Detail

### isNull

    public final boolean isNull()

  Returns true if both the x and y coordinates are set to 0, otherwise returns false.

### manhattanLength

    public final int manhattanLength()

  Returns the sum of the absolute values of `x()` and `y()`, traditionally known as the "Manhattan length" of the vector from the origin to the point. For example:

              protected QPoint oldPosition = new QPoint();

              protected void mouseMoveEvent(QMouseEvent event)
              {
                  QPoint point = new QPoint(event.pos().x(), event.pos().y());
                  point.subtract(oldPosition);
                  if (point.manhattanLength() > 3) {
                      // the mouse has moved more than 3 pixels since the oldPosition
                  }
              }

  This is a useful, and quick to calculate, approximation to the true length:

              double trueLength = Math.hypot(p.x(), p.y());

  The tradition of "Manhattan length" arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQPoint

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QPoint

### setX

    public final void setX(int x)

  Sets the x coordinate of this point to the given `x` coordinate.

See also:
  `x()`, and `setY()`.

### setY

    public final void setY(int y)

  Sets the y coordinate of this point to the given `y` coordinate.

See also:
  `y()`, and `setX()`.

### x

    public final int x()

  Returns the x coordinate of this point.

See also:
  `setX()`, and rx().

### y

    public final int y()

  Returns the y coordinate of this point.

See also:
  `setY()`, and ry().

### multiply

    public final QPoint multiply(double d)

  Multiplies this QPoint by factor `d` and returns the result. `d`

  Returns:

### divide

    public final QPoint divide(double d)

  Divides this QPoint by divisor `d` and returns the result.

### add

    public final QPoint add(QPoint p)

  Adds this QPoint to `p` and returns the result.

### subtract

    public final QPoint subtract(QPoint p)

  Subtracts this QPoint by `p` and returns the result.

### toString

    public java.lang.String toString()

  Returns a string representation of the `this QPoint`.

  Overrides:
    `toString` in class `java.lang.Object`

### clone

    public QPoint clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD