public interface ImageToolkit
The following classes are useful to implement image toolkit plug-ins:
ImageToolkitUtil
, ImageRendererAdapter
.
Modifier and Type | Method and Description |
---|---|
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.
|
String getName()
String getDescription()
null
.
May contain newline characters.ImageRenderer getImageRenderer(URL url)
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
.
url
- URL of a graphics file;
"data:" URLs not supported; URLs having a fragment not supportednull
ImageRenderer getImageRenderer(byte[] data)
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
.
data
- graphics data (that is, the binary contents of a graphics
file)null
ImageToolkitUtil.detectImageFormat(byte[])
,
ImageToolkitUtil.match(byte[], byte[])
ImageRenderer getImageRenderer(Element element)
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
.
element
- root of the XML sub-treenull
ImageConverter getImageConverter(File inFile, File outFile)
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.
inFile
- graphics file to be converted to another formatoutFile
- graphics file resulting from the conversionnull