Search in sources :

Example 1 with AppendVertexUndoEdit

use of com.revolsys.swing.map.overlay.record.geometryeditor.AppendVertexUndoEdit in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method modeAddGeometryClick.

protected boolean modeAddGeometryClick(final MouseEvent event) {
    final int modifiers = event.getModifiersEx();
    if (modifiers == 0 && event.getButton() == MouseEvent.BUTTON1) {
        final int clickCount = event.getClickCount();
        if (clickCount == 1) {
            if (isOverlayAction(ACTION_ADD_GEOMETRY) && !hasMouseOverLocation()) {
                Point point = getSnapPoint();
                if (point == null) {
                    point = getPoint(event);
                }
                final GeometryFactory geometryFactory = this.addLayer.getGeometryFactory();
                point = point.newGeometry(geometryFactory);
                addUndo(new // 
                MultipleUndo(new AppendVertexUndoEdit(this.addGeometryEditor, this.addGeometryPartIndex, this.addGeometryPartDataType, // 
                point), // 
                new ClearXorUndoEdit()));
                event.consume();
                if (DataTypes.POINT.equals(this.addGeometryEditor.getDataType())) {
                    if (isOverlayAction(ACTION_ADD_GEOMETRY)) {
                        modeAddGeometryCompleted();
                    }
                }
                return true;
            }
        } else if (clickCount == 2) {
            if (isOverlayAction(ACTION_ADD_GEOMETRY) || isOverlayAction(ACTION_ADD_GEOMETRY_EDIT_VERTICES)) {
                setXorGeometry(null);
                event.consume();
                Point point = getSnapPoint();
                if (point == null) {
                    point = getPoint(event);
                }
                addUndo(new AppendVertexUndoEdit(this.addGeometryEditor, this.addGeometryPartIndex, this.addGeometryPartDataType, point));
                modeAddGeometryCompleted();
                return true;
            }
        }
    }
    return false;
}
Also used : AppendVertexUndoEdit(com.revolsys.swing.map.overlay.record.geometryeditor.AppendVertexUndoEdit) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Point (com.revolsys.geometry.model.Point)1 AppendVertexUndoEdit (com.revolsys.swing.map.overlay.record.geometryeditor.AppendVertexUndoEdit)1