History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java+171−0
@@ -0,0 +1,171 @@
1+/*
2+ * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.imageio.plugins.gif;
27+
28+import java.util.Arrays;
29+import javax.imageio.ImageTypeSpecifier;
30+import javax.imageio.metadata.IIOMetadataFormat;
31+import javax.imageio.metadata.IIOMetadataFormatImpl;
32+
33+public class GIFImageMetadataFormat extends IIOMetadataFormatImpl {
34+
35+ private static IIOMetadataFormat instance = null;
36+
37+ private GIFImageMetadataFormat() {
38+ super(GIFImageMetadata.nativeMetadataFormatName,
39+ CHILD_POLICY_SOME);
40+
41+ // root -> ImageDescriptor
42+ addElement("ImageDescriptor",
43+ GIFImageMetadata.nativeMetadataFormatName,
44+ CHILD_POLICY_EMPTY);
45+ addAttribute("ImageDescriptor", "imageLeftPosition",
46+ DATATYPE_INTEGER, true, null,
47+ "0", "65535", true, true);
48+ addAttribute("ImageDescriptor", "imageTopPosition",
49+ DATATYPE_INTEGER, true, null,
50+ "0", "65535", true, true);
51+ addAttribute("ImageDescriptor", "imageWidth",
52+ DATATYPE_INTEGER, true, null,
53+ "1", "65535", true, true);
54+ addAttribute("ImageDescriptor", "imageHeight",
55+ DATATYPE_INTEGER, true, null,
56+ "1", "65535", true, true);
57+ addBooleanAttribute("ImageDescriptor", "interlaceFlag",
58+ false, false);
59+
60+ // root -> LocalColorTable
61+ addElement("LocalColorTable",
62+ GIFImageMetadata.nativeMetadataFormatName,
63+ 2, 256);
64+ addAttribute("LocalColorTable", "sizeOfLocalColorTable",
65+ DATATYPE_INTEGER, true, null,
66+ Arrays.asList(GIFStreamMetadata.colorTableSizes));
67+ addBooleanAttribute("LocalColorTable", "sortFlag",
68+ false, false);
69+
70+ // root -> LocalColorTable -> ColorTableEntry
71+ addElement("ColorTableEntry", "LocalColorTable",
72+ CHILD_POLICY_EMPTY);
73+ addAttribute("ColorTableEntry", "index",
74+ DATATYPE_INTEGER, true, null,
75+ "0", "255", true, true);
76+ addAttribute("ColorTableEntry", "red",
77+ DATATYPE_INTEGER, true, null,
78+ "0", "255", true, true);
79+ addAttribute("ColorTableEntry", "green",
80+ DATATYPE_INTEGER, true, null,
81+ "0", "255", true, true);
82+ addAttribute("ColorTableEntry", "blue",
83+ DATATYPE_INTEGER, true, null,
84+ "0", "255", true, true);
85+
86+ // root -> GraphicControlExtension
87+ addElement("GraphicControlExtension",
88+ GIFImageMetadata.nativeMetadataFormatName,
89+ CHILD_POLICY_EMPTY);
90+ addAttribute("GraphicControlExtension", "disposalMethod",
91+ DATATYPE_STRING, true, null,
92+ Arrays.asList(GIFImageMetadata.disposalMethodNames));
93+ addBooleanAttribute("GraphicControlExtension", "userInputFlag",
94+ false, false);
95+ addBooleanAttribute("GraphicControlExtension", "transparentColorFlag",
96+ false, false);
97+ addAttribute("GraphicControlExtension", "delayTime",
98+ DATATYPE_INTEGER, true, null,
99+ "0", "65535", true, true);
100+ addAttribute("GraphicControlExtension", "transparentColorIndex",
101+ DATATYPE_INTEGER, true, null,
102+ "0", "255", true, true);
103+
104+ // root -> PlainTextExtension
105+ addElement("PlainTextExtension",
106+ GIFImageMetadata.nativeMetadataFormatName,
107+ CHILD_POLICY_EMPTY);
108+ addAttribute("PlainTextExtension", "textGridLeft",
109+ DATATYPE_INTEGER, true, null,
110+ "0", "65535", true, true);
111+ addAttribute("PlainTextExtension", "textGridTop",
112+ DATATYPE_INTEGER, true, null,
113+ "0", "65535", true, true);
114+ addAttribute("PlainTextExtension", "textGridWidth",
115+ DATATYPE_INTEGER, true, null,
116+ "1", "65535", true, true);
117+ addAttribute("PlainTextExtension", "textGridHeight",
118+ DATATYPE_INTEGER, true, null,
119+ "1", "65535", true, true);
120+ addAttribute("PlainTextExtension", "characterCellWidth",
121+ DATATYPE_INTEGER, true, null,
122+ "1", "65535", true, true);
123+ addAttribute("PlainTextExtension", "characterCellHeight",
124+ DATATYPE_INTEGER, true, null,
125+ "1", "65535", true, true);
126+ addAttribute("PlainTextExtension", "textForegroundColor",
127+ DATATYPE_INTEGER, true, null,
128+ "0", "255", true, true);
129+ addAttribute("PlainTextExtension", "textBackgroundColor",
130+ DATATYPE_INTEGER, true, null,
131+ "0", "255", true, true);
132+
133+ // root -> ApplicationExtensions
134+ addElement("ApplicationExtensions",
135+ GIFImageMetadata.nativeMetadataFormatName,
136+ 1, Integer.MAX_VALUE);
137+
138+ // root -> ApplicationExtensions -> ApplicationExtension
139+ addElement("ApplicationExtension", "ApplicationExtensions",
140+ CHILD_POLICY_EMPTY);
141+ addAttribute("ApplicationExtension", "applicationID",
142+ DATATYPE_STRING, true, null);
143+ addAttribute("ApplicationExtension", "authenticationCode",
144+ DATATYPE_STRING, true, null);
145+ addObjectValue("ApplicationExtension", byte.class,
146+ 0, Integer.MAX_VALUE);
147+
148+ // root -> CommentExtensions
149+ addElement("CommentExtensions",
150+ GIFImageMetadata.nativeMetadataFormatName,
151+ 1, Integer.MAX_VALUE);
152+
153+ // root -> CommentExtensions -> CommentExtension
154+ addElement("CommentExtension", "CommentExtensions",
155+ CHILD_POLICY_EMPTY);
156+ addAttribute("CommentExtension", "value",
157+ DATATYPE_STRING, true, null);
158+ }
159+
160+ public boolean canNodeAppear(String elementName,
161+ ImageTypeSpecifier imageType) {
162+ return true;
163+ }
164+
165+ public static synchronized IIOMetadataFormat getInstance() {
166+ if (instance == null) {
167+ instance = new GIFImageMetadataFormat();
168+ }
169+ return instance;
170+ }
171+}