|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimtools.images.svg.SVGImageFactory
public class SVGImageFactory
A factory to load SVG files and display them using a BufferedImage Once a
given SVG file is loaded with a size definition or using the default one, the
image is generated in a dedicated thread. The loading is performed using
load
method which provides as an input a callback defined by
the FactoryListener
interface. Thanks to this interface, the
resulting image is provided to the caller when it is fully painted. If other
callers require the same SVG file (with the same size) then the image is
shared to avoid to recompute it. The caller is assumed to call the
release
method to free allocated ressources when possible If a
user of the image needs to rescale it, then it shall call the
scale
method which will perform the update of the image using
a listener dedicated thread. This thread will delay the computation so that
if several rescalings are required (in a time less than this delay plus the
time to do the computation) then only the last one is taken into account to
avoid useless computations. It is assumed that the old image is first
rescaled for intermediate updates and then will be painted to provide a real
SVG update for the new size.
Nested Class Summary | |
---|---|
static interface |
SVGImageFactory.FactoryListener
The listener for the image users |
Field Summary | |
---|---|
protected java.util.HashMap |
factoryElements
The elements managed by the the factory the key is computed according to the File providing the SVG the value is the SVGFileHolder
which is in charge of generating all the images for this SVG |
static int |
SCALE_DELAY
The delay between two scale computations |
Constructor Summary | |
---|---|
SVGImageFactory()
Create an instance of the factory |
Method Summary | |
---|---|
protected FactoryTranscoder |
createFactoryTranscoder(ImageHolder ie)
This method has to be overriden to provide a specialization of FactoryTranscoder |
protected SVGFileHolder |
createFileHolder(SVGImageFactory factory,
java.io.File f)
This method has to be overriden to provide a specialization of SVGFileHolder |
java.awt.image.BufferedImage |
get(java.io.File f)
Load an SVG file and paint it into an image |
java.awt.image.BufferedImage |
get(java.io.File f,
int w,
int h)
Load an SVG file and paint it into an image |
protected java.lang.Object |
getKey(java.io.File f)
Generate a key for an SVG file used to store in the hastable the SVGFileHolder |
void |
load(java.io.File f,
int w,
int h,
SVGImageFactory.FactoryListener l)
Load an SVG file and paint it into an image |
void |
load(java.io.File f,
SVGImageFactory.FactoryListener l)
Load an SVG file and paint it into an image using the SVF default size |
java.io.File |
read(java.io.ObjectInputStream in,
SVGImageFactory.FactoryListener l,
FileSerializer serializer,
java.io.File referenceFile)
Read the image used by one listener |
void |
release(java.io.File f,
SVGImageFactory.FactoryListener l)
Release the image used by one listener |
void |
scale(java.io.File f,
int w,
int h,
SVGImageFactory.FactoryListener l)
Change the size of an SVG document |
void |
wipeOff()
Clean factoryElements contents. |
void |
write(java.io.ObjectOutputStream out,
java.io.File f,
SVGImageFactory.FactoryListener l,
FileSerializer serializer,
java.io.File referenceFile)
Save the image used by one listener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int SCALE_DELAY
protected java.util.HashMap factoryElements
SVGFileHolder
which is in charge of generating all the images for this SVG
getKey
Constructor Detail |
---|
public SVGImageFactory()
Method Detail |
---|
public void wipeOff()
public void load(java.io.File f, SVGImageFactory.FactoryListener l)
f
- the file to loadl
- the listener to call back when the image is availablepublic java.awt.image.BufferedImage get(java.io.File f)
f
- the file to loadpublic java.awt.image.BufferedImage get(java.io.File f, int w, int h)
f
- the file to loadw
- the image width in pixels (=-1 for the default value)h
- the image height in pixels (=-1 for the default value)public void load(java.io.File f, int w, int h, SVGImageFactory.FactoryListener l)
f
- the file to loadw
- the image width in pixels (=-1 for the default value)h
- the image height in pixels (=-1 for the default value)l
- the listener to call back when the image is availableprotected java.lang.Object getKey(java.io.File f)
f
- the file
public void release(java.io.File f, SVGImageFactory.FactoryListener l)
f
- the filel
- the user listenerpublic void write(java.io.ObjectOutputStream out, java.io.File f, SVGImageFactory.FactoryListener l, FileSerializer serializer, java.io.File referenceFile) throws java.io.IOException
out
- the output streamf
- the filel
- the user listenerserializer
- to serialize the filereferenceFile
- used by the the file serializer
java.io.IOException
public java.io.File read(java.io.ObjectInputStream in, SVGImageFactory.FactoryListener l, FileSerializer serializer, java.io.File referenceFile) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the input streamf
- the filel
- the user listenerserializer
- to serialize the filereferenceFile
- used by the the file serializer
java.io.IOException
java.lang.ClassNotFoundException
public void scale(java.io.File f, int w, int h, SVGImageFactory.FactoryListener l)
f
- the SVG filew
- the image width in pixels (=-1 for the default value)h
- the image height in pixels (=-1 for the default value)l
- the user listenerprotected FactoryTranscoder createFactoryTranscoder(ImageHolder ie)
FactoryTranscoder
ie
- the transcoder constructor parameter
FactoryTrancoder
protected SVGFileHolder createFileHolder(SVGImageFactory factory, java.io.File f)
SVGFileHolder
factory
- the holder constructor factory parameterf
- the holder constructor file parameter
SVGFileHolder
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |