KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > imageio > plugins > common > StandardMetadataFormat


1 /*
2  * @(#)StandardMetadataFormat.java 1.9 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.imageio.plugins.common;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.List JavaDoc;
12 import javax.imageio.ImageTypeSpecifier JavaDoc;
13 import javax.imageio.metadata.IIOMetadataFormatImpl JavaDoc;
14
15 public class StandardMetadataFormat extends IIOMetadataFormatImpl JavaDoc {
16
17     // Utility method for nodes with a single atttribute named "value"
18
private void addSingleAttributeElement(String JavaDoc elementName,
19                                            String JavaDoc parentName,
20                                            int dataType) {
21         addElement(elementName, parentName, CHILD_POLICY_EMPTY);
22         addAttribute(elementName, "value", dataType, true, null);
23     }
24
25     public StandardMetadataFormat() {
26         super(standardMetadataFormatName, CHILD_POLICY_SOME);
27         List JavaDoc values;
28         
29         // root -> Chroma
30
addElement("Chroma", standardMetadataFormatName,
31                    CHILD_POLICY_SOME);
32         
33         // root -> Chroma -> ColorSpaceType
34
addElement("ColorSpaceType", "Chroma",
35                    CHILD_POLICY_EMPTY);
36         
37         values = new ArrayList JavaDoc();
38         values.add("XYZ");
39         values.add("Lab");
40         values.add("Luv");
41         values.add("YCbCr");
42         values.add("Yxy");
43         values.add("YCCK");
44         values.add("PhotoYCC");
45         values.add("RGB");
46         values.add("GRAY");
47         values.add("HSV");
48         values.add("HLS");
49         values.add("CMYK");
50         values.add("CMY");
51         values.add("2CLR");
52         values.add("3CLR");
53         values.add("4CLR");
54         values.add("5CLR");
55         values.add("6CLR");
56         values.add("7CLR");
57         values.add("8CLR");
58         values.add("9CLR");
59         values.add("ACLR");
60         values.add("BCLR");
61         values.add("CCLR");
62         values.add("DCLR");
63         values.add("ECLR");
64         values.add("FCLR");
65         addAttribute("ColorSpaceType",
66                      "name",
67                      DATATYPE_STRING,
68                      true,
69                      null,
70                      values);
71         
72         // root -> Chroma -> NumChannels
73
addElement("NumChannels", "Chroma",
74                    CHILD_POLICY_EMPTY);
75         addAttribute("NumChannels", "value",
76                      DATATYPE_INTEGER,
77                      true,
78                      0, Integer.MAX_VALUE);
79         
80         // root -> Chroma -> Gamma
81
addElement("Gamma", "Chroma", CHILD_POLICY_EMPTY);
82         addAttribute("Gamma", "value",
83                      DATATYPE_FLOAT, true, null);
84         
85         // root -> Chroma -> BlackIsZero
86
addElement("BlackIsZero", "Chroma", CHILD_POLICY_EMPTY);
87         addBooleanAttribute("BlackIsZero", "value", true, true);
88         
89         // root -> Chroma -> Palette
90
addElement("Palette", "Chroma", 0, Integer.MAX_VALUE);
91         
92         // root -> Chroma -> PaletteEntry
93
addElement("PaletteEntry", "Palette", CHILD_POLICY_EMPTY);
94         addAttribute("PaletteEntry", "index", DATATYPE_INTEGER,
95                      true, null);
96         addAttribute("PaletteEntry", "red", DATATYPE_INTEGER,
97                      true, null);
98         addAttribute("PaletteEntry", "green", DATATYPE_INTEGER,
99                      true, null);
100         addAttribute("PaletteEntry", "blue", DATATYPE_INTEGER,
101                      true, null);
102         addAttribute("PaletteEntry", "alpha", DATATYPE_INTEGER,
103                      false, "255");
104         
105         // root -> Chroma -> BackgroundIndex
106
addElement("BackgroundIndex", "Chroma", CHILD_POLICY_EMPTY);
107         addAttribute("BackgroundIndex", "value", DATATYPE_INTEGER,
108                      true, null);
109         
110         // root -> Chroma -> BackgroundColor
111
addElement("BackgroundColor", "Chroma", CHILD_POLICY_EMPTY);
112         addAttribute("BackgroundColor", "red", DATATYPE_INTEGER,
113                      true, null);
114         addAttribute("BackgroundColor", "green", DATATYPE_INTEGER,
115                      true, null);
116         addAttribute("BackgroundColor", "blue", DATATYPE_INTEGER,
117                      true, null);
118         
119         // root -> Compression
120
addElement("Compression", standardMetadataFormatName,
121                    CHILD_POLICY_SOME);
122         
123         // root -> Compression -> CompressionTypeName
124
addSingleAttributeElement("CompressionTypeName",
125                                   "Compression",
126                                   DATATYPE_STRING);
127         
128         // root -> Compression -> Lossless
129
addElement("Lossless", "Compression", CHILD_POLICY_EMPTY);
130         addBooleanAttribute("Lossless", "value", true, true);
131         
132         // root -> Compression -> NumProgressiveScans
133
addSingleAttributeElement("NumProgressiveScans",
134                                   "Compression",
135                                   DATATYPE_INTEGER);
136         
137         // root -> Compression -> BitRate
138
addSingleAttributeElement("BitRate",
139                                   "Compression",
140                                   DATATYPE_FLOAT);
141
142         // root -> Data
143
addElement("Data", standardMetadataFormatName,
144                    CHILD_POLICY_SOME);
145         
146         // root -> Data -> PlanarConfiguration
147
addElement("PlanarConfiguration", "Data", CHILD_POLICY_EMPTY);
148         
149         values = new ArrayList JavaDoc();
150         values.add("PixelInterleaved");
151         values.add("PlaneInterleaved");
152         values.add("LineInterleaved");
153         values.add("TileInterleaved");
154         addAttribute("PlanarConfiguration", "value",
155                      DATATYPE_STRING,
156                      true,
157                      null,
158                      values);
159         
160         // root -> Data -> SampleFormat
161
addElement("SampleFormat", "Data", CHILD_POLICY_EMPTY);
162         
163         values = new ArrayList JavaDoc();
164         values.add("SignedIntegral");
165         values.add("UnsignedIntegral");
166         values.add("Real");
167         values.add("Index");
168         addAttribute("SampleFormat", "value",
169                      DATATYPE_STRING,
170                      true,
171                      null,
172                      values);
173         
174         // root -> Data -> BitsPerSample
175
addElement("BitsPerSample", "Data",
176                    CHILD_POLICY_EMPTY);
177         addAttribute("BitsPerSample", "value",
178                      DATATYPE_INTEGER,
179                      true,
180                      1, Integer.MAX_VALUE);
181         
182         // root -> Data -> SignificantBitsPerSample
183
addElement("SignificantBitsPerSample", "Data", CHILD_POLICY_EMPTY);
184         addAttribute("SignificantBitsPerSample", "value",
185                      DATATYPE_INTEGER,
186                      true,
187                      1, Integer.MAX_VALUE);
188         
189         // root -> Data -> SampleMSB
190
addElement("SampleMSB", "Data",
191                    CHILD_POLICY_EMPTY);
192         addAttribute("SampleMSB", "value",
193                      DATATYPE_INTEGER,
194                      true,
195                      1, Integer.MAX_VALUE);
196         
197         // root -> Dimension
198
addElement("Dimension", standardMetadataFormatName,
199                    CHILD_POLICY_SOME);
200         
201         // root -> Dimension -> PixelAspectRatio
202
addSingleAttributeElement("PixelAspectRatio",
203                                   "Dimension",
204                                   DATATYPE_FLOAT);
205         
206         // root -> Dimension -> ImageOrientation
207
addElement("ImageOrientation", "Dimension",
208                    CHILD_POLICY_EMPTY);
209         
210         values = new ArrayList JavaDoc();
211         values.add("Normal");
212         values.add("Rotate90");
213         values.add("Rotate180");
214         values.add("Rotate270");
215         values.add("FlipH");
216         values.add("FlipV");
217         values.add("FlipHRotate90");
218         values.add("FlipVRotate90");
219         addAttribute("ImageOrientation", "value",
220                      DATATYPE_STRING,
221                      true,
222                      null,
223                      values);
224         
225         // root -> Dimension -> HorizontalPixelSize
226
addSingleAttributeElement("HorizontalPixelSize",
227                                   "Dimension",
228                                   DATATYPE_FLOAT);
229         
230         // root -> Dimension -> VerticalPixelSize
231
addSingleAttributeElement("VerticalPixelSize",
232                                   "Dimension",
233                                   DATATYPE_FLOAT);
234         
235         // root -> Dimension -> HorizontalPhysicalPixelSpacing
236
addSingleAttributeElement("HorizontalPhysicalPixelSpacing",
237                                   "Dimension",
238                                   DATATYPE_FLOAT);
239         
240         // root -> Dimension -> VerticalPhysicalPixelSpacing
241
addSingleAttributeElement("VerticalPhysicalPixelSpacing",
242                                   "Dimension",
243                                   DATATYPE_FLOAT);
244         
245         // root -> Dimension -> HorizontalPosition
246
addSingleAttributeElement("HorizontalPosition",
247                                   "Dimension",
248                                   DATATYPE_FLOAT);
249         
250         // root -> Dimension -> VerticalPosition
251
addSingleAttributeElement("VerticalPosition",
252                                   "Dimension",
253                                   DATATYPE_FLOAT);
254         
255         // root -> Dimension -> HorizontalPixelOffset
256
addSingleAttributeElement("HorizontalPixelOffset",
257                                   "Dimension",
258                                   DATATYPE_INTEGER);
259         
260         // root -> Dimension -> VerticalPixelOffset
261
addSingleAttributeElement("VerticalPixelOffset",
262                                   "Dimension",
263                                   DATATYPE_INTEGER);
264
265         // root -> Dimension -> HorizontalScreenSize
266
addSingleAttributeElement("HorizontalScreenSize",
267                                   "Dimension",
268                                   DATATYPE_INTEGER);
269         
270         // root -> Dimension -> VerticalScreenSize
271
addSingleAttributeElement("VerticalScreenSize",
272                                   "Dimension",
273                                   DATATYPE_INTEGER);
274         
275         
276         // root -> Document
277
addElement("Document", standardMetadataFormatName,
278                    CHILD_POLICY_SOME);
279         
280         // root -> Document -> FormatVersion
281
addElement("FormatVersion", "Document",
282                    CHILD_POLICY_EMPTY);
283         addAttribute("FormatVersion", "value",
284                      DATATYPE_STRING,
285                      true,
286                      null);
287
288         // root -> Document -> SubimageInterpretation
289
addElement("SubimageInterpretation", "Document",
290                    CHILD_POLICY_EMPTY);
291         values = new ArrayList JavaDoc();
292         values.add("Standalone");
293         values.add("SinglePage");
294         values.add("FullResolution");
295         values.add("ReducedResolution");
296         values.add("PyramidLayer");
297         values.add("Preview");
298         values.add("VolumeSlice");
299         values.add("ObjectView");
300         values.add("Panorama");
301         values.add("AnimationFrame");
302         values.add("TransparencyMask");
303         values.add("CompositingLayer");
304         values.add("SpectralSlice");
305         values.add("Unknown");
306         addAttribute("SubimageInterpretation", "value",
307                      DATATYPE_STRING,
308                      true,
309                      null,
310                      values);
311         
312         // root -> Document -> ImageCreationTime
313
addElement("ImageCreationTime", "Document",
314                    CHILD_POLICY_EMPTY);
315         addAttribute("ImageCreationTime", "year",
316                      DATATYPE_INTEGER,
317                      true,
318                      null);
319         addAttribute("ImageCreationTime", "month",
320                      DATATYPE_INTEGER,
321                      true,
322                      null,
323                      "1", "12", true, true);
324         addAttribute("ImageCreationTime", "day",
325                      DATATYPE_INTEGER,
326                      true,
327                      null,
328                      "1", "31", true, true);
329         addAttribute("ImageCreationTime", "hour",
330                      DATATYPE_INTEGER,
331                      false,
332                      "0",
333                      "0", "23", true, true);
334         addAttribute("ImageCreationTime", "minute",
335                      DATATYPE_INTEGER,
336                      false,
337                      "0",
338                      "0", "59", true, true);
339         // second = 60 denotes leap second
340
addAttribute("ImageCreationTime", "second",
341                      DATATYPE_INTEGER,
342                      false,
343                      "0",
344                      "0", "60", true, true);
345         
346         // root -> Document -> ImageModificationTime
347
addElement("ImageModificationTime", "Document",
348                    CHILD_POLICY_EMPTY);
349         addAttribute("ImageModificationTime", "year",
350                      DATATYPE_INTEGER,
351                      true,
352                      null);
353         addAttribute("ImageModificationTime", "month",
354                      DATATYPE_INTEGER,
355                      true,
356                      null,
357                      "1", "12", true, true);
358         addAttribute("ImageModificationTime", "day",
359                      DATATYPE_INTEGER,
360                      true,
361                      null,
362                      "1", "31", true, true);
363         addAttribute("ImageModificationTime", "hour",
364                      DATATYPE_INTEGER,
365                      false,
366                      "0",
367                      "0", "23", true, true);
368         addAttribute("ImageModificationTime", "minute",
369                      DATATYPE_INTEGER,
370                      false,
371                      "0",
372                      "0", "59", true, true);
373         // second = 60 denotes leap second
374
addAttribute("ImageModificationTime", "second",
375                      DATATYPE_INTEGER,
376                      false,
377                      "0",
378                      "0", "60", true, true);
379         
380         // root -> Text
381
addElement("Text", standardMetadataFormatName,
382                    0, Integer.MAX_VALUE);
383         
384         // root -> Text -> TextEntry
385
addElement("TextEntry", "Text", CHILD_POLICY_EMPTY);
386         addAttribute("TextEntry", "keyword",
387                      DATATYPE_STRING,
388                      false,
389                      null);
390         addAttribute("TextEntry", "value",
391                      DATATYPE_STRING,
392                      true,
393                      null);
394         addAttribute("TextEntry", "language",
395                      DATATYPE_STRING,
396                      false,
397                      null);
398         addAttribute("TextEntry", "encoding",
399                      DATATYPE_STRING,
400                      false,
401                      null);
402         
403         values = new ArrayList JavaDoc();
404         values.add("none");
405         values.add("lzw");
406         values.add("zip");
407         values.add("bzip");
408         values.add("other");
409         addAttribute("TextEntry", "compression",
410                      DATATYPE_STRING,
411                      false,
412                      "none",
413                      values);
414         
415         // root -> Transparency
416
addElement("Transparency", standardMetadataFormatName,
417                    CHILD_POLICY_SOME);
418         
419         // root -> Transparency -> Alpha
420
addElement("Alpha", "Transparency", CHILD_POLICY_EMPTY);
421         
422         values = new ArrayList JavaDoc();
423         values.add("none");
424         values.add("premultiplied");
425         values.add("nonpremultiplied");
426         addAttribute("Alpha", "value",
427                      DATATYPE_STRING,
428                      false,
429                      "none",
430                      values);
431         
432         // root -> Transparency -> TransparentIndex
433
addSingleAttributeElement("TransparentIndex", "Transparency",
434                                   DATATYPE_INTEGER);
435         
436         // root -> Transparency -> TransparentColor
437
addElement("TransparentColor", "Transparency",
438                    CHILD_POLICY_EMPTY);
439         addAttribute("TransparentColor", "value",
440                      DATATYPE_INTEGER,
441                      true,
442                      0, Integer.MAX_VALUE);
443         
444         // root -> Transparency -> TileTransparencies
445
addElement("TileTransparencies", "Transparency",
446                    0, Integer.MAX_VALUE);
447         
448         // root -> Transparency -> TileTransparencies -> TransparentTile
449
addElement("TransparentTile", "TileTransparencies",
450                    CHILD_POLICY_EMPTY);
451         addAttribute("TransparentTile", "x",
452                      DATATYPE_INTEGER,
453                      true,
454                      null);
455         addAttribute("TransparentTile", "y",
456                      DATATYPE_INTEGER,
457                      true,
458                      null);
459         
460         // root -> Transparency -> TileOpacities
461
addElement("TileOpacities", "Transparency",
462                    0, Integer.MAX_VALUE);
463         
464         // root -> Transparency -> TileOpacities -> OpaqueTile
465
addElement("OpaqueTile", "TileOpacities",
466                    CHILD_POLICY_EMPTY);
467         addAttribute("OpaqueTile", "x",
468                      DATATYPE_INTEGER,
469                      true,
470                      null);
471         addAttribute("OpaqueTile", "y",
472                      DATATYPE_INTEGER,
473                      true,
474                      null);
475     }
476     
477     public boolean canNodeAppear(String JavaDoc elementName,
478                                  ImageTypeSpecifier JavaDoc imageType) {
479             return true;
480     }
481 }
482
Popular Tags