}
System.loadLibrary("DCRaw");
System.loadLibrary("Segment");
// Other JNI libraries seem to get pulled in automatically.
Document doc = null;
try {
// First try as a saved-document:
InputStream in = new FileInputStream(file);
XmlDocument xmlDoc = null;
try {
xmlDoc = new XmlDocument(in);
}
catch (IOException e) {
// If xmlDoc is null, we fall back to image-import.
}
if (xmlDoc != null) {
doc = new Document(xmlDoc);
}
else {
// Maybe it's an image:
ImageInfo info = ImageInfo.getInstanceFor(file);
ImageMetadata meta = info.getMetadata();
doc = new Document(meta);
}
}
catch (BadImageFileException e) {
fail("Invalid image file", e);
}
catch (Document.MissingImageFileException e) {
fail("Couldn't find the original image", e);
}
catch (XMLException e) {
fail("Malformed LightZone file", e);
}
catch (IOException e) {
fail("Error reading the file", e);
}
catch (OutOfMemoryError e) {
fail("Insufficient memory to open this file", e);
}
catch (UnknownImageTypeException e) {
fail("Unrecognized image format", e);
}
catch (UnsupportedColorProfileException e) {
fail("Unsupported camera", e);
}
catch (Throwable e) {
System.err.println("Unknown error opening this file:");
e.printStackTrace();
return;
}
editor = doc.getEditor();
}
EditorLayout layout = new EditorLayout(editor);
JFrame frame = new JFrame("EditorLayout");
frame.setContentPane(layout);