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.gui
Class QPolygon

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QPolygon

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable

    public class QPolygon

extends QtJambiObject
implements java.lang.Cloneable

The `QPolygon` class provides a vector of points using integer precision. A `QPolygon` object is a QVector<`QPoint`>. The easiest way to add points to a `QPolygon` is to use QVector's streaming operator, as illustrated below:

                QPolygon polygon = new QPolygon();
                polygon.add(new QPoint(10, 20));
                polygon.add(new QPoint(20, 30));

In addition to the functions provided by QVector, `QPolygon` provides some point-specific functions.

Each point in a polygon can be retrieved by passing its index to the point() function. To populate the polygon, `QPolygon` provides the setPoint() function to set the point at a given index, the setPoints() function to set all the points in the polygon (resizing it to the given number of points), and the putPoints() function which copies a number of given points into the polygon from a specified index (resizing the polygon if necessary).

`QPolygon` provides the `boundingRect()` and `translate()` functions for geometry functions. Use the `QMatrix::map()` function for more general transformations of QPolygons.

The `QPolygon` class is implicitly shared.

See also:
  QVector, `QPolygonF`, and `QLine`.

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
`QPolygon()` Constructs a polygon with no points.
`QPolygon(int size)` Constructs a polygon of the given `size`.
`QPolygon(java.util.List v)` Constructs a polygon containing the specified `points`.
`QPolygon(QPolygon a)` Constructs a copy of the given `polygon`.
`QPolygon(QRect r)` Constructs a polygon from the given `rectangle`.
`QPolygon(QRect r, boolean closed)` Constructs a polygon from the given `rectangle`.

Method Summary
`QPolygon` | `add(int x, int y)` Adds the point (`x`, `y`) to the end of this QPolygon's point list.
`QPolygon` | `add(QPoint pt)` Adds `pt` to this polygon's point list.
`QPolygon` | `add(QPolygon p)` Adds the points in `p` to the end of this polygons point list.
`void` | `append(QPoint t)` Append `t` to this polygon.
`QPoint` | `at(int i)` Returns the QPoint at inex `i`.
`QRect` | `boundingRect()` Returns the bounding rectangle of the polygon, or `QRect`(0, 0, 0, 0) if the polygon is empty.
`int` | `capacity()` Returns the capacity, i.e., the maximum number of points the polygon can contain.
`void` | `clear()` Clears this polygon of all points,
`QPolygon` | `clone()` This method is reimplemented for internal reasons
`boolean` | `contains(QPoint t)` Returns true of this QPolygon contains the point `t`; otherwise, returns false.
`boolean` | `containsPoint(QPoint pt, Qt.FillRule fillRule)` Returns true if the given `point` is inside the polygon according to the specified `fillRule`; otherwise returns false.
`int` | `count()` Returns the number of points that this QPolygon contains.
`int` | `count(QPoint t)` Returns the number of occurrences of `t` in this QPolygon.
`boolean` | `empty()` Returns true if this QPolygon does not contains any points; otherwise, returns true.
`QPoint` | `first()` Returns the first point contained in this QPolygon.
`static java.util.List` | `fromList(java.util.List list)` Sets this QPolygon's points to `list`.
`int` | `indexOf(QPoint t)` Returns the index of `t` after the index `from`.
`int` | `indexOf(QPoint t, int from)` Returns the index of `t` after the index `from`.
`QPolygon` | `intersected(QPolygon r)` Returns a polygon which is the intersection of this polygon and `r`.
`boolean` | `isEmpty()` Returns true if this QPolygon contains no points; otherwise, returns false.
`QPoint` | `last()` Returns the last point in this QPolygon.
`int` | `lastIndexOf(QPoint t)` Returns the last index after `from` of `t` in this QPolygon.
`int` | `lastIndexOf(QPoint t, int from)` Returns the last index after `from` of `t` in this QPolygon.
`java.util.List` | `mid(int pos)` Returns `length` points from this QPolygon, starting at index `from`.
`java.util.List` | `mid(int pos, int length)` Returns `length` points from this QPolygon, starting at index `from`.
`void` | `pop_back()` Removes the last point in this QPolygon, and then returns that point.
`void` | `pop_front()` Removes the first point from this QPolygon, and then returns that point,
`void` | `prepend(QPoint t)` Inserts the point `t` as the first point in the polygon.
`void` | `push_back(QPoint t)` Inserts `t` to the end of this QPolygon.
`void` | `push_front(QPoint t)` Inserts `t` as the first point of this polygon.
`void` | `readFrom(QDataStream stream)` Reads a QPolygon
`void` | `remove(int i)` rmoves the point at index `i`.
`void` | `remove(int i, int n)` Removes `n` points from the index `i`.
`void` | `replace(int i, QPoint t)` Replace the point at index `i` with `t`.
`int` | `size()` Returns the number of points in this polygon.
`QPolygon` | `subtracted(QPolygon r)` Returns a polygon which is `r` subtracted from this polygon.
`java.util.List` | `toList()` Returns the points contained in this polygon in a java.util.List.
`java.lang.String` | `toString()` Returns a string representation of the `this QPolygon`.
`void` | `translate(int dx, int dy)` Translates all points in the polygon by (`dx`, `dy`).
`void` | `translate(QPoint offset)` Translates all points in the polygon by the given `offset`.
`QPolygon` | `united(QPolygon r)` Returns a polygon which is the union of this polygon and `r`.
`QPoint` | `value(int i)` Returns the point at index `i`.
`QPoint` | `value(int i, QPoint defaultValue)` Returns the point at index `i`.
`void` | `writeTo(QDataStream stream)` Writes thisQPolygon

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

