return "";
}
}
private Node getNativeTree() {
IIOMetadataNode node; // scratch node
IIOMetadataNode root =
new IIOMetadataNode(nativeMetadataFormatName);
// Image descriptor
node = new IIOMetadataNode("ImageDescriptor");
node.setAttribute("imageLeftPosition",
Integer.toString(imageLeftPosition));
node.setAttribute("imageTopPosition",
Integer.toString(imageTopPosition));
node.setAttribute("imageWidth", Integer.toString(imageWidth));
node.setAttribute("imageHeight", Integer.toString(imageHeight));
node.setAttribute("interlaceFlag",
interlaceFlag ? "TRUE" : "FALSE");
root.appendChild(node);
// Local color table
if (localColorTable != null) {
node = new IIOMetadataNode("LocalColorTable");
int numEntries = localColorTable.length/3;
node.setAttribute("sizeOfLocalColorTable",
Integer.toString(numEntries));
node.setAttribute("sortFlag",
sortFlag ? "TRUE" : "FALSE");
for (int i = 0; i < numEntries; i++) {
IIOMetadataNode entry =
new IIOMetadataNode("ColorTableEntry");
entry.setAttribute("index", Integer.toString(i));
int r = localColorTable[3*i] & 0xff;
int g = localColorTable[3*i + 1] & 0xff;
int b = localColorTable[3*i + 2] & 0xff;
entry.setAttribute("red", Integer.toString(r));
entry.setAttribute("green", Integer.toString(g));
entry.setAttribute("blue", Integer.toString(b));
node.appendChild(entry);
}
root.appendChild(node);
}
// Graphic control extension
node = new IIOMetadataNode("GraphicControlExtension");
node.setAttribute("disposalMethod",
disposalMethodNames[disposalMethod]);
node.setAttribute("userInputFlag",
userInputFlag ? "TRUE" : "FALSE");
node.setAttribute("transparentColorFlag",
transparentColorFlag ? "TRUE" : "FALSE");
node.setAttribute("delayTime",
Integer.toString(delayTime));
node.setAttribute("transparentColorIndex",
Integer.toString(transparentColorIndex));
root.appendChild(node);
if (hasPlainTextExtension) {
node = new IIOMetadataNode("PlainTextExtension");
node.setAttribute("textGridLeft",
Integer.toString(textGridLeft));
node.setAttribute("textGridTop",
Integer.toString(textGridTop));
node.setAttribute("textGridWidth",
Integer.toString(textGridWidth));
node.setAttribute("textGridHeight",
Integer.toString(textGridHeight));
node.setAttribute("characterCellWidth",
Integer.toString(characterCellWidth));
node.setAttribute("characterCellHeight",
Integer.toString(characterCellHeight));
node.setAttribute("textForegroundColor",
Integer.toString(textForegroundColor));
node.setAttribute("textBackgroundColor",
Integer.toString(textBackgroundColor));
node.setAttribute("text", toISO8859(text));
root.appendChild(node);
}
// Application extensions
int numAppExtensions = applicationIDs == null ?
0 : applicationIDs.size();
if (numAppExtensions > 0) {
node = new IIOMetadataNode("ApplicationExtensions");
for (int i = 0; i < numAppExtensions; i++) {
IIOMetadataNode appExtNode =
new IIOMetadataNode("ApplicationExtension");
byte[] applicationID = (byte[])applicationIDs.get(i);
appExtNode.setAttribute("applicationID",
toISO8859(applicationID));
byte[] authenticationCode = (byte[])authenticationCodes.get(i);
appExtNode.setAttribute("authenticationCode",
toISO8859(authenticationCode));
byte[] appData = (byte[])applicationData.get(i);
appExtNode.setUserObject((byte[])appData.clone());
node.appendChild(appExtNode);
}
root.appendChild(node);
}
// Comment extensions
int numComments = comments == null ? 0 : comments.size();
if (numComments > 0) {
node = new IIOMetadataNode("CommentExtensions");
for (int i = 0; i < numComments; i++) {
IIOMetadataNode commentNode =
new IIOMetadataNode("CommentExtension");
byte[] comment = (byte[])comments.get(i);
commentNode.setAttribute("value", toISO8859(comment));
node.appendChild(commentNode);
}
root.appendChild(node);
}