simtools.images.svg
Class SVGFileHolder

java.lang.Object
  extended by simtools.images.svg.SVGFileHolder
Direct Known Subclasses:
TestSVGImageFactory.TestFileHolder

public class SVGFileHolder
extends java.lang.Object

The holder of one SVG document in charge of computing the images for each requested sizes

Author:
cazenave_c

Field Summary
protected  SVGImageFactory factory
          The SVGImageFactory in charge of this holder
protected  java.io.File file
          The SVG file
protected  int height
          Width and height for the original document.
protected  java.util.HashMap imageElements
          All the generated images with different sizes The key contains the size specification
protected  TranscoderInput tinput
          The batik transoder SVG input
protected  java.lang.String url
          The SVG url
protected  int width
          Width and height for the original document.
 
Constructor Summary
SVGFileHolder(SVGImageFactory factory, java.io.File f)
          Construct a new SVG holder
 
Method Summary
 void generate(int w, int h, SVGImageFactory.FactoryListener l, boolean background)
          Generate an image of the specified size from the SVG file The listener gets back (the image or an error message) If the image is not yet available, it is generated in a thread if background is set to true
 ImageHolder get(int w, int h)
          Get an image of the specified size from the SVG file If the image is not yet available then return null
 java.io.File getFile()
          Get the file managed by this hoder
 java.lang.Object getKey(int w, int h)
          Generate a key for an image managed by this holder
 boolean isEmpty()
          Check if the holder is empty i.e. there is no more user of this SVG file
 void read(java.io.ObjectInputStream in, SVGImageFactory.FactoryListener l)
          e Read the image for one of the user of this SVG file
 void relase(SVGImageFactory.FactoryListener l)
          Release one of the user of this SVG file If there is no more user the related image is freed
 void write(java.io.ObjectOutputStream out, SVGImageFactory.FactoryListener l)
          Save the image for one of the user of this SVG file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected final java.io.File file
The SVG file


url

protected final java.lang.String url
The SVG url


tinput

protected final TranscoderInput tinput
The batik transoder SVG input


imageElements

protected java.util.HashMap imageElements
All the generated images with different sizes The key contains the size specification

See Also:
The value is a ImageHolder which contains the image and all the related listeners

factory

protected final SVGImageFactory factory
The SVGImageFactory in charge of this holder


width

protected int width
Width and height for the original document. They are set to -1 until the size is known


height

protected int height
Width and height for the original document. They are set to -1 until the size is known

Constructor Detail

SVGFileHolder

public SVGFileHolder(SVGImageFactory factory,
                     java.io.File f)
Construct a new SVG holder

Parameters:
factory -
f -
Method Detail

isEmpty

public boolean isEmpty()
Check if the holder is empty i.e. there is no more user of this SVG file

Returns:
true if empty

getFile

public java.io.File getFile()
Get the file managed by this hoder

Returns:
the file

relase

public void relase(SVGImageFactory.FactoryListener l)
Release one of the user of this SVG file If there is no more user the related image is freed

Parameters:
l - the user listener

write

public void write(java.io.ObjectOutputStream out,
                  SVGImageFactory.FactoryListener l)
           throws java.io.IOException
Save the image for one of the user of this SVG file

Parameters:
l - the user listener
Throws:
java.io.IOException

read

public void read(java.io.ObjectInputStream in,
                 SVGImageFactory.FactoryListener l)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
e Read the image for one of the user of this SVG file

Parameters:
l - the user listener
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getKey

public java.lang.Object getKey(int w,
                               int h)
Generate a key for an image managed by this holder

Parameters:
w - the image width
h - the image height
Returns:
the key

get

public ImageHolder get(int w,
                       int h)
Get an image of the specified size from the SVG file If the image is not yet available then return null

Parameters:
w - the image width
h - the image height
Returns:
the image holder

generate

public void generate(int w,
                     int h,
                     SVGImageFactory.FactoryListener l,
                     boolean background)
Generate an image of the specified size from the SVG file The listener gets back (the image or an error message) If the image is not yet available, it is generated in a thread if background is set to true

Parameters:
w - the image width
h - the image height
l - the listener
background - equals true to do the process in a new thread