}
}
depsImp.add(new LayerDependency(d, layersMap.get(d), dImp));
}
ImportSupport support = new ImportSupport(name, idx, depsImp);
Layer layer = null;
Exception exception = null;
try {
layer = imp.load(e, support, progressMonitor.createSubTaskMonitor(1, false));
} catch (IllegalDataException | IOException ex) {
exception = ex;
}
if (exception != null) {
Main.error(exception);
if (!GraphicsEnvironment.isHeadless()) {
CancelOrContinueDialog dialog = new CancelOrContinueDialog();
dialog.show(
tr("Error loading layer"),
tr("<html>Could not load layer {0} ''{1}''.<br>Error is:<br>{2}</html>", idx, name, exception.getMessage()),
JOptionPane.ERROR_MESSAGE,
progressMonitor
);
if (dialog.isCancel()) {
progressMonitor.cancel();
return;
} else {
continue;
}
}
}
if (layer == null) throw new RuntimeException();
layersMap.put(idx, layer);
}
progressMonitor.worked(1);
}
layers = new ArrayList<>();
for (int idx : layersMap.keySet()) {
Layer layer = layersMap.get(idx);
if (layer == null) {
continue;
}
Element el = elems.get(idx);
if (el.hasAttribute("visible")) {
layer.setVisible(Boolean.parseBoolean(el.getAttribute("visible")));
}
if (el.hasAttribute("opacity")) {
try {
double opacity = Double.parseDouble(el.getAttribute("opacity"));
layer.setOpacity(opacity);
} catch (NumberFormatException ex) {
Main.warn(ex);
}
}
}
for (Entry<Integer, Layer> e : layersMap.entrySet()) {
Layer l = e.getValue();
if (l == null) {
continue;
}
l.setName(names.get(e.getKey()));
layers.add(l);
}
}