use of it.geosolutions.imageio.plugins.tiff.TIFFDirectory in project imageio-ext by geosolutions-it.
the class TIFFFieldNode method initialize.
private synchronized void initialize() {
if (isInitialized == Boolean.TRUE)
return;
if (isIFD) {
TIFFDirectory dir = (TIFFDirectory) field.getData();
TIFFField[] fields = dir.getTIFFFields();
if (fields != null) {
TIFFTagSet[] tagSets = dir.getTagSets();
List tagSetList = Arrays.asList(tagSets);
int numFields = fields.length;
for (int i = 0; i < numFields; i++) {
TIFFField f = fields[i];
int tagNumber = f.getTagNumber();
TIFFTag tag = TIFFIFD.getTag(tagNumber, tagSetList);
Node node = f.getAsNativeNode();
if (node != null) {
appendChild(node);
}
}
}
} else {
IIOMetadataNode child;
int count = field.getCount();
if (field.getType() == TIFFTag.TIFF_UNDEFINED) {
child = new IIOMetadataNode("TIFFUndefined");
byte[] data = field.getAsBytes();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(Integer.toString(data[i] & 0xff));
if (i < count - 1) {
sb.append(",");
}
}
child.setAttribute("value", sb.toString());
} else {
child = new IIOMetadataNode("TIFF" + field.getTypeName(field.getType()) + "s");
TIFFTag tag = field.getTag();
String tName = tag.getName();
boolean proceed = true;
if (EXCLUDE_ATTRIBUTES && tName != null && ATTRIBUTES_EXCLUSION_SET.contains(tName)) {
proceed = false;
}
for (int i = 0; i < count && proceed; i++) {
IIOMetadataNode cchild = new IIOMetadataNode("TIFF" + field.getTypeName(field.getType()));
cchild.setAttribute("value", field.getValueAsString(i));
if (tag.hasValueNames() && field.isIntegral()) {
int value = field.getAsInt(i);
String name = tag.getValueName(value);
if (name != null) {
cchild.setAttribute("description", name);
}
}
child.appendChild(cchild);
}
}
appendChild(child);
}
isInitialized = Boolean.TRUE;
}
Aggregations