001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.imageio.metadata;
019:
020: import javax.imageio.ImageTypeSpecifier;
021: import java.util.ArrayList;
022:
023: class IIOStandardMetadataFormat extends IIOMetadataFormatImpl {
024: public IIOStandardMetadataFormat() {
025: super (standardMetadataFormatName, CHILD_POLICY_SOME);
026: buildDTD();
027: }
028:
029: @Override
030: public boolean canNodeAppear(String elementName,
031: ImageTypeSpecifier imageType) {
032: return true;
033: }
034:
035: private void buildDTD() {
036: // CHROMA
037: addElement("Chroma", standardMetadataFormatName,
038: CHILD_POLICY_SOME);
039:
040: addElement("ColorSpaceType", "Chroma", CHILD_POLICY_EMPTY);
041:
042: ArrayList<String> values = new ArrayList<String>(27);
043: values.add("XYZ");
044: values.add("Lab");
045: values.add("Luv");
046: values.add("YCbCr");
047: values.add("Yxy");
048: values.add("YCCK");
049: values.add("PhotoYCC");
050: values.add("RGB");
051: values.add("GRAY");
052: values.add("HSV");
053: values.add("HLS");
054: values.add("CMYK");
055: values.add("CMY");
056: values.add("2CLR");
057: values.add("3CLR");
058: values.add("4CLR");
059: values.add("5CLR");
060: values.add("6CLR");
061: values.add("7CLR");
062: values.add("8CLR");
063: values.add("9CLR");
064: values.add("ACLR");
065: values.add("BCLR");
066: values.add("CCLR");
067: values.add("DCLR");
068: values.add("ECLR");
069: values.add("FCLR");
070: addAttribute("ColorSpaceType", "name", DATATYPE_STRING, true,
071: null, values);
072:
073: addElement("NumChannels", "Chroma", CHILD_POLICY_EMPTY);
074: addAttribute("NumChannels", "value", DATATYPE_INTEGER, true, 0,
075: Integer.MAX_VALUE); // list - why?
076:
077: addElement("Gamma", "Chroma", CHILD_POLICY_EMPTY);
078: addAttribute("Gamma", "value", DATATYPE_FLOAT, true, null);
079:
080: addElement("BlackIsZero", "Chroma", CHILD_POLICY_EMPTY);
081: addBooleanAttribute("BlackIsZero", "value", true, true);
082:
083: addElement("Palette", "Chroma", 0, Integer.MAX_VALUE); // CHILD_POLICY_REPEAT
084: addElement("PaletteEntry", "Palette", CHILD_POLICY_EMPTY);
085: addAttribute("PaletteEntry", "index", DATATYPE_INTEGER, true,
086: null);
087: addAttribute("PaletteEntry", "red", DATATYPE_INTEGER, true,
088: null);
089: addAttribute("PaletteEntry", "green", DATATYPE_INTEGER, true,
090: null);
091: addAttribute("PaletteEntry", "blue", DATATYPE_INTEGER, true,
092: null);
093: addAttribute("PaletteEntry", "alpha", DATATYPE_INTEGER, false,
094: "255");
095:
096: addElement("BackgroundIndex", "Chroma", CHILD_POLICY_EMPTY);
097: addAttribute("BackgroundIndex", "value", DATATYPE_INTEGER,
098: true, null);
099:
100: addElement("BackgroundColor", "Chroma", CHILD_POLICY_EMPTY);
101: addAttribute("BackgroundColor", "red", DATATYPE_INTEGER, true,
102: null);
103: addAttribute("BackgroundColor", "green", DATATYPE_INTEGER,
104: true, null);
105: addAttribute("BackgroundColor", "blue", DATATYPE_INTEGER, true,
106: null);
107:
108: // COMPRESSION
109: addElement("Compression", standardMetadataFormatName,
110: CHILD_POLICY_SOME);
111:
112: addElement("CompressionTypeName", "Compression",
113: CHILD_POLICY_EMPTY);
114: addAttribute("CompressionTypeName", "value", DATATYPE_STRING,
115: true, null);
116:
117: addElement("Lossless", "Compression", CHILD_POLICY_EMPTY);
118: addBooleanAttribute("Lossless", "value", true, true);
119:
120: addElement("NumProgressiveScans", "Compression",
121: CHILD_POLICY_EMPTY);
122: addAttribute("NumProgressiveScans", "value", DATATYPE_INTEGER,
123: true, null);
124:
125: addElement("BitRate", "Compression", CHILD_POLICY_EMPTY);
126: addAttribute("BitRate", "value", DATATYPE_FLOAT, true, null);
127:
128: // DATA
129: addElement("Data", standardMetadataFormatName,
130: CHILD_POLICY_SOME);
131:
132: addElement("PlanarConfiguration", "Data", CHILD_POLICY_EMPTY);
133: values = new ArrayList<String>(4);
134: values.add("PixelInterleaved");
135: values.add("PlaneInterleaved");
136: values.add("LineInterleaved");
137: values.add("TileInterleaved");
138: addAttribute("PlanarConfiguration", "value", DATATYPE_STRING,
139: true, null, values);
140:
141: addElement("SampleFormat", "Data", CHILD_POLICY_EMPTY);
142: values = new ArrayList<String>(4);
143: values.add("SignedIntegral");
144: values.add("UnsignedIntegral");
145: values.add("Real");
146: values.add("Index");
147: addAttribute("SampleFormat", "value", DATATYPE_STRING, true,
148: null, values);
149:
150: addElement("BitsPerSample", "Data", CHILD_POLICY_EMPTY);
151: addAttribute("BitsPerSample", "value", DATATYPE_INTEGER, true,
152: 1, Integer.MAX_VALUE); // list
153:
154: addElement("SignificantBitsPerSample", "Data",
155: CHILD_POLICY_EMPTY);
156: addAttribute("SignificantBitsPerSample", "value",
157: DATATYPE_INTEGER, true, 1, Integer.MAX_VALUE); // list
158:
159: addElement("SampleMSB", "Data", CHILD_POLICY_EMPTY);
160: addAttribute("SampleMSB", "value", DATATYPE_INTEGER, true, 1,
161: Integer.MAX_VALUE); // list
162:
163: // DIMENSION
164: addElement("Dimension", standardMetadataFormatName,
165: CHILD_POLICY_SOME);
166:
167: addElement("PixelAspectRatio", "Dimension", CHILD_POLICY_EMPTY);
168: addAttribute("PixelAspectRatio", "value", DATATYPE_FLOAT, true,
169: null);
170:
171: addElement("ImageOrientation", "Dimension", CHILD_POLICY_EMPTY);
172: values = new ArrayList<String>(8);
173: values.add("Normal");
174: values.add("Rotate90");
175: values.add("Rotate180");
176: values.add("Rotate270");
177: values.add("FlipH");
178: values.add("FlipV");
179: values.add("FlipHRotate90");
180: values.add("FlipVRotate90");
181: addAttribute("ImageOrientation", "value", DATATYPE_STRING,
182: true, null, values);
183:
184: addElement("HorizontalPixelSize", "Dimension",
185: CHILD_POLICY_EMPTY);
186: addAttribute("HorizontalPixelSize", "value", DATATYPE_FLOAT,
187: true, null);
188:
189: addElement("VerticalPixelSize", "Dimension", CHILD_POLICY_EMPTY);
190: addAttribute("VerticalPixelSize", "value", DATATYPE_FLOAT,
191: true, null);
192:
193: addElement("HorizontalPhysicalPixelSpacing", "Dimension",
194: CHILD_POLICY_EMPTY);
195: addAttribute("HorizontalPhysicalPixelSpacing", "value",
196: DATATYPE_FLOAT, true, null);
197:
198: addElement("VerticalPhysicalPixelSpacing", "Dimension",
199: CHILD_POLICY_EMPTY);
200: addAttribute("VerticalPhysicalPixelSpacing", "value",
201: DATATYPE_FLOAT, true, null);
202:
203: addElement("HorizontalPosition", "Dimension",
204: CHILD_POLICY_EMPTY);
205: addAttribute("HorizontalPosition", "value", DATATYPE_FLOAT,
206: true, null);
207:
208: addElement("VerticalPosition", "Dimension", CHILD_POLICY_EMPTY);
209: addAttribute("VerticalPosition", "value", DATATYPE_FLOAT, true,
210: null);
211:
212: addElement("HorizontalPixelOffset", "Dimension",
213: CHILD_POLICY_EMPTY);
214: addAttribute("HorizontalPixelOffset", "value",
215: DATATYPE_INTEGER, true, null);
216:
217: addElement("VerticalPixelOffset", "Dimension",
218: CHILD_POLICY_EMPTY);
219: addAttribute("VerticalPixelOffset", "value", DATATYPE_INTEGER,
220: true, null);
221:
222: addElement("HorizontalScreenSize", "Dimension",
223: CHILD_POLICY_EMPTY);
224: addAttribute("HorizontalScreenSize", "value", DATATYPE_INTEGER,
225: true, null);
226:
227: addElement("VerticalScreenSize", "Dimension",
228: CHILD_POLICY_EMPTY);
229: addAttribute("VerticalScreenSize", "value", DATATYPE_INTEGER,
230: true, null);
231:
232: // DOCUMENT
233: addElement("Document", standardMetadataFormatName,
234: CHILD_POLICY_SOME);
235:
236: addElement("FormatVersion", "Document", CHILD_POLICY_EMPTY);
237: addAttribute("FormatVersion", "value", DATATYPE_STRING, true,
238: null);
239:
240: addElement("SubimageInterpretation", "Document",
241: CHILD_POLICY_EMPTY);
242: values = new ArrayList<String>(14);
243: values.add("Standalone");
244: values.add("SinglePage");
245: values.add("FullResolution");
246: values.add("ReducedResolution");
247: values.add("PyramidLayer");
248: values.add("Preview");
249: values.add("VolumeSlice");
250: values.add("ObjectView");
251: values.add("Panorama");
252: values.add("AnimationFrame");
253: values.add("TransparencyMask");
254: values.add("CompositingLayer");
255: values.add("SpectralSlice");
256: values.add("Unknown");
257: addAttribute("SubimageInterpretation", "value",
258: DATATYPE_STRING, true, null, values);
259:
260: addElement("ImageCreationTime", "Document", CHILD_POLICY_EMPTY);
261: addAttribute("ImageCreationTime", "year", DATATYPE_INTEGER,
262: true, null);
263: addAttribute("ImageCreationTime", "month", DATATYPE_INTEGER,
264: true, null, "1", "12", true, true);
265: addAttribute("ImageCreationTime", "day", DATATYPE_INTEGER,
266: true, null, "1", "31", true, true);
267: addAttribute("ImageCreationTime", "hour", DATATYPE_INTEGER,
268: false, "0", "0", "23", true, true);
269: addAttribute("ImageCreationTime", "minute", DATATYPE_INTEGER,
270: false, "0", "0", "59", true, true);
271: addAttribute("ImageCreationTime", "second", DATATYPE_INTEGER,
272: false, "0", "0", "60", true, true);
273:
274: addElement("ImageModificationTime", "Document",
275: CHILD_POLICY_EMPTY);
276: addAttribute("ImageModificationTime", "year", DATATYPE_INTEGER,
277: true, null);
278: addAttribute("ImageModificationTime", "month",
279: DATATYPE_INTEGER, true, null, "1", "12", true, true);
280: addAttribute("ImageModificationTime", "day", DATATYPE_INTEGER,
281: true, null, "1", "31", true, true);
282: addAttribute("ImageModificationTime", "hour", DATATYPE_INTEGER,
283: false, "0", "0", "23", true, true);
284: addAttribute("ImageModificationTime", "minute",
285: DATATYPE_INTEGER, false, "0", "0", "59", true, true);
286: addAttribute("ImageModificationTime", "second",
287: DATATYPE_INTEGER, false, "0", "0", "60", true, true);
288:
289: // TEXT
290: addElement("Text", standardMetadataFormatName, 0,
291: Integer.MAX_VALUE); // CHILD_POLICY_REPEAT
292:
293: addElement("TextEntry", "Text", CHILD_POLICY_EMPTY);
294: addAttribute("TextEntry", "keyword", DATATYPE_STRING, false,
295: null);
296: addAttribute("TextEntry", "value", DATATYPE_STRING, true, null);
297: addAttribute("TextEntry", "language", DATATYPE_STRING, false,
298: null);
299: addAttribute("TextEntry", "encoding", DATATYPE_STRING, false,
300: null);
301: values = new ArrayList<String>(5);
302: values.add("none");
303: values.add("lzw");
304: values.add("zip");
305: values.add("bzip");
306: values.add("other");
307: addAttribute("TextEntry", "compression", DATATYPE_STRING,
308: false, "none", values);
309:
310: // TRANSPARENCY
311: addElement("Transparency", standardMetadataFormatName,
312: CHILD_POLICY_SOME);
313:
314: addElement("Alpha", "Transparency", CHILD_POLICY_EMPTY);
315: values = new ArrayList<String>(3);
316: values.add("none");
317: values.add("premultiplied");
318: values.add("nonpremultiplied");
319: addAttribute("Alpha", "value", DATATYPE_STRING, false, "none",
320: values);
321:
322: addElement("TransparentIndex", "Transparency",
323: CHILD_POLICY_EMPTY);
324: addAttribute("TransparentIndex", "value", DATATYPE_INTEGER,
325: true, null);
326:
327: addElement("TransparentColor", "Transparency",
328: CHILD_POLICY_EMPTY);
329: addAttribute("TransparentColor", "value", DATATYPE_INTEGER,
330: true, 0, Integer.MAX_VALUE);
331:
332: addElement("TileTransparencies", "Transparency", 0,
333: Integer.MAX_VALUE); // CHILD_POLICY_REPEAT
334:
335: addElement("TransparentTile", "TileTransparencies",
336: CHILD_POLICY_EMPTY);
337: addAttribute("TransparentTile", "x", DATATYPE_INTEGER, true,
338: null);
339: addAttribute("TransparentTile", "y", DATATYPE_INTEGER, true,
340: null);
341:
342: addElement("TileOpacities", "Transparency", 0,
343: Integer.MAX_VALUE); // CHILD_POLICY_REPEAT
344:
345: addElement("OpaqueTile", "TileOpacities", CHILD_POLICY_EMPTY);
346: addAttribute("OpaqueTile", "x", DATATYPE_INTEGER, true, null);
347: addAttribute("OpaqueTile", "y", DATATYPE_INTEGER, true, null);
348: }
349: }
|