use of javax.imageio.metadata.IIOInvalidTreeException in project jdk8u_jdk by JetBrains.
the class JPEGMetadata method mergeStandardTree.
private void mergeStandardTree(Node root) throws IIOInvalidTreeException {
transparencyDone = false;
NodeList children = root.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node node = children.item(i);
String name = node.getNodeName();
if (name.equals("Chroma")) {
mergeStandardChromaNode(node, children);
} else if (name.equals("Compression")) {
mergeStandardCompressionNode(node);
} else if (name.equals("Data")) {
mergeStandardDataNode(node);
} else if (name.equals("Dimension")) {
mergeStandardDimensionNode(node);
} else if (name.equals("Document")) {
mergeStandardDocumentNode(node);
} else if (name.equals("Text")) {
mergeStandardTextNode(node);
} else if (name.equals("Transparency")) {
mergeStandardTransparencyNode(node);
} else {
throw new IIOInvalidTreeException("Invalid node: " + name, node);
}
}
}
use of javax.imageio.metadata.IIOInvalidTreeException in project jdk8u_jdk by JetBrains.
the class SOFMarkerSegment method updateFromNativeNode.
void updateFromNativeNode(Node node, boolean fromScratch) throws IIOInvalidTreeException {
NamedNodeMap attrs = node.getAttributes();
int value = getAttributeValue(node, attrs, "process", 0, 2, false);
tag = (value != -1) ? value + JPEG.SOF0 : tag;
// If samplePrecision is present, it must be 8.
// This just checks. We don't bother to assign the value.
value = getAttributeValue(node, attrs, "samplePrecision", 8, 8, false);
value = getAttributeValue(node, attrs, "numLines", 0, 65535, false);
numLines = (value != -1) ? value : numLines;
value = getAttributeValue(node, attrs, "samplesPerLine", 0, 65535, false);
samplesPerLine = (value != -1) ? value : samplesPerLine;
int numComponents = getAttributeValue(node, attrs, "numFrameComponents", 1, 4, false);
NodeList children = node.getChildNodes();
if (children.getLength() != numComponents) {
throw new IIOInvalidTreeException("numFrameComponents must match number of children", node);
}
componentSpecs = new ComponentSpec[numComponents];
for (int i = 0; i < numComponents; i++) {
componentSpecs[i] = new ComponentSpec(children.item(i));
}
}
use of javax.imageio.metadata.IIOInvalidTreeException in project jdk8u_jdk by JetBrains.
the class JPEGMetadata method mergeSequenceSubtree.
private void mergeSequenceSubtree(Node sequenceTree) throws IIOInvalidTreeException {
NodeList children = sequenceTree.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node node = children.item(i);
String name = node.getNodeName();
if (name.equals("dqt")) {
mergeDQTNode(node);
} else if (name.equals("dht")) {
mergeDHTNode(node);
} else if (name.equals("dri")) {
mergeDRINode(node);
} else if (name.equals("com")) {
mergeCOMNode(node);
} else if (name.equals("app14Adobe")) {
mergeAdobeNode(node);
} else if (name.equals("unknown")) {
mergeUnknownNode(node);
} else if (name.equals("sof")) {
mergeSOFNode(node);
} else if (name.equals("sos")) {
mergeSOSNode(node);
} else {
throw new IIOInvalidTreeException("Invalid node: " + name, node);
}
}
}
use of javax.imageio.metadata.IIOInvalidTreeException in project jdk8u_jdk by JetBrains.
the class JPEGMetadata method mergeTree.
public void mergeTree(String formatName, Node root) throws IIOInvalidTreeException {
if (formatName == null) {
throw new IllegalArgumentException("null formatName!");
}
if (root == null) {
throw new IllegalArgumentException("null root!");
}
List copy = null;
if (resetSequence == null) {
// Deep copy
resetSequence = cloneSequence();
// Avoid cloning twice
copy = resetSequence;
} else {
copy = cloneSequence();
}
if (isStream && (formatName.equals(JPEG.nativeStreamMetadataFormatName))) {
mergeNativeTree(root);
} else if (!isStream && (formatName.equals(JPEG.nativeImageMetadataFormatName))) {
mergeNativeTree(root);
} else if (!isStream && (formatName.equals(IIOMetadataFormatImpl.standardMetadataFormatName))) {
mergeStandardTree(root);
} else {
throw new IllegalArgumentException("Unsupported format name: " + formatName);
}
if (!isConsistent()) {
markerSequence = copy;
throw new IIOInvalidTreeException("Merged tree is invalid; original restored", root);
}
}
use of javax.imageio.metadata.IIOInvalidTreeException in project jdk8u_jdk by JetBrains.
the class AdobeMarkerSegment method updateFromNativeNode.
void updateFromNativeNode(Node node, boolean fromScratch) throws IIOInvalidTreeException {
// Only the transform is required
NamedNodeMap attrs = node.getAttributes();
transform = getAttributeValue(node, attrs, "transform", 0, 2, true);
int count = attrs.getLength();
if (count > 4) {
throw new IIOInvalidTreeException("Adobe APP14 node cannot have > 4 attributes", node);
}
if (count > 1) {
int value = getAttributeValue(node, attrs, "version", 100, 255, false);
version = (value != -1) ? value : version;
value = getAttributeValue(node, attrs, "flags0", 0, 65535, false);
flags0 = (value != -1) ? value : flags0;
value = getAttributeValue(node, attrs, "flags1", 0, 65535, false);
flags1 = (value != -1) ? value : flags1;
}
}
Aggregations