|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m2g.ScalableImage javax.microedition.m2g.SVGImage
public class SVGImage
This class represents an SVG image conforming to the W3C SVG Tiny 1.1 Profile. Applications can access the Document
associated with this SVGImage using getDocument
method. Using the Document
class,
it is possible to interact with the content and perform operations such as zoom, pan, and rotate
apart from various other functions. The event dispatching methods as described
in this class must be used for dispatching user specific events to the underlying SVG engine.
Note that the DOM event flow resulting from invoking methods such as focusOn or dispatchMouseEvent are limited to
the at-target and bubble phase of the DOM Level 2 event flow.
The width and height values specified in the SVGImage are only used to compute the initial viewport width/height. It is also important to note that according to the SVG 1.1 specification, if viewBox is not defined, then the preserveAspectRatio attribute is ignored. Therefore, the contents should not be scaled if there is no viewBox defined.
Note: If the application does not have the necessary privilege rights to access this (SVG)
content, a SecurityException may be thrown by the underlying implementation. This is applicable
to all the tree navigation (see Node
) and trait acessor methods (see SVGElement
).
Features such as zooming, panning and playing of animations will not be affected.
Here is the list of events supported in this specification:
Events |
Description |
---|---|
"DOMFocusIn" |
Occurs when the element comes into focus. |
"DOMFocusOut" |
Occurs when an element goes out of focus. |
"DOMActivate" |
Occurs when an element is activated, for instance, through a keypress (select) |
"click" |
Occurs when the pointing device button is clicked over the SVG content (or particular SVGElement) |
ScalableImage
,
Document
Constructor Summary | |
---|---|
protected |
SVGImage()
Constructor |
Method Summary | |
---|---|
void |
activate()
This method is used to dispatch an "DOMActivate" event to the document. |
static SVGImage |
createEmptyImage(ExternalResourceHandler handler)
This method creates and loads an empty SVGImage (skeleton) that can be used to programatically construct a simple SVG image. |
void |
dispatchMouseEvent(java.lang.String type,
int x,
int y)
This method is used to dispatch a mouse event of the specified type to the
document. |
void |
focusOn(SVGElement element)
This method triggers a "DOMFocusIn" event with the specified element as the event target. |
Document |
getDocument()
Returns the associated Document . |
int |
getViewportHeight()
This method returns the ScalableImage's viewport height. |
int |
getViewportWidth()
This method returns the ScalableImage's viewport width. |
void |
incrementTime(float seconds)
Increments the animation or media timeline for this SVGImage (in seconds). |
void |
requestCompleted(java.lang.String URI,
java.io.InputStream resourceData)
Once the requested external resource is available, the application forwards this information (resourceData) to the SVG engine. |
void |
setViewportHeight(int height)
This method sets the new (viewport) height of this ScalableImage. |
void |
setViewportWidth(int width)
This method sets the new (viewport) width of this ScalableImage. |
Methods inherited from class javax.microedition.m2g.ScalableImage |
---|
createImage, createImage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected SVGImage()
Method Detail |
---|
public Document getDocument()
Document
.
Document
.public static SVGImage createEmptyImage(ExternalResourceHandler handler)
If an handler is specified, the engine will invoke it for any external resource referenced in the document. If the handler is set to null, the SVGImage will try to load images automatically using the engine default implementation,but might not be able to load all of them.
Note that the handler
is also called when the xlink:href attribute on
<image> is set or changed by the application, but the call is made only when the
element is hooked into the document tree i.e. when the ancestors go all the way up to
the root <svg> element. There are two cases:
handler
- implementation of the ExternalResourceHandler interface
ExternalResourceHandler
public void dispatchMouseEvent(java.lang.String type, int x, int y) throws DOMException
type
to the
document. The mouse position is given as screen coordinates x, y
. If the
x, y values are outside the viewport area or no target is available for the x, y
coordinates, the event is not dispatched. Note that when a "click" event is dispatched,
a "DOMActivate" is automatically dispatched by the underlying implementation. The only
required mouse event type is "click". Implementations may support more event types than click.
However, using these additional event types may not work in all conformant JSR 226 1.0
implementations. Therefore, if an unsupported type is specified,
a DOMException with error code NOT_SUPPORTED_ERR is thrown.
type
- the type of mouse event.x
- the x location of the mouse/pointer in viewport coordinate
system.y
- the y location of the mouse/pointer in viewport coordinate
system.
DOMException
- with error code NOT_SUPPORTED_ERR: if the event type
is not supported.
java.lang.NullPointerException
- if type
is null.
java.lang.IllegalArgumentException
- if the x or y values are negative.public void activate()
public void focusOn(SVGElement element) throws DOMException
null
and setting
null
will remove the current focus.
element
- the element to set the focus on.
DOMException
- with error code WRONG_DOCUMENT_ERR: if invalid element is passed (for
ex: an element that does not belong to this document).public void incrementTime(float seconds)
seconds
- the value of time to increment in seconds.
java.lang.IllegalArgumentException
- if the specified time is negative.public void setViewportWidth(int width)
setViewportWidth
in class ScalableImage
width
- the new width to be set.
java.lang.IllegalArgumentException
- if width is negative.getViewportWidth()
public void setViewportHeight(int height)
setViewportHeight
in class ScalableImage
height
- the new height to be set.
java.lang.IllegalArgumentException
- if height is negative.getViewportHeight()
public int getViewportWidth()
getViewportWidth
in class ScalableImage
setViewportWidth(int)
public int getViewportHeight()
getViewportHeight
in class ScalableImage
setViewportHeight(int)
public void requestCompleted(java.lang.String URI, java.io.InputStream resourceData) throws java.io.IOException
SVGImage
, the engine will replace the current resource data with the new
one. Note: Setting null
for resourceData indicates that the requested resource
could not be fetched by the ResourceHandler
or application, and in this
event the SVG engine will not make further attempts to load this resource.
requestCompleted
in class ScalableImage
URI
- URI that was requested through requestExternalResourceresourceData
- inputstream containing the external resource
java.io.IOException
- if an error occurs while loading the resource.
java.lang.NullPointerException
- if URL is null.ExternalResourceHandler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |