|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m2g.ScalableImage
public abstract class ScalableImage
This class models images in vector format, such as the Scalable Vector Graphics (SVG) image format. Therefore, it is required that all classes representing "scalable" images extend this class.
SVGImage
Constructor Summary | |
---|---|
protected |
ScalableImage()
Constructor |
Method Summary | |
---|---|
static ScalableImage |
createImage(java.io.InputStream stream,
ExternalResourceHandler handler)
This method creates and loads a ScalableImage (e.g. |
static ScalableImage |
createImage(java.lang.String url,
ExternalResourceHandler handler)
This method creates and loads a ScalableImage (e.g. |
abstract int |
getViewportHeight()
This method returns the ScalableImage's viewport height. |
abstract int |
getViewportWidth()
This method returns the ScalableImage's viewport width. |
abstract 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. |
abstract void |
setViewportHeight(int height)
This method sets the new (viewport) height of this ScalableImage. |
abstract void |
setViewportWidth(int width)
This method sets the new (viewport) width of this ScalableImage. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ScalableImage()
Method Detail |
---|
public static ScalableImage createImage(java.io.InputStream stream, ExternalResourceHandler handler) throws java.io.IOException
If an handler
is specified, the engine will invoke it for any
external resource referenced in the document. However, please note that data URIs
(for ex: base64 encoded images like <image xlink:href="data:image/png;base64,/9j/4AAQ..."/>)
are required to be decoded by the engine, and therefore the handler will not be invoked
in such cases. All these requests must occur before createImage returns, and the
engine must only make one call if there exist multiple resources
with the same URI. If the handler
is set to null, the ScalableImage
will try to load images automatically using the engine's default implementation,
but might not be able to load all of them. For example, if the ScalableImage
is loaded from a file in a Jar file, the implementation will not be able
to load images that have relative URIs (ex; <image xlink:href="myImage.png" />).
If the handler is not able to locate a requested resource, it informs the SVG engine
by calling the requestCompleted method with null
for resourceData.
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:
stream
- The stream from which the SVG content should be read.handler
- implementation of the ExternalResourceHandler interface
java.io.IOException
- if an error occurs while loading the content.
java.lang.NullPointerException
- if stream
is null.ExternalResourceHandler
public static ScalableImage createImage(java.lang.String url, ExternalResourceHandler handler) throws java.io.IOException
If an handler
is specified, the engine will invoke it for any
external resource referenced in the document. However, please note that data URIs
(for ex: base64 encoded images like <image xlink:href="data:image/png;base64,/9j/4AAQ..."/>)
are required to be decoded by the engine, and therefore the handler will not be invoked
in such cases. All these requests must occur before createImage returns, and the
engine must only make one call if there exist multiple resources
with the same URI. If the handler
is set to null, the ScalableImage
will try to load images automatically using the engine's default implementation,
but might not be able to load all of them. For example, if the ScalableImage
is loaded from a file in a Jar file, the implementation will not be able
to load images that have relative URIs (ex: <image xlink:href="myImage.png" />).
If the handler is not able to locate a requested resource, it informs the SVG engine
by calling the requestCompleted method with null
for resourceData.
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:
If the platform implementation supports the JSR-75 FileConnection, then the file: URLs as used by JSR-75 shall be supported and the images are loaded from files identified by this locator. This can be used to load possible DRM protected image files from the file system.
url
- A string in URL syntax that identifies the image source.handler
- implementation of the ExternalResourceHandler interface
java.io.IOException
- if an error occurs while loading the SVG content.
java.lang.NullPointerException
- if URL
is null.
java.lang.IllegalArgumentException
- if the specified locator is of unsupported type.
java.lang.SecurityException
- if the application does not have the privilege rights to access
the contents of this resource.ExternalResourceHandler
public abstract void setViewportWidth(int width)
width
- the new width to be set.
java.lang.IllegalArgumentException
- if width is negative.getViewportWidth()
public abstract void setViewportHeight(int height)
height
- the new height to be set.
java.lang.IllegalArgumentException
- if height is negative.getViewportHeight()
public abstract int getViewportWidth()
setViewportWidth(int)
public abstract int getViewportHeight()
setViewportHeight(int)
public abstract 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.
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 |