Search in sources :

Example 1 with ListAddUndo

use of com.revolsys.swing.undo.ListAddUndo in project com.revolsys.open by revolsys.

the class EditGeoreferencedImageOverlay method addTiePointFinish.

private boolean addTiePointFinish(final MouseEvent event) {
    if (event == null || event.getButton() == MouseEvent.BUTTON1) {
        if (this.addTiePointFirstPoint != null) {
            if (clearOverlayAction(ACTION_TIE_POINT_ADD)) {
                try {
                    clearMapCursor(CURSOR_SOURCE_PIXEL_ADD);
                    Point mapPoint = getEventPoint();
                    final Point snapPoint = getSnapPoint();
                    if (snapPoint != null) {
                        mapPoint = snapPoint;
                    }
                    final Point sourcePoint = this.addTiePointFirstPoint;
                    final Point sourcePixel = this.layer.targetPointToSourcePixel(sourcePoint);
                    final GeometryFactory geometryFactory = getImageGeometryFactory();
                    final Point targetPoint = mapPoint.newGeometry(geometryFactory);
                    final MappedLocation mappedLocation = new MappedLocation(sourcePixel, targetPoint);
                    addUndo(new ListAddUndo(this.image.getTiePoints(), mappedLocation));
                } finally {
                    addTiePointClear();
                }
                return true;
            }
        }
    }
    return false;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) MappedLocation(com.revolsys.raster.MappedLocation) ListAddUndo(com.revolsys.swing.undo.ListAddUndo) Point(com.revolsys.geometry.model.Point)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Point (com.revolsys.geometry.model.Point)1 MappedLocation (com.revolsys.raster.MappedLocation)1 ListAddUndo (com.revolsys.swing.undo.ListAddUndo)1