|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.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(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(String URI,
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected SVGImage()
Constructor.
Method Detail |
---|
public Document getDocument()
Returns the associated Document.
public 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. Note: A root <svg> element with default viewport size of 100x100 is also created inside this method.
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(String type, int x, int y) throws DOMException
This method is used to dispatch a mouse event of the specified 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.
NullPointerException
- if type
is null.
IllegalArgumentException
- if the x
or y
values are negative.public void activate()
This method is used to dispatch an "DOMActivate" event to the document. The element that has focus is activated, which means that a "DOMActivate" event with the the currently focused element as target is dispatched. If no element has focus, this method does not do anything and no event is dispatched.
public void focusOn(SVGElement element) throws DOMException
This method triggers a "DOMFocusIn" event with the specified element as
the event target. That element becomes the element with focus. This
method also triggers a "DOMFocusOut" event with the element which
previous had focus as target. When the activate method is called, a
"DOMActivate" event is triggered with the currently focused element as
the target. The initial focus is always 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)
Increments the animation or media timeline for this SVGImage (in seconds). As the name
implies, this method is intended to move only forward in the timeline and typically should be used
to animate SVG content when the SVGAnimator class in not used. Setting negative values will throw
an Exception.
As the new time is applied to the document, animation events (beginEvent, endEvent, repeatEvent) are
dispatched by the implementation.(see org.w3c.dom.events.TimeEvent
).
It is important to note that setting large increments of time would result in
skipping parts of the animation as per the SVG animation model.
seconds
- the value of time to increment in seconds.
IllegalArgumentException
- if the specified time seconds
is negative.public void setViewportWidth(int width)
This method sets the new (viewport) width of this ScalableImage
.
The viewport is the area where the ScalableImage
is rendered. Any parts
of the viewport that lie outside the boundaries of the target clipping
rectangle are clipped. The viewport upper left corner (x, y) is given
relative to the upper left corner of the target rendering surface.
setViewportWidth
in class ScalableImage
width
- the new width to be set.
IllegalArgumentException
- if width
is negative.SVGImage.getViewportWidth()
public void setViewportHeight(int height)
This method sets the new (viewport) height of this ScalableImage.
setViewportHeight
in class ScalableImage
height
- the new height to be set.
IllegalArgumentException
- if height is negative.SVGImage.getViewportHeight()
public int getViewportWidth()
This method returns the ScalableImage
's viewport width. The initial
viewport width is taken from the "width" value specified in the Scalable Image. The value
returned is always in pixels. If the specified width is defined in percentages, the
values are mapped to the default view port size of 100x100. If the viewport width
is explicitly changed by the application, then the percentages are ignored and the content
is made to fit to this new viewport width.
getViewportWidth
in class ScalableImage
ScalableImage
.SVGImage.setViewportWidth(int)
public int getViewportHeight()
This method returns the ScalableImage
's viewport height. The initial
viewport height is taken from the "height" value specified in the Scalable Image. The value
returned is always in pixels. If the specified height is defined in percentages, the
values are mapped to the default view port size of 100x100. If the viewport height
is explicitly changed by the application, then the percentages are ignored and the content
is made to fit to this new viewport height.
getViewportHeight
in class ScalableImage
ScalableImage
.SVGImage.setViewportHeight(int)
public void requestCompleted(String URI, InputStream resourceData) throws IOException
Once the requested external resource is available, the application forwards this information
(resourceData) to the SVG engine. If this method is called a second time for a same URL of a
same 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 requestExternalResource
resourceData
- inputstream containing the external resource
IOException
- if an error occurs while loading the resource.
NullPointerException
- if URL
is nullExternalResourceHandler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal