Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.DataSet


        setEnabled(true);
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        DataSet set = getCurrentDataSet();
        if (set != null && !set.getAllSelected().isEmpty()) {
            HistoryBrowserDialogManager.getInstance().showHistory(set.getAllSelected());
        } else {
            HistoryObjectIDDialog dialog = new HistoryObjectIDDialog();
            if (dialog.showDialog().getValue() == dialog.getContinueButtonIndex()) {
                HistoryBrowserDialogManager.getInstance().showHistory(dialog.getOsmIds());
            }
View Full Code Here


                    OsmPrimitive current = toCheck.pop();
                    synchronized(this) {
                        reader = new OsmServerBackreferenceReader(current);
                    }
                    getProgressMonitor().subTask(tr("Reading parents of ''{0}''", current.getDisplayName(DefaultNameFormatter.getInstance())));
                    DataSet ds = reader.parseOsm(getProgressMonitor().createSubTaskMonitor(1, false));
                    synchronized(this) {
                        reader = null;
                    }
                    checked.add(current);
                    getProgressMonitor().subTask(tr("Checking for deleted parents in the local dataset"));
                    for (OsmPrimitive p: ds.allPrimitives()) {
                        if (canceled) return;
                        OsmPrimitive myDeletedParent = layer.data.getPrimitiveById(p);
                        // our local dataset includes a deleted parent of a primitive we want
                        // to delete. Include this parent in the collection of uploaded primitives
                        //
View Full Code Here

    }

    private static void initialize() {
        leftHandTrafficPolygons = new ArrayList<>();
        try (InputStream is = new CachedFile("resource://data/left-right-hand-traffic.osm").getInputStream()) {
            DataSet data = OsmReader.parseDataSet(is, null);
            for (Way w : data.getWays()) {
                leftHandTrafficPolygons.add(Geometry.getAreaLatLon(w.getNodes()));
            }
        } catch (IOException | IllegalDataException ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

     *
     */
    public MergeSourceBuildingVisitor(DataSet selectionBase) throws IllegalArgumentException {
        CheckParameterUtil.ensureParameterNotNull(selectionBase, "selectionBase");
        this.selectionBase = selectionBase;
        this.hull = new DataSet();
        this.mappedPrimitives = new HashMap<>();
    }
View Full Code Here

                                // This try/catch is a hack to stop the flooding bug reports about this.
                                // The exception needed to handle with in the first place, means that this
                                // access to the data need to be restarted, if the main thread modifies
                                // the data.
                                DataSet ds = null;
                                // The popup != null check is required because a left-click
                                // produces several events as well, which would make this
                                // variable true. Of course we only want the popup to show
                                // if the middle mouse button has been pressed in the first
                                // place
                                boolean mouseNotMoved = oldMousePos != null
                                        && oldMousePos.equals(ms.mousePos);
                                boolean isAtOldPosition = mouseNotMoved && popup != null;
                                boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0;
                                try {
                                    ds = mv.getCurrentDataSet();
                                    if (ds != null) {
                                        // This is not perfect, if current dataset was changed during execution, the lock would be useless
                                        if(isAtOldPosition && middleMouseDown) {
                                            // Write lock is necessary when selecting in popupCycleSelection
                                            // locks can not be upgraded -> if do read lock here and write lock later (in OsmPrimitive.updateFlags)
                                            // then always occurs deadlock (#5814)
                                            ds.beginUpdate();
                                        } else {
                                            ds.getReadLock().lock();
                                        }
                                    }

                                    // Set the text label in the bottom status bar
                                    // "if mouse moved only" was added to stop heap growing
                                    if (!mouseNotMoved) {
                                        statusBarElementUpdate(ms);
                                    }

                                    // Popup Information
                                    // display them if the middle mouse button is pressed and
                                    // keep them until the mouse is moved
                                    if (middleMouseDown || isAtOldPosition) {
                                        Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos, OsmPrimitive.isUsablePredicate);

                                        final JPanel c = new JPanel(new GridBagLayout());
                                        final JLabel lbl = new JLabel(
                                                "<html>"+tr("Middle click again to cycle through.<br>"+
                                                        "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>",
                                                        null,
                                                        JLabel.HORIZONTAL
                                                );
                                        lbl.setHorizontalAlignment(JLabel.LEFT);
                                        c.add(lbl, GBC.eol().insets(2, 0, 2, 0));

                                        // Only cycle if the mouse has not been moved and the
                                        // middle mouse button has been pressed at least twice
                                        // (the reason for this is the popup != null check for
                                        // isAtOldPosition, see above. This is a nice side
                                        // effect though, because it does not change selection
                                        // of the first middle click)
                                        if(isAtOldPosition && middleMouseDown) {
                                            // Hand down mouse modifiers so the SHIFT mod can be
                                            // handled correctly (see funcion)
                                            popupCycleSelection(osms, ms.modifiers);
                                        }

                                        // These labels may need to be updated from the outside
                                        // so collect them
                                        List<JLabel> lbls = new ArrayList<>(osms.size());
                                        for (final OsmPrimitive osm : osms) {
                                            JLabel l = popupBuildPrimitiveLabels(osm);
                                            lbls.add(l);
                                            c.add(l, GBC.eol().fill(GBC.HORIZONTAL).insets(2, 0, 2, 2));
                                        }

                                        popupShowPopup(popupCreatePopup(c, ms), lbls);
                                    } else {
                                        popupHidePopup();
                                    }

                                    oldMousePos = ms.mousePos;
                                } catch (ConcurrentModificationException x) {
                                    Main.warn(x);
                                } finally {
                                    if (ds != null) {
                                        if(isAtOldPosition && middleMouseDown) {
                                            ds.endUpdate();
                                        } else {
                                            ds.getReadLock().unlock();
                                        }
                                    }
                                }
                            }
                        });
