throw new IllegalArgumentException("Not a recognized format!");
}
}
private Node getNativeTree() {
IIOMetadataNode node; // scratch node
IIOMetadataNode root =
new IIOMetadataNode(nativeMetadataFormatName);
node = new IIOMetadataNode("Version");
node.setAttribute("value", version);
root.appendChild(node);
// Image descriptor
node = new IIOMetadataNode("LogicalScreenDescriptor");
/* NB: At the moment we use empty strings to support undefined
* integer values in tree representation.
* We need to add better support for undefined/default values later.
*/
node.setAttribute("logicalScreenWidth",
logicalScreenWidth == UNDEFINED_INTEGER_VALUE ?
"" : Integer.toString(logicalScreenWidth));
node.setAttribute("logicalScreenHeight",
logicalScreenHeight == UNDEFINED_INTEGER_VALUE ?
"" : Integer.toString(logicalScreenHeight));
// Stored value plus one
node.setAttribute("colorResolution",
colorResolution == UNDEFINED_INTEGER_VALUE ?
"" : Integer.toString(colorResolution));
node.setAttribute("pixelAspectRatio",
Integer.toString(pixelAspectRatio));
root.appendChild(node);
if (globalColorTable != null) {
node = new IIOMetadataNode("GlobalColorTable");
int numEntries = globalColorTable.length/3;
node.setAttribute("sizeOfGlobalColorTable",
Integer.toString(numEntries));
node.setAttribute("backgroundColorIndex",
Integer.toString(backgroundColorIndex));
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 = globalColorTable[3*i] & 0xff;
int g = globalColorTable[3*i + 1] & 0xff;
int b = globalColorTable[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);
}