|
|
||||||||||
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.svg.QSvgRenderer
public class QSvgRenderer
The QSvgRenderer class is used to draw the contents of SVG files onto paint devices.
Using QSvgRenderer, Scalable Vector Graphics (SVG) can be rendered onto any QPaintDevice subclass, including QWidget, QImage, and QGLWidget.
QSvgRenderer provides an API that supports basic features of SVG rendering, such as loading and rendering of static drawings, and more interactive features like animation. Since the rendering is performed using QPainter, SVG drawings can be rendered on any subclass of QPaintDevice.
SVG drawings are either loaded when an QSvgRenderer is constructed, or loaded later using the load functions. Data is either supplied directly as serialized XML, or indirectly using a file name. If a valid file has been loaded, either when the renderer is constructed or at some later time, isValid returns true; otherwise it returns false. QSvgRenderer provides the render slot to render the current document, or the current frame of an animated document, using a given painter.
The defaultSize function provides information about the amount of space that is required to render the currently loaded SVG file. This is useful for paint devices, such as QWidget, that often need to supply a size hint to their parent layout. The default size of a drawing may differ from its visible area, found using the viewBox property.
Animated SVG drawings are supported, and can be controlled with a simple collection of functions and properties:
Finally, the QSvgRenderer class provides the repaintNeeded signal which is emitted whenever the rendering of the document needs to be updated.
Viewer Example
,
QPictureNested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, 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> |
Field Summary | |
---|---|
QSignalEmitter.Signal0 |
repaintNeeded
This signal is emitted whenever the rendering of the document needs to be updated, usually for the purposes of animation. |
Constructor Summary | |
---|---|
QSvgRenderer()
Equivalent to QSvgRenderer(0). |
|
QSvgRenderer(QByteArray contents)
Equivalent to QSvgRenderer(contents, 0). |
|
QSvgRenderer(QByteArray contents,
QObject parent)
Constructs a new renderer with the given parent and loads the specified SVG format contents. |
|
QSvgRenderer(QObject parent)
Constructs a new renderer with the given parent. |
|
QSvgRenderer(java.lang.String filename)
Equivalent to QSvgRenderer(filename, 0). |
|
QSvgRenderer(java.lang.String filename,
QObject parent)
Constructs a new renderer with the given parent and loads the contents of the SVG file with the specified filename. |
Method Summary | |
---|---|
boolean |
animated()
Returns true if the current document contains animated elements; otherwise returns false. |
int |
animationDuration()
|
QRectF |
boundsOnElement(java.lang.String id)
Returns bounding rectangle of the item with the given id. |
int |
currentFrame()
Returns the current frame of the document's animation, or 0 if the document is not animated. |
QSize |
defaultSize()
Returns the default size of the document contents. |
boolean |
elementExists(java.lang.String id)
Returns true if the element with the given id exists in the currently parsed SVG file and is a renderable element. |
int |
framesPerSecond()
Returns the number of frames per second to be shown. |
static QSvgRenderer |
fromNativePointer(QNativePointer nativePointer)
This function returns the QSvgRenderer instance pointed to by nativePointer |
boolean |
isValid()
Returns true if there is a valid current document; otherwise returns false. |
boolean |
load(QByteArray contents)
Loads the specified SVG format contents, returning true if the content was successfully parsed; otherwise returns false. |
boolean |
load(java.lang.String filename)
Loads the SVG file specified by filename, returning true if the content was successfully parsed; otherwise returns false. |
QMatrix |
matrixForElement(java.lang.String id)
Returns the transformation matrix setup for the element with the given id. |
void |
render(QPainter p)
Renders the current document, or the current frame of an animated document, using the given p. |
void |
render(QPainter p,
QRectF bounds)
Renders the current document, or the current frame of an animated document, using the given p on the specified bounds within the painter. |
void |
render(QPainter p,
java.lang.String elementId)
Equivalent to render(p, elementId, QRectF()). |
void |
render(QPainter p,
java.lang.String elementId,
QRectF bounds)
Renders the given element with elementId using the given p on the specified bounds. |
void |
setCurrentFrame(int arg__1)
Sets the current frame of the document's animation, or 0 if the document is not animated to arg__1. |
void |
setFramesPerSecond(int num)
Sets the number of frames per second to be shown to num. |
void |
setViewBox(QRect viewbox)
Sets the rectangle specifying the visible area of the document in logical coordinates to viewbox. |
void |
setViewBox(QRectF viewbox)
Sets the rectangle specifying the visible area of the document in logical coordinates to viewbox. |
QRect |
viewBox()
Returns viewBoxF.toRect(). |
QRectF |
viewBoxF()
Returns the rectangle specifying the visible area of the document in logical coordinates. |
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 |
Field Detail |
---|
public final QSignalEmitter.Signal0 repaintNeeded
This signal is emitted whenever the rendering of the document needs to be updated, usually for the purposes of animation.
Constructor Detail |
---|
public QSvgRenderer(java.lang.String filename)
Equivalent to QSvgRenderer(filename, 0).
public QSvgRenderer(java.lang.String filename, QObject parent)
Constructs a new renderer with the given parent and loads the contents of the SVG file with the specified filename.
public QSvgRenderer(QByteArray contents)
Equivalent to QSvgRenderer(contents, 0).
public QSvgRenderer(QByteArray contents, QObject parent)
Constructs a new renderer with the given parent and loads the specified SVG format contents.
public QSvgRenderer()
Equivalent to QSvgRenderer(0).
public QSvgRenderer(QObject parent)
Constructs a new renderer with the given parent.
Method Detail |
---|
public final boolean animated()
Returns true if the current document contains animated elements; otherwise returns false.
public final int animationDuration()
public final QRectF boundsOnElement(java.lang.String id)
Returns bounding rectangle of the item with the given id. The transformation matrix of parent elements is not affecting the bounds of the element.
public final int currentFrame()
Returns the current frame of the document's animation, or 0 if the document is not animated.
public final QSize defaultSize()
Returns the default size of the document contents.
public final boolean elementExists(java.lang.String id)
Returns true if the element with the given id exists in the currently parsed SVG file and is a renderable element.
Note: this method returns true only for elements that can be rendered. Which implies that elements that are considered part of the fill/stroke style properties, e.g. radialGradients even tough marked with "id" attributes will not be found by this method.
public final int framesPerSecond()
Returns the number of frames per second to be shown.
The number of frames per second is 0 if the current document is not animated.
public final boolean isValid()
Returns true if there is a valid current document; otherwise returns false.
public final boolean load(QByteArray contents)
Loads the specified SVG format contents, returning true if the content was successfully parsed; otherwise returns false.
public final boolean load(java.lang.String filename)
Loads the SVG file specified by filename, returning true if the content was successfully parsed; otherwise returns false.
public final QMatrix matrixForElement(java.lang.String id)
Returns the transformation matrix setup for the element with the given id. That includes the transformation on the element itself.
public final void render(QPainter p, QRectF bounds)
Renders the current document, or the current frame of an animated document, using the given p on the specified bounds within the painter. If the bounding rectangle is not specified the SVG file is mapped to the whole paint device.
public final void render(QPainter p, java.lang.String elementId)
Equivalent to render(p, elementId, QRectF()).
public final void render(QPainter p, java.lang.String elementId, QRectF bounds)
Renders the given element with elementId using the given p on the specified bounds. If the bounding rectangle is not specified the SVG element is mapped to the whole paint device.
public final void render(QPainter p)
Renders the current document, or the current frame of an animated document, using the given p.
public final void setCurrentFrame(int arg__1)
Sets the current frame of the document's animation, or 0 if the document is not animated to arg__1.
public final void setFramesPerSecond(int num)
Sets the number of frames per second to be shown to num.
The number of frames per second is 0 if the current document is not animated.
public final void setViewBox(QRectF viewbox)
Sets the rectangle specifying the visible area of the document in logical coordinates to viewbox.
public final void setViewBox(QRect viewbox)
Sets the rectangle specifying the visible area of the document in logical coordinates to viewbox.
public final QRect viewBox()
Returns viewBoxF.toRect().
public final QRectF viewBoxF()
Returns the rectangle specifying the visible area of the document in logical coordinates.
public static QSvgRenderer 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 |