|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QGraphicsItemAnimation
public class QGraphicsItemAnimation
The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem.
The QGraphicsItemAnimation class animates a QGraphicsItem. You can schedule changes to the item's transformation matrix at specified steps. The QGraphicsItemAnimation class has a current step value. When this value changes the transformations scheduled at that step are performed. The current step of the animation is set with the setStep() function.
QGraphicsItemAnimation will do a simple linear interpolation between the nearest adjacent scheduled changes to calculate the matrix. For instance, if you set the position of an item at values 0.0 and 1.0, the animation will show the item moving in a straight line between these positions. The same is true for scaling and rotation.
It is usual to use the class with a QTimeLine. The timeline's valueChanged() signal is then connected to the setStep() slot. For example, you can set up an item for rotation by calling setRotationAt() for different step values. The animations timeline is set with the setTimeLine function.
An example animation with a timeline follows:
QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20); QTimeLine *timer = new QTimeLine(5000); timer->setFrameRange(0, 100); QGraphicsItemAnimation *animation = new QGraphicsItemAnimation; animation->setItem(ball); animation->setTimeLine(timer); for (int i = 0; i < 200; ++i) animation->setPosAt(i / 200.0, QPointF(i, i)); QGraphicsScene *scene = new QGraphicsScene(); scene->setSceneRect(0, 0, 250, 250); scene->addItem(ball); QGraphicsView *view = new QGraphicsView(scene); view->show(); timer->start();
Note that steps lie between 0.0 and 1.0. It may be necessary to use setUpdateInterval(). The default update interval is 40 ms. A scheduled transformation cannot be removed when set, so scheduling several transformations of the same kind (e.g., rotations) at the same step is not recommended.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QGraphicsItemAnimation()
Equivalent to QGraphicsItemAnimation(0). |
|
QGraphicsItemAnimation(QObject parent)
Constructs an animation object with the given parent. |
Method Summary | |
---|---|
protected void |
afterAnimationStep(double step)
This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place. |
protected void |
beforeAnimationStep(double step)
This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. |
void |
clear()
Clears the scheduled transformations used for the animation, but retains the item and timeline. |
static QGraphicsItemAnimation |
fromNativePointer(QNativePointer nativePointer)
This function returns the QGraphicsItemAnimation instance pointed to by nativePointer |
double |
horizontalScaleAt(double step)
Returns the horizontal scale for the item at the specified step value. |
double |
horizontalShearAt(double step)
Returns the horizontal shear for the item at the specified step value. |
QGraphicsItemInterface |
item()
Returns the item on which the animation object operates. |
QMatrix |
matrixAt(double step)
Returns the matrix used to transform the item at the specified step value. |
QPointF |
posAt(double step)
Returns the position of the item at the given step value. |
java.util.List<QPair<java.lang.Double,QPointF>> |
posList()
Returns all explicitly inserted positions. |
void |
reset()
Resets the item to its starting position and transformation. |
double |
rotationAt(double step)
Returns the angle at which the item is rotated at the specified step value. |
java.util.List<QPair<java.lang.Double,java.lang.Double>> |
rotationList()
Returns all explicitly inserted rotations. |
java.util.List<QPair<java.lang.Double,QPointF>> |
scaleList()
Returns all explicitly inserted scales. |
void |
setItem(QGraphicsItemInterface item)
Sets the specified item to be used in the animation. |
void |
setPosAt(double step,
QPointF pos)
Sets the position of the item at the given step value to the pos specified. |
void |
setRotationAt(double step,
double angle)
Sets the rotation of the item at the given step value to the angle specified. |
void |
setScaleAt(double step,
double sx,
double sy)
Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy. |
void |
setShearAt(double step,
double sh,
double sv)
Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv. |
void |
setStep(double x)
Sets the current x value for the animation, causing the transformations scheduled at this step to be performed. |
void |
setTimeLine(QTimeLine timeLine)
Sets the timeline object used to control the rate of animation to the timeLine specified. |
void |
setTranslationAt(double step,
double dx,
double dy)
Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy. |
java.util.List<QPair<java.lang.Double,QPointF>> |
shearList()
Returns all explicitly inserted shears. |
QTimeLine |
timeLine()
Returns the timeline object used to control the rate at which the animation occurs. |
java.util.List<QPair<java.lang.Double,QPointF>> |
translationList()
Returns all explicitly inserted translations. |
double |
verticalScaleAt(double step)
Returns the vertical scale for the item at the specified step value. |
double |
verticalShearAt(double step)
Returns the vertical shear for the item at the specified step value. |
double |
xTranslationAt(double step)
Returns the horizontal translation of the item at the specified step value. |
double |
yTranslationAt(double step)
Returns the vertical translation of the item at the specified step value. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGraphicsItemAnimation()
Equivalent to QGraphicsItemAnimation(0).
public QGraphicsItemAnimation(QObject parent)
Constructs an animation object with the given parent.
Method Detail |
---|
public final void clear()
Clears the scheduled transformations used for the animation, but retains the item and timeline.
public final double horizontalScaleAt(double step)
Returns the horizontal scale for the item at the specified step value.
public final double horizontalShearAt(double step)
Returns the horizontal shear for the item at the specified step value.
public final QGraphicsItemInterface item()
Returns the item on which the animation object operates.
public final QMatrix matrixAt(double step)
Returns the matrix used to transform the item at the specified step value.
public final QPointF posAt(double step)
Returns the position of the item at the given step value.
public final java.util.List<QPair<java.lang.Double,QPointF>> posList()
Returns all explicitly inserted positions.
public final void reset()
Resets the item to its starting position and transformation.
public final double rotationAt(double step)
Returns the angle at which the item is rotated at the specified step value.
public final java.util.List<QPair<java.lang.Double,java.lang.Double>> rotationList()
Returns all explicitly inserted rotations.
public final java.util.List<QPair<java.lang.Double,QPointF>> scaleList()
Returns all explicitly inserted scales.
public final void setItem(QGraphicsItemInterface item)
Sets the specified item to be used in the animation.
public final void setPosAt(double step, QPointF pos)
Sets the position of the item at the given step value to the pos specified.
public final void setRotationAt(double step, double angle)
Sets the rotation of the item at the given step value to the angle specified.
public final void setScaleAt(double step, double sx, double sy)
Sets the scale of the item at the given step value using the horizontal and vertical scale factors specified by sx and sy.
public final void setShearAt(double step, double sh, double sv)
Sets the shear of the item at the given step value using the horizontal and vertical shear factors specified by sh and sv.
public final void setStep(double x)
Sets the current x value for the animation, causing the transformations scheduled at this step to be performed.
public final void setTimeLine(QTimeLine timeLine)
Sets the timeline object used to control the rate of animation to the timeLine specified.
public final void setTranslationAt(double step, double dx, double dy)
Sets the translation of the item at the given step value using the horizontal and vertical coordinates specified by dx and dy.
public final java.util.List<QPair<java.lang.Double,QPointF>> shearList()
Returns all explicitly inserted shears.
public final QTimeLine timeLine()
Returns the timeline object used to control the rate at which the animation occurs.
public final java.util.List<QPair<java.lang.Double,QPointF>> translationList()
Returns all explicitly inserted translations.
public final double verticalScaleAt(double step)
Returns the vertical scale for the item at the specified step value.
public final double verticalShearAt(double step)
Returns the vertical shear for the item at the specified step value.
public final double xTranslationAt(double step)
Returns the horizontal translation of the item at the specified step value.
public final double yTranslationAt(double step)
Returns the vertical translation of the item at the specified step value.
protected void afterAnimationStep(double step)
This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place. The animation step is provided for use in cases where the action depends on its value.
protected void beforeAnimationStep(double step)
This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. The animation step is provided for use in cases where the action depends on its value.
public static QGraphicsItemAnimation fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |