KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > imageio > plugins > gif > GIFStreamMetadataFormat


1 /*
2  * @(#)GIFStreamMetadataFormat.java 1.7 04/03/23
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.gif;
9
10 import java.util.Arrays JavaDoc;
11 import javax.imageio.ImageTypeSpecifier JavaDoc;
12 import javax.imageio.metadata.IIOMetadataFormat JavaDoc;
13 import javax.imageio.metadata.IIOMetadataFormatImpl JavaDoc;
14
15 public class GIFStreamMetadataFormat extends IIOMetadataFormatImpl JavaDoc {
16
17     private static IIOMetadataFormat JavaDoc instance = null;
18
19     private GIFStreamMetadataFormat() {
20         super(GIFStreamMetadata.nativeMetadataFormatName,
21               CHILD_POLICY_SOME);
22
23         // root -> Version
24
addElement("Version", GIFStreamMetadata.nativeMetadataFormatName,
25                    CHILD_POLICY_EMPTY);
26         addAttribute("Version", "value",
27                      DATATYPE_STRING, true, null,
28                      Arrays.asList(GIFStreamMetadata.versionStrings));
29
30         // root -> LogicalScreenDescriptor
31
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         // root -> GlobalColorTable
48
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         // root -> GlobalColorTable -> ColorTableEntry
61
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 JavaDoc elementName,
78                                  ImageTypeSpecifier JavaDoc imageType) {
79         return true;
80     }
81
82     public static synchronized IIOMetadataFormat JavaDoc getInstance() {
83         if (instance == null) {
84             instance = new GIFStreamMetadataFormat();
85         }
86         return instance;
87     }
88 }
89
Popular Tags