src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java

Print this page
rev 9343 : 8033716: Fix raw and unchecked lint warnings in com.sun.imageio
Reviewed-by: darcy, prr, bae


  67     public int disposalMethod = 0;
  68     public boolean userInputFlag = false;
  69     public boolean transparentColorFlag = false;
  70     public int delayTime = 0;
  71     public int transparentColorIndex = 0;
  72 
  73     // Fields from Plain Text Extension
  74     public boolean hasPlainTextExtension = false;
  75     public int textGridLeft;
  76     public int textGridTop;
  77     public int textGridWidth;
  78     public int textGridHeight;
  79     public int characterCellWidth;
  80     public int characterCellHeight;
  81     public int textForegroundColor;
  82     public int textBackgroundColor;
  83     public byte[] text;
  84 
  85     // Fields from ApplicationExtension
  86     // List of byte[]
  87     public List applicationIDs = null; // new ArrayList();
  88 
  89     // List of byte[]
  90     public List authenticationCodes = null; // new ArrayList();
  91 
  92     // List of byte[]
  93     public List applicationData = null; // new ArrayList();
  94 
  95     // Fields from CommentExtension
  96     // List of byte[]
  97     public List comments = null; // new ArrayList();
  98 
  99     protected GIFImageMetadata(boolean standardMetadataFormatSupported,
 100                                String nativeMetadataFormatName,
 101                                String nativeMetadataFormatClassName,
 102                                String[] extraMetadataFormatNames,
 103                                String[] extraMetadataFormatClassNames)
 104     {
 105         super(standardMetadataFormatSupported,
 106               nativeMetadataFormatName,
 107               nativeMetadataFormatClassName,
 108               extraMetadataFormatNames,
 109               extraMetadataFormatClassNames);
 110     }
 111 
 112     public GIFImageMetadata() {
 113         this(true,
 114               nativeMetadataFormatName,
 115               "com.sun.imageio.plugins.gif.GIFImageMetadataFormat",
 116               null, null);
 117     }


 208                               Integer.toString(characterCellWidth));
 209             node.setAttribute("characterCellHeight",
 210                               Integer.toString(characterCellHeight));
 211             node.setAttribute("textForegroundColor",
 212                               Integer.toString(textForegroundColor));
 213             node.setAttribute("textBackgroundColor",
 214                               Integer.toString(textBackgroundColor));
 215             node.setAttribute("text", toISO8859(text));
 216 
 217             root.appendChild(node);
 218         }
 219 
 220         // Application extensions
 221         int numAppExtensions = applicationIDs == null ?
 222             0 : applicationIDs.size();
 223         if (numAppExtensions > 0) {
 224             node = new IIOMetadataNode("ApplicationExtensions");
 225             for (int i = 0; i < numAppExtensions; i++) {
 226                 IIOMetadataNode appExtNode =
 227                     new IIOMetadataNode("ApplicationExtension");
 228                 byte[] applicationID = (byte[])applicationIDs.get(i);
 229                 appExtNode.setAttribute("applicationID",
 230                                         toISO8859(applicationID));
 231                 byte[] authenticationCode = (byte[])authenticationCodes.get(i);
 232                 appExtNode.setAttribute("authenticationCode",
 233                                         toISO8859(authenticationCode));
 234                 byte[] appData = (byte[])applicationData.get(i);
 235                 appExtNode.setUserObject(appData.clone());
 236                 node.appendChild(appExtNode);
 237             }
 238 
 239             root.appendChild(node);
 240         }
 241 
 242         // Comment extensions
 243         int numComments = comments == null ? 0 : comments.size();
 244         if (numComments > 0) {
 245             node = new IIOMetadataNode("CommentExtensions");
 246             for (int i = 0; i < numComments; i++) {
 247                 IIOMetadataNode commentNode =
 248                     new IIOMetadataNode("CommentExtension");
 249                 byte[] comment = (byte[])comments.get(i);
 250                 commentNode.setAttribute("value", toISO8859(comment));
 251                 node.appendChild(commentNode);
 252             }
 253 
 254             root.appendChild(node);
 255         }
 256 
 257         return root;
 258     }
 259 
 260     public IIOMetadataNode getStandardChromaNode() {
 261         IIOMetadataNode chroma_node = new IIOMetadataNode("Chroma");
 262         IIOMetadataNode node = null; // scratch node
 263 
 264         node = new IIOMetadataNode("ColorSpaceType");
 265         node.setAttribute("name", "RGB");
 266         chroma_node.appendChild(node);
 267 
 268         node = new IIOMetadataNode("NumChannels");
 269         node.setAttribute("value", transparentColorFlag ? "4" : "3");


 357         node = new IIOMetadataNode("HorizontalPixelOffset");
 358         node.setAttribute("value", Integer.toString(imageLeftPosition));
 359         dimension_node.appendChild(node);
 360 
 361         node = new IIOMetadataNode("VerticalPixelOffset");
 362         node.setAttribute("value", Integer.toString(imageTopPosition));
 363         dimension_node.appendChild(node);
 364 
 365         // HorizontalScreenSize not in image
 366         // VerticalScreenSize not in image
 367 
 368         return dimension_node;
 369     }
 370 
 371     // Document not in image
 372 
 373     public IIOMetadataNode getStandardTextNode() {
 374         if (comments == null) {
 375             return null;
 376         }
 377         Iterator commentIter = comments.iterator();
 378         if (!commentIter.hasNext()) {
 379             return null;
 380         }
 381 
 382         IIOMetadataNode text_node = new IIOMetadataNode("Text");
 383         IIOMetadataNode node = null; // scratch node
 384 
 385         while (commentIter.hasNext()) {
 386             byte[] comment = (byte[])commentIter.next();
 387             String s = null;
 388             try {
 389                 s = new String(comment, "ISO-8859-1");
 390             } catch (UnsupportedEncodingException e) {
 391                 throw new RuntimeException("Encoding ISO-8859-1 unknown!");
 392             }
 393 
 394             node = new IIOMetadataNode("TextEntry");
 395             node.setAttribute("value", s);
 396             node.setAttribute("encoding", "ISO-8859-1");
 397             node.setAttribute("compression", "none");
 398             text_node.appendChild(node);
 399         }
 400 
 401         return text_node;
 402     }
 403 
 404     public IIOMetadataNode getStandardTransparencyNode() {
 405         if (!transparentColorFlag) {
 406             return null;




  67     public int disposalMethod = 0;
  68     public boolean userInputFlag = false;
  69     public boolean transparentColorFlag = false;
  70     public int delayTime = 0;
  71     public int transparentColorIndex = 0;
  72 
  73     // Fields from Plain Text Extension
  74     public boolean hasPlainTextExtension = false;
  75     public int textGridLeft;
  76     public int textGridTop;
  77     public int textGridWidth;
  78     public int textGridHeight;
  79     public int characterCellWidth;
  80     public int characterCellHeight;
  81     public int textForegroundColor;
  82     public int textBackgroundColor;
  83     public byte[] text;
  84 
  85     // Fields from ApplicationExtension
  86     // List of byte[]
  87     public List<byte[]> applicationIDs = null;
  88 
  89     // List of byte[]
  90     public List<byte[]> authenticationCodes = null;
  91 
  92     // List of byte[]
  93     public List<byte[]> applicationData = null;
  94 
  95     // Fields from CommentExtension
  96     // List of byte[]
  97     public List<byte[]> comments = null;
  98 
  99     protected GIFImageMetadata(boolean standardMetadataFormatSupported,
 100                                String nativeMetadataFormatName,
 101                                String nativeMetadataFormatClassName,
 102                                String[] extraMetadataFormatNames,
 103                                String[] extraMetadataFormatClassNames)
 104     {
 105         super(standardMetadataFormatSupported,
 106               nativeMetadataFormatName,
 107               nativeMetadataFormatClassName,
 108               extraMetadataFormatNames,
 109               extraMetadataFormatClassNames);
 110     }
 111 
 112     public GIFImageMetadata() {
 113         this(true,
 114               nativeMetadataFormatName,
 115               "com.sun.imageio.plugins.gif.GIFImageMetadataFormat",
 116               null, null);
 117     }


 208                               Integer.toString(characterCellWidth));
 209             node.setAttribute("characterCellHeight",
 210                               Integer.toString(characterCellHeight));
 211             node.setAttribute("textForegroundColor",
 212                               Integer.toString(textForegroundColor));
 213             node.setAttribute("textBackgroundColor",
 214                               Integer.toString(textBackgroundColor));
 215             node.setAttribute("text", toISO8859(text));
 216 
 217             root.appendChild(node);
 218         }
 219 
 220         // Application extensions
 221         int numAppExtensions = applicationIDs == null ?
 222             0 : applicationIDs.size();
 223         if (numAppExtensions > 0) {
 224             node = new IIOMetadataNode("ApplicationExtensions");
 225             for (int i = 0; i < numAppExtensions; i++) {
 226                 IIOMetadataNode appExtNode =
 227                     new IIOMetadataNode("ApplicationExtension");
 228                 byte[] applicationID = applicationIDs.get(i);
 229                 appExtNode.setAttribute("applicationID",
 230                                         toISO8859(applicationID));
 231                 byte[] authenticationCode = authenticationCodes.get(i);
 232                 appExtNode.setAttribute("authenticationCode",
 233                                         toISO8859(authenticationCode));
 234                 byte[] appData = applicationData.get(i);
 235                 appExtNode.setUserObject(appData.clone());
 236                 node.appendChild(appExtNode);
 237             }
 238 
 239             root.appendChild(node);
 240         }
 241 
 242         // Comment extensions
 243         int numComments = comments == null ? 0 : comments.size();
 244         if (numComments > 0) {
 245             node = new IIOMetadataNode("CommentExtensions");
 246             for (int i = 0; i < numComments; i++) {
 247                 IIOMetadataNode commentNode =
 248                     new IIOMetadataNode("CommentExtension");
 249                 byte[] comment = comments.get(i);
 250                 commentNode.setAttribute("value", toISO8859(comment));
 251                 node.appendChild(commentNode);
 252             }
 253 
 254             root.appendChild(node);
 255         }
 256 
 257         return root;
 258     }
 259 
 260     public IIOMetadataNode getStandardChromaNode() {
 261         IIOMetadataNode chroma_node = new IIOMetadataNode("Chroma");
 262         IIOMetadataNode node = null; // scratch node
 263 
 264         node = new IIOMetadataNode("ColorSpaceType");
 265         node.setAttribute("name", "RGB");
 266         chroma_node.appendChild(node);
 267 
 268         node = new IIOMetadataNode("NumChannels");
 269         node.setAttribute("value", transparentColorFlag ? "4" : "3");


 357         node = new IIOMetadataNode("HorizontalPixelOffset");
 358         node.setAttribute("value", Integer.toString(imageLeftPosition));
 359         dimension_node.appendChild(node);
 360 
 361         node = new IIOMetadataNode("VerticalPixelOffset");
 362         node.setAttribute("value", Integer.toString(imageTopPosition));
 363         dimension_node.appendChild(node);
 364 
 365         // HorizontalScreenSize not in image
 366         // VerticalScreenSize not in image
 367 
 368         return dimension_node;
 369     }
 370 
 371     // Document not in image
 372 
 373     public IIOMetadataNode getStandardTextNode() {
 374         if (comments == null) {
 375             return null;
 376         }
 377         Iterator<byte[]> commentIter = comments.iterator();
 378         if (!commentIter.hasNext()) {
 379             return null;
 380         }
 381 
 382         IIOMetadataNode text_node = new IIOMetadataNode("Text");
 383         IIOMetadataNode node = null; // scratch node
 384 
 385         while (commentIter.hasNext()) {
 386             byte[] comment = commentIter.next();
 387             String s = null;
 388             try {
 389                 s = new String(comment, "ISO-8859-1");
 390             } catch (UnsupportedEncodingException e) {
 391                 throw new RuntimeException("Encoding ISO-8859-1 unknown!");
 392             }
 393 
 394             node = new IIOMetadataNode("TextEntry");
 395             node.setAttribute("value", s);
 396             node.setAttribute("encoding", "ISO-8859-1");
 397             node.setAttribute("compression", "none");
 398             text_node.appendChild(node);
 399         }
 400 
 401         return text_node;
 402     }
 403 
 404     public IIOMetadataNode getStandardTransparencyNode() {
 405         if (!transparentColorFlag) {
 406             return null;