1 7 8 package com.sun.imageio.plugins.gif; 9 10 import java.util.Arrays ; 11 import javax.imageio.ImageTypeSpecifier ; 12 import javax.imageio.metadata.IIOMetadataFormat ; 13 import javax.imageio.metadata.IIOMetadataFormatImpl ; 14 15 public class GIFStreamMetadataFormat extends IIOMetadataFormatImpl { 16 17 private static IIOMetadataFormat instance = null; 18 19 private GIFStreamMetadataFormat() { 20 super(GIFStreamMetadata.nativeMetadataFormatName, 21 CHILD_POLICY_SOME); 22 23 addElement("Version", GIFStreamMetadata.nativeMetadataFormatName, 25 CHILD_POLICY_EMPTY); 26 addAttribute("Version", "value", 27 DATATYPE_STRING, true, null, 28 Arrays.asList(GIFStreamMetadata.versionStrings)); 29 30 addElement("LogicalScreenDescriptor", 32 GIFStreamMetadata.nativeMetadataFormatName, 33 CHILD_POLICY_EMPTY); 34 addAttribute("LogicalScreenDescriptor", "logicalScreenWidth", 35 DATATYPE_INTEGER, true, null, 36 "1", "65535", true, true); 37 addAttribute("LogicalScreenDescriptor", "logicalScreenHeight", 38 DATATYPE_INTEGER, true, null, 39 "1", "65535", true, true); 40 addAttribute("LogicalScreenDescriptor", "colorResolution", 41 DATATYPE_INTEGER, true, null, 42 "1", "8", true, true); 43 addAttribute("LogicalScreenDescriptor", "pixelAspectRatio", 44 DATATYPE_INTEGER, true, null, 45 "0", "255", true, true); 46 47 addElement("GlobalColorTable", 49 GIFStreamMetadata.nativeMetadataFormatName, 50 2, 256); 51 addAttribute("GlobalColorTable", "sizeOfGlobalColorTable", 52 DATATYPE_INTEGER, true, null, 53 Arrays.asList(GIFStreamMetadata.colorTableSizes)); 54 addAttribute("GlobalColorTable", "backgroundColorIndex", 55 DATATYPE_INTEGER, true, null, 56 "0", "255", true, true); 57 addBooleanAttribute("GlobalColorTable", "sortFlag", 58 false, false); 59 60 addElement("ColorTableEntry", "GlobalColorTable", 62 CHILD_POLICY_EMPTY); 63 addAttribute("ColorTableEntry", "index", 64 DATATYPE_INTEGER, true, null, 65 "0", "255", true, true); 66 addAttribute("ColorTableEntry", "red", 67 DATATYPE_INTEGER, true, null, 68 "0", "255", true, true); 69 addAttribute("ColorTableEntry", "green", 70 DATATYPE_INTEGER, true, null, 71 "0", "255", true, true); 72 addAttribute("ColorTableEntry", "blue", 73 DATATYPE_INTEGER, true, null, 74 "0", "255", true, true); 75 } 76 77 public boolean canNodeAppear(String elementName, 78 ImageTypeSpecifier imageType) { 79 return true; 80 } 81 82 public static synchronized IIOMetadataFormat getInstance() { 83 if (instance == null) { 84 instance = new GIFStreamMetadataFormat(); 85 } 86 return instance; 87 } 88 } 89 | Popular Tags |