1 7 8 package com.sun.imageio.plugins.common; 9 10 import java.util.ArrayList ; 11 import java.util.List ; 12 import javax.imageio.ImageTypeSpecifier ; 13 import javax.imageio.metadata.IIOMetadataFormatImpl ; 14 15 public class StandardMetadataFormat extends IIOMetadataFormatImpl { 16 17 private void addSingleAttributeElement(String elementName, 19 String 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 values; 28 29 addElement("Chroma", standardMetadataFormatName, 31 CHILD_POLICY_SOME); 32 33 addElement("ColorSpaceType", "Chroma", 35 CHILD_POLICY_EMPTY); 36 37 values = new ArrayList (); 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 addElement("NumChannels", "Chroma", 74 CHILD_POLICY_EMPTY); 75 addAttribute("NumChannels", "value", 76 DATATYPE_INTEGER, 77 true, 78 0, Integer.MAX_VALUE); 79 80 addElement("Gamma", "Chroma", CHILD_POLICY_EMPTY); 82 addAttribute("Gamma", "value", 83 DATATYPE_FLOAT, true, null); 84 85 addElement("BlackIsZero", "Chroma", CHILD_POLICY_EMPTY); 87 addBooleanAttribute("BlackIsZero", "value", true, true); 88 89 addElement("Palette", "Chroma", 0, Integer.MAX_VALUE); 91 92 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 addElement("BackgroundIndex", "Chroma", CHILD_POLICY_EMPTY); 107 addAttribute("BackgroundIndex", "value", DATATYPE_INTEGER, 108 true, null); 109 110 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 addElement("Compression", standardMetadataFormatName, 121 CHILD_POLICY_SOME); 122 123 addSingleAttributeElement("CompressionTypeName", 125 "Compression", 126 DATATYPE_STRING); 127 128 addElement("Lossless", "Compression", CHILD_POLICY_EMPTY); 130 addBooleanAttribute("Lossless", "value", true, true); 131 132 addSingleAttributeElement("NumProgressiveScans", 134 "Compression", 135 DATATYPE_INTEGER); 136 137 addSingleAttributeElement("BitRate", 139 "Compression", 140 DATATYPE_FLOAT); 141 142 addElement("Data", standardMetadataFormatName, 144 CHILD_POLICY_SOME); 145 146 addElement("PlanarConfiguration", "Data", CHILD_POLICY_EMPTY); 148 149 values = new ArrayList (); 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 addElement("SampleFormat", "Data", CHILD_POLICY_EMPTY); 162 163 values = new ArrayList (); 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 addElement("BitsPerSample", "Data", 176 CHILD_POLICY_EMPTY); 177 addAttribute("BitsPerSample", "value", 178 DATATYPE_INTEGER, 179 true, 180 1, Integer.MAX_VALUE); 181 182 addElement("SignificantBitsPerSample", "Data", CHILD_POLICY_EMPTY); 184 addAttribute("SignificantBitsPerSample", "value", 185 DATATYPE_INTEGER, 186 true, 187 1, Integer.MAX_VALUE); 188 189 addElement("SampleMSB", "Data", 191 CHILD_POLICY_EMPTY); 192 addAttribute("SampleMSB", "value", 193 DATATYPE_INTEGER, 194 true, 195 1, Integer.MAX_VALUE); 196 197 addElement("Dimension", standardMetadataFormatName, 199 CHILD_POLICY_SOME); 200 201 addSingleAttributeElement("PixelAspectRatio", 203 "Dimension", 204 DATATYPE_FLOAT); 205 206 addElement("ImageOrientation", "Dimension", 208 CHILD_POLICY_EMPTY); 209 210 values = new ArrayList (); 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 addSingleAttributeElement("HorizontalPixelSize", 227 "Dimension", 228 DATATYPE_FLOAT); 229 230 addSingleAttributeElement("VerticalPixelSize", 232 "Dimension", 233 DATATYPE_FLOAT); 234 235 addSingleAttributeElement("HorizontalPhysicalPixelSpacing", 237 "Dimension", 238 DATATYPE_FLOAT); 239 240 addSingleAttributeElement("VerticalPhysicalPixelSpacing", 242 "Dimension", 243 DATATYPE_FLOAT); 244 245 addSingleAttributeElement("HorizontalPosition", 247 "Dimension", 248 DATATYPE_FLOAT); 249 250 addSingleAttributeElement("VerticalPosition", 252 "Dimension", 253 DATATYPE_FLOAT); 254 255 addSingleAttributeElement("HorizontalPixelOffset", 257 "Dimension", 258 DATATYPE_INTEGER); 259 260 addSingleAttributeElement("VerticalPixelOffset", 262 "Dimension", 263 DATATYPE_INTEGER); 264 265 addSingleAttributeElement("HorizontalScreenSize", 267 "Dimension", 268 DATATYPE_INTEGER); 269 270 addSingleAttributeElement("VerticalScreenSize", 272 "Dimension", 273 DATATYPE_INTEGER); 274 275 276 addElement("Document", standardMetadataFormatName, 278 CHILD_POLICY_SOME); 279 280 addElement("FormatVersion", "Document", 282 CHILD_POLICY_EMPTY); 283 addAttribute("FormatVersion", "value", 284 DATATYPE_STRING, 285 true, 286 null); 287 288 addElement("SubimageInterpretation", "Document", 290 CHILD_POLICY_EMPTY); 291 values = new ArrayList (); 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 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 addAttribute("ImageCreationTime", "second", 341 DATATYPE_INTEGER, 342 false, 343 "0", 344 "0", "60", true, true); 345 346 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 addAttribute("ImageModificationTime", "second", 375 DATATYPE_INTEGER, 376 false, 377 "0", 378 "0", "60", true, true); 379 380 addElement("Text", standardMetadataFormatName, 382 0, Integer.MAX_VALUE); 383 384 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 (); 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 addElement("Transparency", standardMetadataFormatName, 417 CHILD_POLICY_SOME); 418 419 addElement("Alpha", "Transparency", CHILD_POLICY_EMPTY); 421 422 values = new ArrayList (); 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 addSingleAttributeElement("TransparentIndex", "Transparency", 434 DATATYPE_INTEGER); 435 436 addElement("TransparentColor", "Transparency", 438 CHILD_POLICY_EMPTY); 439 addAttribute("TransparentColor", "value", 440 DATATYPE_INTEGER, 441 true, 442 0, Integer.MAX_VALUE); 443 444 addElement("TileTransparencies", "Transparency", 446 0, Integer.MAX_VALUE); 447 448 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 addElement("TileOpacities", "Transparency", 462 0, Integer.MAX_VALUE); 463 464 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 elementName, 478 ImageTypeSpecifier imageType) { 479 return true; 480 } 481 } 482 | Popular Tags |