Search in sources :

Example 11 with CloseLocation

use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.

the class MapPanel method mouseMovedCloseSelected.

public boolean mouseMovedCloseSelected(final MouseEvent event) {
    if (isOverlayAction(SelectRecordsOverlay.ACTION_SELECT_RECORDS) || isOverlayAction(ZoomOverlay.ACTION_ZOOM_BOX) || isOverlayAction(ZoomOverlay.ACTION_PAN)) {
        clearCloseSelected();
        return false;
    } else {
        final double scale = getViewport().getScale();
        final Point point = MouseOverlay.getEventPoint();
        final double x = point.getX();
        final double y = point.getY();
        final double maxDistance = this.viewport.getHotspotMapUnits();
        final GeometryFactory geometryFactory = this.viewport.getGeometryFactory2dFloating();
        final BoundingBox boundingBox = point.newBoundingBox().expand(maxDistance);
        final List<LayerRecord> closeRecords = new ArrayList<>();
        final List<CloseLocation> closeLocations = new ArrayList<>();
        for (final LayerRecord closeRecord : getSelectedRecords(boundingBox)) {
            final AbstractRecordLayer layer = closeRecord.getLayer();
            if (layer.isVisible(scale) && layer.isVisible(closeRecord)) {
                final Geometry geometry = closeRecord.getGeometry();
                final CloseLocation closeLocation = findCloseLocation(geometryFactory, layer, closeRecord, geometry, x, y, maxDistance);
                if (closeLocation != null) {
                    closeRecords.add(closeRecord);
                    closeLocations.add(closeLocation);
                }
            }
        }
        this.closeSelectedRecords = closeRecords;
        this.closeSelectedLocations = closeLocations;
        repaint();
        return true;
    }
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Point(com.revolsys.geometry.model.Point) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 12 with CloseLocation

use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method modeEditGeometryVerticesFinish.

protected boolean modeEditGeometryVerticesFinish(final MouseEvent event) {
    if (this.editGeometryVerticesStart && clearOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES)) {
        if (this.dragged && event.getButton() == MouseEvent.BUTTON1) {
            try {
                final MultipleUndo edit = new MultipleUndo();
                final List<CloseLocation> locations = getMouseOverLocations();
                for (final CloseLocation location : locations) {
                    final GeometryEditor<?> geometryEditor = geometryEdit(event, location);
                    if (geometryEditor.isModified()) {
                        final Geometry newGeometry = geometryEditor.newGeometry();
                        final UndoableEdit geometryEdit = setGeometry(location, newGeometry);
                        edit.addEdit(geometryEdit);
                    }
                }
                if (!edit.isEmpty()) {
                    addUndo(edit);
                }
            } finally {
                modeEditGeometryVerticesClear();
            }
            return true;
        }
    }
    return false;
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Geometry(com.revolsys.geometry.model.Geometry) UndoableEdit(javax.swing.undo.UndoableEdit) AbstractUndoableEdit(com.revolsys.swing.undo.AbstractUndoableEdit) MultipleUndo(com.revolsys.swing.undo.MultipleUndo)

Example 13 with CloseLocation

use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method modePopupMenu.

private boolean modePopupMenu(final MouseEvent event) {
    if (event.isPopupTrigger()) {
        for (final CloseLocation location : getMouseOverLocations()) {
            final LayerRecord record = location.getRecord();
            if (record != null) {
                final LayerRecordMenu menu = record.getMenu();
                menu.showMenu(record, event);
            }
            return true;
        }
    }
    return false;
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 14 with CloseLocation

use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method modeEditGeometryVerticesMove.

protected boolean modeEditGeometryVerticesMove(final MouseEvent event) {
    if (canOverrideOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES) || isOverlayAction(ACTION_MOVE_GEOMETRY)) {
        final double scale = getViewportScale();
        final List<CloseLocation> closeLocations = new ArrayList<>();
        final MapPanel map = getMap();
        for (final CloseLocation location : map.getCloseSelectedLocations()) {
            final AbstractRecordLayer layer = location.getLayer();
            if (layer.isEditable(scale)) {
                closeLocations.add(location);
            }
        }
        if (closeLocations.isEmpty()) {
            modeMoveGeometryClear();
            modeEditGeometryVerticesClear();
        } else if (event.isAltDown()) {
            setOverlayAction(ACTION_MOVE_GEOMETRY);
        } else {
            setOverlayAction(ACTION_EDIT_GEOMETRY_VERTICES);
        }
        return setMouseOverLocations(closeLocations);
    }
    return false;
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) MapPanel(com.revolsys.swing.map.MapPanel) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer)

Example 15 with CloseLocation

use of com.revolsys.swing.map.overlay.CloseLocation in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method updateMouseOverLocations.

private boolean updateMouseOverLocations() {
    final MapPanel map = getMap();
    if (hasMouseOverLocation()) {
        if (isOverlayAction(ACTION_MOVE_GEOMETRY)) {
            map.clearToolTipText();
        } else {
            final Map<String, Set<CloseLocation>> vertexLocations = new TreeMap<>();
            final Map<String, Set<CloseLocation>> segmentLocations = new TreeMap<>();
            for (final CloseLocation location : getMouseOverLocations()) {
                final String typePath = location.getLayerPath();
                if (location.getVertexId() == null) {
                    Maps.addToSet(segmentLocations, typePath, location);
                } else {
                    Maps.addToSet(vertexLocations, typePath, location);
                }
            }
            final StringBuilder text = new StringBuilder("<html>");
            appendLocations(text, "Move Vertices", vertexLocations);
            appendLocations(text, "Insert Vertices", segmentLocations);
            text.append("</html>");
            final Point2D eventPoint = getEventPosition();
            map.setToolTipText(eventPoint, text);
        }
        return true;
    } else {
        map.clearToolTipText();
        return false;
    }
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) MapPanel(com.revolsys.swing.map.MapPanel) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Point2D(java.awt.geom.Point2D) LineString(com.revolsys.geometry.model.LineString) TreeMap(java.util.TreeMap)

Aggregations

CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)15 Geometry (com.revolsys.geometry.model.Geometry)9 Point (com.revolsys.geometry.model.Point)6 MapPanel (com.revolsys.swing.map.MapPanel)5 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)5 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)5 ArrayList (java.util.ArrayList)5 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)4 AbstractUndoableEdit (com.revolsys.swing.undo.AbstractUndoableEdit)4 MultipleUndo (com.revolsys.swing.undo.MultipleUndo)4 UndoableEdit (javax.swing.undo.UndoableEdit)4 GeometryEditor (com.revolsys.geometry.model.editor.GeometryEditor)3 LinkedHashSet (java.util.LinkedHashSet)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 LineString (com.revolsys.geometry.model.LineString)2 BaseCloseable (com.revolsys.io.BaseCloseable)2 Project (com.revolsys.swing.map.layer.Project)2 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)2 DeleteVertexUndoEdit (com.revolsys.swing.map.overlay.record.geometryeditor.DeleteVertexUndoEdit)2