Search in sources :

Example 31 with MapPanel

use of com.revolsys.swing.map.MapPanel 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 32 with MapPanel

use of com.revolsys.swing.map.MapPanel 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

MapPanel (com.revolsys.swing.map.MapPanel)32 Point (com.revolsys.geometry.model.Point)6 Viewport2D (com.revolsys.swing.map.Viewport2D)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LineString (com.revolsys.geometry.model.LineString)4 RecordDefinition (com.revolsys.record.schema.RecordDefinition)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 ArrayList (java.util.ArrayList)4 DataType (com.revolsys.datatype.DataType)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 Project (com.revolsys.swing.map.layer.Project)3 Set (java.util.Set)3 TreeMap (java.util.TreeMap)3 JLabel (javax.swing.JLabel)3 Geometry (com.revolsys.geometry.model.Geometry)2 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)2 EnableCheck (com.revolsys.swing.action.enablecheck.EnableCheck)2 TabbedValuePanel (com.revolsys.swing.component.TabbedValuePanel)2 Layer (com.revolsys.swing.map.layer.Layer)2