### QPolygon

    public QPolygon()

  Constructs a polygon with no points.

See also:
  QVector::isEmpty().

### QPolygon

    public QPolygon(QPolygon a)

  Constructs a copy of the given `polygon`.

See also:
  setPoints().

### QPolygon

    public QPolygon(QRect r)

  Constructs a polygon from the given `rectangle`. If `closed` is false, the polygon just contains the four points of the rectangle ordered clockwise, otherwise the polygon's fifth point is set to `rectangle`.topLeft().

  Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).

See also:
  setPoints().

### QPolygon

    public QPolygon(QRect r,
                    boolean closed)

  Constructs a polygon from the given `rectangle`. If `closed` is false, the polygon just contains the four points of the rectangle ordered clockwise, otherwise the polygon's fifth point is set to `rectangle`.topLeft().

  Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).

See also:
  setPoints().

### QPolygon

    public QPolygon(java.util.List v)

  Constructs a polygon containing the specified `points`.

See also:
  setPoints().

### QPolygon

    public QPolygon(int size)

  Constructs a polygon of the given `size`. Creates an empty polygon if `size` == 0.

See also:
  QVector::isEmpty().

Method Detail

### append

    public final void append(QPoint t)

  Append `t` to this polygon.

### at

    public final QPoint at(int i)

  Returns the QPoint at inex `i`.

### boundingRect

    public final QRect boundingRect()

  Returns the bounding rectangle of the polygon, or `QRect`(0, 0, 0, 0) if the polygon is empty.

See also:
  QVector::isEmpty().

### capacity

    public final int capacity()

  Returns the capacity, i.e., the maximum number of points the polygon can contain.

### clear

    public final void clear()

  Clears this polygon of all points,

### contains

    public final boolean contains(QPoint t)

  Returns true of this QPolygon contains the point `t`; otherwise, returns false.

### containsPoint

    public final boolean containsPoint(QPoint pt,
                                       Qt.FillRule fillRule)

  Returns true if the given `point` is inside the polygon according to the specified `fillRule`; otherwise returns false.

### count

    public final int count()

  Returns the number of points that this QPolygon contains.

