Package org.openstreetmap.josm.gui.layer

Examples of org.openstreetmap.josm.gui.layer.Layer$LayerSaveAction


                        }
                    }
                    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);
        }
    }
View Full Code Here


                support.addPostLayersTask(importData.getPostLayerTask());

                GpxLayer gpxLayer = null;
                List<SessionReader.LayerDependency> deps = support.getLayerDependencies();
                if (!deps.isEmpty()) {
                    Layer layer = deps.iterator().next().getLayer();
                    if (layer instanceof GpxLayer) {
                        gpxLayer = (GpxLayer) layer;
                    }
                }
View Full Code Here

        this.layer = layer;
    }

    @Override
    public Collection<Layer> getDependencies() {
        Layer gpxLayer = layer.fromLayer;
        if (gpxLayer != null && Main.map.mapView.hasLayer(gpxLayer))
            return Collections.singleton(gpxLayer);
        return Collections.emptySet();
    }
View Full Code Here

        public ToggleLayerIndexVisibility(int layerIndex) {
            this.layerIndex = layerIndex;
        }
        @Override
        public void actionPerformed(ActionEvent e) {
            final Layer l = model.getLayer(model.getRowCount() - layerIndex - 1);
            if(l != null) {
                l.toggleVisible();
            }
        }
View Full Code Here

            }
        }

        @Override
        public void executeMultikeyAction(int index, boolean repeat) {
            Layer l = LayerListDialog.getLayerForIndex(index);
            if (l != null) {
                l.toggleVisible();
                lastLayer = new WeakReference<>(l);
            } else if (repeat && lastLayer != null) {
                l = lastLayer.get();
                if (LayerListDialog.isLayerValid(l)) {
                    l.toggleVisible();
                }
            }
        }
View Full Code Here

            return multikeyShortcut;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            Layer toActivate;
            if (layer != null) {
                toActivate = layer;
            } else {
                toActivate = model.getSelectedLayers().get(0);
            }
View Full Code Here

                    if (layer == null) {
                        if (getModel().getSelectedLayers().size() != 1) {
                            setEnabled(false);
                            return;
                        }
                        Layer selectedLayer = getModel().getSelectedLayers().get(0);
                        setEnabled(!isActiveLayer(selectedLayer));
                    } else {
                        setEnabled(!isActiveLayer(layer));
                    }
                }
View Full Code Here

            updateEnabledState();
        }

        @Override
        public void executeMultikeyAction(int index, boolean repeat) {
            Layer l = LayerListDialog.getLayerForIndex(index);
            if (l != null) {
                execute(l);
            }
        }
View Full Code Here

        public void actionPerformed(ActionEvent e) {
            if (layer != null) {
                Main.main.menu.merge.merge(layer);
            } else {
                if (getModel().getSelectedLayers().size() == 1) {
                    Layer selectedLayer = getModel().getSelectedLayers().get(0);
                    Main.main.menu.merge.merge(selectedLayer);
                } else {
                    Main.main.menu.merge.merge(getModel().getSelectedLayers());
                }
            }
View Full Code Here

        public void updateEnabledState() {
            if (layer == null) {
                if (getModel().getSelectedLayers().isEmpty()) {
                    setEnabled(false);
                } else  if (getModel().getSelectedLayers().size() > 1) {
                    Layer firstLayer = getModel().getSelectedLayers().get(0);
                    for (Layer l: getModel().getSelectedLayers()) {
                        if (l != firstLayer && (!l.isMergable(firstLayer) || !firstLayer.isMergable(l))) {
                            setEnabled(false);
                            return;
                        }
                    }
                    setEnabled(true);
                } else {
                    Layer selectedLayer = getModel().getSelectedLayers().get(0);
                    List<Layer> targets = getModel().getPossibleMergeTargets(selectedLayer);
                    setEnabled(!targets.isEmpty());
                }
            } else {
                List<Layer> targets = getModel().getPossibleMergeTargets(layer);
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.gui.layer.Layer$LayerSaveAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.