|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QPolygon
public class QPolygon
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.
QPolygonF
, and QLine
.
Nested Class Summary |
---|
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. |
boolean |
endsWith(QPoint t)
|
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)
|
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. |
boolean |
startsWith(QPoint t)
|
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()
|
void |
translate(int dx,
int dy)
Translates all points in the polygon by (dx, dy). |
void |
translate(QPoint offset)
This is an overloaded member function, provided for convenience. |
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)
|
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 |
---|
public QPolygon()
public QPolygon(QPolygon a)
public QPolygon(QRect r)
Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).
public QPolygon(QRect r, boolean closed)
Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).
public QPolygon(java.util.List v)
public QPolygon(int size)
Method Detail |
---|
public final void append(QPoint t)
public final QPoint at(int i)
public final QRect boundingRect()
QRect
(0, 0, 0, 0) if the polygon is empty.
public final int capacity()
public final void clear()
public final boolean contains(QPoint t)
public final boolean containsPoint(QPoint pt, Qt.FillRule fillRule)
public final int count()
public final int count(QPoint t)
public final boolean empty()
public final boolean endsWith(QPoint t)
public final QPoint first()
public final int indexOf(QPoint t)
public final int indexOf(QPoint t, int from)
public final QPolygon intersected(QPolygon r)
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
public final boolean isEmpty()
public final QPoint last()
public final int lastIndexOf(QPoint t)
public final int lastIndexOf(QPoint t, int from)
public final java.util.List mid(int pos)
public final java.util.List mid(int pos, int length)
public final void writeTo(QDataStream stream)
public final void readFrom(QDataStream stream)
public final void pop_back()
public final void pop_front()
public final void prepend(QPoint t)
public final void push_back(QPoint t)
public final void push_front(QPoint t)
public final void remove(int i)
public final void remove(int i, int n)
public final void replace(int i, QPoint t)
public final int size()
public final boolean startsWith(QPoint t)
public final QPolygon subtracted(QPolygon r)
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
public final java.util.List toList()
public final void translate(QPoint offset)
Translates all points in the polygon by the given offset.
public final void translate(int dx, int dy)
public final QPolygon united(QPolygon r)
Set operations on polygons, will treat the polygons as areas, and implicitly close the polygon.
intersected()
, and subtracted()
.
public final QPoint value(int i)
public final QPoint value(int i, QPoint defaultValue)
public static java.util.List fromList(java.util.List list)
public final QPolygon add(int x, int y)
public final QPolygon add(QPoint pt)
public final QPolygon add(QPolygon p)
public java.lang.String toString()
toString
in class java.lang.Object
public QPolygon clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |