public class ExternalImageToolkit extends Object implements ImageToolkit
Modifier and Type | Class and Description |
---|---|
static class |
ExternalImageToolkit.Converter |
static class |
ExternalImageToolkit.Format |
Constructor and Description |
---|
ExternalImageToolkit(String name,
String description,
ExternalImageToolkit.Converter[] converters,
URL configURL) |
Modifier and Type | Method and Description |
---|---|
URL |
getConfigurationURL() |
ExternalImageToolkit.Converter[] |
getConverters() |
String |
getDescription()
Returns a short description of this toolkit.
|
ImageConverter |
getImageConverter(File inFile,
File outFile)
Returns an ImageConverter which can be used to convert specified files.
|
ImageRenderer |
getImageRenderer(byte[] data)
Returns an ImageRenderer which can be used to create an image
representing the specified data.
|
ImageRenderer |
getImageRenderer(Element element)
Returns an ImageRenderer which can be used to create an image
representing the specified XML element.
|
ImageRenderer |
getImageRenderer(URL url)
Returns an ImageRenderer which can be used to create an image
representing the specified URL.
|
String |
getName()
Returns the name of this toolkit.
|
public ExternalImageToolkit(String name, String description, ExternalImageToolkit.Converter[] converters, URL configURL)
public String getName()
ImageToolkit
getName
in interface ImageToolkit
public String getDescription()
ImageToolkit
null
.
May contain newline characters.getDescription
in interface ImageToolkit
public ExternalImageToolkit.Converter[] getConverters()
public URL getConfigurationURL()
public ImageRenderer getImageRenderer(URL url)
ImageToolkit
null
if this
toolkit has no such renderer.
This method is invoked when the graphics file that is to be rendered on screen is referenced by the document being edited. DocBook example: <imagedata fileref="URL"/>.
This method typically checks the filename extension of the URL. If
this extension denotes a format which is supported by this toolkit, the
method returns a properly configured ImageRenderer. Otherwise, this
method returns null
.
getImageRenderer
in interface ImageToolkit
url
- URL of a graphics file;
"data:" URLs not supported; URLs having a fragment not supportednull
public ImageRenderer getImageRenderer(byte[] data)
ImageToolkit
null
if this
toolkit has no such renderer.
This method is invoked when the graphics file that is to be rendered on screen is embedded in the document being edited. Example: <image data="au8ze...base64Binary...t514l"/>.
This method typically checks the magic string or binary signature of
the data. For example: if the first bytes are 0x4949 or
0x4D4D, the format is TIFF. If this magic string denotes a
format which is supported by this toolkit, the method returns a
properly configured ImageRenderer. Otherwise, this method returns
null
.
getImageRenderer
in interface ImageToolkit
data
- graphics data (that is, the binary contents of a graphics
file)null
ImageToolkitUtil.detectImageFormat(byte[])
,
ImageToolkitUtil.match(byte[], byte[])
public ImageRenderer getImageRenderer(Element element)
ImageToolkit
null
if
this toolkit has no such renderer.
This method is invoked when the graphics that is to be rendered on screen is a sub-tree of the document being edited. DocBook 5 example: <db5:imagedata><svg:svg> ... </svg:svg></db5:imagedata> (the element to be rendered is <svg:svg>, not <db5:imagedata>).
This method typically checks the namespace of the element. If this
namespace denotes a format which is supported by this toolkit, the
method returns a properly configured ImageRenderer. Otherwise, this
method returns null
.
getImageRenderer
in interface ImageToolkit
element
- root of the XML sub-treenull
public ImageConverter getImageConverter(File inFile, File outFile)
ImageToolkit
null
if this toolkit has no such converter.
This method is invoked when a graphics file needs to be converted from a format to another. The format conversion is specified in the <convertImage> child element of the <process> configuration element. More information in XMLmind XML Editor - Configuration and Deployment.
This method typically checks the filename extensions of both the
input file and the output file. If these extensions denotes formats
supported by this toolkit, the method returns a properly configured
ImageConverter. Otherwise, this method returns null
.
Like the getImageRenderer methods, this method is invoked several
times in a row until it returns a non-null converter. This means: can
you convert this TIFF image to GIF? No. OK, but can you convert this
TIFF image to PNG? No. OK, but can you convert his TIFF image to JPEG?
And so on. If this method returns null
in all cases, then,
another image toolkit, if any, is tested.
getImageConverter
in interface ImageToolkit
inFile
- graphics file to be converted to another formatoutFile
- graphics file resulting from the conversionnull