38 |
|
|
39 |
package javax.imageio.metadata; |
package javax.imageio.metadata; |
40 |
|
|
41 |
|
import org.w3c.dom.Node; |
42 |
|
|
43 |
/** |
/** |
44 |
|
* Represents metadata that describe an image or an image stream. |
45 |
|
* Each ImageIO plugin will represent image data using an opaque |
46 |
|
* object but all such objects should expose their internal |
47 |
|
* information as a tree of IIOMetadataNodes. |
48 |
|
* |
49 |
|
* There are three formats of metadata that a plugin can support: |
50 |
|
* |
51 |
|
* <ul> |
52 |
|
* <li>a "native" format</li> |
53 |
|
* <li>a custom format</li> |
54 |
|
* <li>a standard plugin-neutral format</li> |
55 |
|
* </ul> |
56 |
|
* |
57 |
|
* If a plugin supports more than one format of metadata, the other |
58 |
|
* formats can be retrieved by calling getMetadataFormatNames. |
59 |
|
* |
60 |
|
* The native format is used to transfer metadata from one image to |
61 |
|
* another image of the same type, losslessly. |
62 |
|
* |
63 |
|
* The custom format describes the image metadata and exposes a tree |
64 |
|
* of IIOMetadataNodes but its internal representation is specific to |
65 |
|
* this plugin. |
66 |
|
* |
67 |
|
* The plugin-neutral format uses a generic tree structure as its |
68 |
|
* internal representation. |
69 |
|
* |
70 |
|
* ImageTranscoders may be used to convert metadata understood by one |
71 |
|
* plugin to metadata understood by another, however the conversion |
72 |
|
* may be lossy. |
73 |
|
* |
74 |
* @author Michael Koch (konqueror@gmx.de) |
* @author Michael Koch (konqueror@gmx.de) |
75 |
|
* @author Thomas Fitzsimmons (fitzsim@redhat.com) |
76 |
*/ |
*/ |
77 |
public abstract class IIOMetadata |
public abstract class IIOMetadata |
78 |
{ |
{ |
85 |
protected boolean standardFormatSupported; |
protected boolean standardFormatSupported; |
86 |
|
|
87 |
/** |
/** |
88 |
* Creates a <code>IIOMetaData</code> object. |
* Construct an IIOMetadata object. |
89 |
*/ |
*/ |
90 |
protected IIOMetadata() |
protected IIOMetadata() |
91 |
{ |
{ |
93 |
} |
} |
94 |
|
|
95 |
/** |
/** |
96 |
* Creates a <code>IIOMetaData</code> object with the given arguments. |
* Construct an IIOMetadata object. |
97 |
* |
* |
98 |
* @param standardMetadataFormatSupported |
* @param standardMetadataFormatSupported |
99 |
* @param nativeMetadataFormatName |
* @param nativeMetadataFormatName |
243 |
{ |
{ |
244 |
this.controller = controller; |
this.controller = controller; |
245 |
} |
} |
246 |
|
|
247 |
|
public abstract Node getAsTree (String formatName); |
248 |
|
|
249 |
|
protected IIOMetadataNode getStandardChromaNode () |
250 |
|
{ |
251 |
|
return null; |
252 |
|
} |
253 |
|
|
254 |
|
protected IIOMetadataNode getStandardCompressionNode () |
255 |
|
{ |
256 |
|
return null; |
257 |
|
} |
258 |
|
|
259 |
|
protected IIOMetadataNode getStandardDataNode () |
260 |
|
{ |
261 |
|
return null; |
262 |
|
} |
263 |
|
|
264 |
|
protected IIOMetadataNode getStandardDimensionNode () |
265 |
|
{ |
266 |
|
return null; |
267 |
|
} |
268 |
|
|
269 |
|
protected IIOMetadataNode getStandardDocumentNode () |
270 |
|
{ |
271 |
|
return null; |
272 |
|
} |
273 |
|
|
274 |
|
protected IIOMetadataNode getStandardTextNode () |
275 |
|
{ |
276 |
|
return null; |
277 |
|
} |
278 |
|
|
279 |
|
protected IIOMetadataNode getStandardTileNode () |
280 |
|
{ |
281 |
|
return null; |
282 |
|
} |
283 |
|
|
284 |
|
protected IIOMetadataNode getStandardTransparencyNode () |
285 |
|
{ |
286 |
|
return null; |
287 |
|
} |
288 |
|
|
289 |
|
private void appendChild (IIOMetadataNode node, |
290 |
|
IIOMetadataNode child) |
291 |
|
{ |
292 |
|
if (child != null) |
293 |
|
node.appendChild(child); |
294 |
|
} |
295 |
|
|
296 |
|
protected final IIOMetadataNode getStandardTree () |
297 |
|
{ |
298 |
|
IIOMetadataNode node = new IIOMetadataNode(); |
299 |
|
|
300 |
|
appendChild (node, getStandardChromaNode()); |
301 |
|
appendChild (node, getStandardCompressionNode()); |
302 |
|
appendChild (node, getStandardDataNode()); |
303 |
|
appendChild (node, getStandardDimensionNode()); |
304 |
|
appendChild (node, getStandardDocumentNode()); |
305 |
|
appendChild (node, getStandardTextNode()); |
306 |
|
appendChild (node, getStandardTileNode()); |
307 |
|
appendChild (node, getStandardTransparencyNode()); |
308 |
|
|
309 |
|
return node; |
310 |
|
} |
311 |
|
|
312 |
|
public abstract void mergeTree (String formatName, |
313 |
|
Node root) |
314 |
|
throws IIOInvalidTreeException; |
315 |
|
|
316 |
|
public void setFromTree (String formatName, Node root) |
317 |
|
throws IIOInvalidTreeException |
318 |
|
{ |
319 |
|
reset(); |
320 |
|
|
321 |
|
mergeTree (formatName, root); |
322 |
|
} |
323 |
} |
} |