### count

    public final int count(QPoint t)

  Returns the number of occurrences of `t` in this QPolygon.

### empty

    public final boolean empty()

  Returns true if this QPolygon does not contains any points; otherwise, returns true.

### first

    public final QPoint first()

  Returns the first point contained in this QPolygon.

### indexOf

    public final int indexOf(QPoint t)

  Returns the index of `t` after the index `from`. The method returns -1 if `t` was not found.

### indexOf

    public final int indexOf(QPoint t,
                             int from)

  Returns the index of `t` after the index `from`. The method returns -1 if `t` was not found.

### intersected

    public final QPolygon intersected(QPolygon r)

  Returns a polygon which is the intersection of this polygon and `r`.

### isEmpty

    public final boolean isEmpty()

  Returns true if this QPolygon contains no points; otherwise, returns false.

### last

    public final QPoint last()

  Returns the last point in this QPolygon.

### lastIndexOf

    public final int lastIndexOf(QPoint t)

  Returns the last index after `from` of `t` in this QPolygon.

### lastIndexOf

    public final int lastIndexOf(QPoint t,
                                 int from)

  Returns the last index after `from` of `t` in this QPolygon.

### mid

    public final java.util.List mid(int pos)

  Returns `length` points from this QPolygon, starting at index `from`.

### mid

    public final java.util.List mid(int pos,
                                    int length)

  Returns `length` points from this QPolygon, starting at index `from`.

### writeTo

    public final void writeTo(QDataStream stream)

  Writes thisQPolygon

### readFrom

    public final void readFrom(QDataStream stream)

  Reads a QPolygon

### pop_back

    public final void pop_back()

  Removes the last point in this QPolygon, and then returns that point.

### pop_front

    public final void pop_front()

  Removes the first point from this QPolygon, and then returns that point,

### prepend

    public final void prepend(QPoint t)

  Inserts the point `t` as the first point in the polygon.

### push_back

    public final void push_back(QPoint t)

  Inserts `t` to the end of this QPolygon.

### push_front

    public final void push_front(QPoint t)

  Inserts `t` as the first point of this polygon.

### remove

    public final void remove(int i)

  rmoves the point at index `i`.

### remove

    public final void remove(int i,
                             int n)

  Removes `n` points from the index `i`.

### replace

    public final void replace(int i,
                              QPoint t)

  Replace the point at index `i` with `t`.

### size

    public final int size()

  Returns the number of points in this polygon.

### subtracted

    public final QPolygon subtracted(QPolygon r)

  Returns a polygon which is `r` subtracted from this polygon.

### toList

    public final java.util.List toList()

  Returns the points contained in this polygon in a java.util.List.

### translate

    public final void translate(QPoint offset)

  Translates all points in the polygon by the given `offset`.

### translate

    public final void translate(int dx,
                                int dy)

  Translates all points in the polygon by (`dx`, `dy`).

### united

    public final QPolygon united(QPolygon r)

  Returns a polygon which is the union of this polygon and `r`.

See also:
  `intersected()`, and `subtracted()`.

### value

    public final QPoint value(int i)

  Returns the point at index `i`.

### value

    public final QPoint value(int i,
                              QPoint defaultValue)

  Returns the point at index `i`. If `i` is out of bounds, `defaultValue` is returned.

### fromList

    public static java.util.List fromList(java.util.List list)

  Sets this QPolygon's points to `list`.

### add

    public final QPolygon add(int x,
                              int y)

  Adds the point (`x`, `y`) to the end of this QPolygon's point list.

### add

    public final QPolygon add(QPoint pt)

  Adds `pt` to this polygon's point list.

### add

    public final QPolygon add(QPolygon p)

  Adds the points in `p` to the end of this polygons point list.

### toString

    public java.lang.String toString()

  Returns a string representation of the `this QPolygon`.

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

### clone

    public QPolygon 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