View Full Code Here

         * will automatically select the next item and update the map
         * @param osms primitives to cycle through
         * @param mods modifiers (i.e. control keys)
         */
        private void popupCycleSelection(Collection<OsmPrimitive> osms, int mods) {
            DataSet ds = Main.main.getCurrentDataSet();
            // Find some items that are required for cycling through
            OsmPrimitive firstItem = null;
            OsmPrimitive firstSelected = null;
            OsmPrimitive nextSelected = null;
            for (final OsmPrimitive osm : osms) {
                if(firstItem == null) {
                    firstItem = osm;
                }
                if(firstSelected != null && nextSelected == null) {
                    nextSelected = osm;
                }
                if(firstSelected == null && ds.isSelected(osm)) {
                    firstSelected = osm;
                }
            }

            // Clear previous selection if SHIFT (add to selection) is not
            // pressed. Cannot use "setSelected()" because it will cause a
            // fireSelectionChanged event which is unnecessary at this point.
            if((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) {
                ds.clearSelection();
            }

            // This will cycle through the available items.
            if(firstSelected == null) {
                ds.addSelected(firstItem);
            } else {
                ds.clearSelection(firstSelected);
                if(nextSelected != null) {
                    ds.addSelected(nextSelected);
                }
            }
        }
View Full Code Here

         *
         * @param lbl The label to color
         * @param osm The primitive to derive the colors from
         */
        private void popupSetLabelColors(JLabel lbl, OsmPrimitive osm) {
            DataSet ds = Main.main.getCurrentDataSet();
            if(ds.isSelected(osm)) {
                lbl.setBackground(SystemColor.textHighlight);
                lbl.setForeground(SystemColor.textHighlightText);
            } else {
                lbl.setBackground(SystemColor.control);
                lbl.setForeground(SystemColor.controlText);
View Full Code Here

                }
                @Override public void mouseExited(MouseEvent e) {
                    popupSetLabelColors(l, osm);
                }
                @Override public void mouseClicked(MouseEvent e) {
                    DataSet ds = Main.main.getCurrentDataSet();
                    // Let the user toggle the selection
                    ds.toggleSelected(osm);
                    l.validate();
                }
            });
            // Sometimes the mouseEntered event is not catched, thus the label
            // will not be highlighted, making it confusing. The MotionListener
View Full Code Here

        putValue("help", ht("/Action/NewLayer"));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Main.main.addLayer(new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null));
    }
View Full Code Here

     * @param associatedFile filename of data (can be <code>null</code> if the stream does not come from a file)
     * @param layerName name of generated layer
     * @param progressMonitor handler for progress monitoring and canceling
     */
    public OsmImporterData loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException {
        final DataSet dataSet = parseDataSet(in, progressMonitor);
        if (dataSet == null) {
            throw new IllegalDataException(tr("Invalid dataset"));
        }
        OsmDataLayer layer = createLayer(dataSet, associatedFile, layerName);
        Runnable postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName, layer);
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.DataSet

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.