Search in sources :

Example 6 with MappedLocation

use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.

the class TiePointsPanel method zoomToTiePoint.

public void zoomToTiePoint() {
    final MappedLocation object = getEventRowObject();
    final GeoreferencedImage image = this.layer.getImage();
    final Geometry geometry = object.getSourceToTargetLine(image, this.layer.getBoundingBox(), !this.layer.isShowOriginalImage());
    if (geometry != null) {
        final Project project = Project.get();
        final GeometryFactory geometryFactory = project.getGeometryFactory();
        final BoundingBox boundingBox = geometry.getBoundingBox().convert(geometryFactory).expand(200);
        project.setViewBoundingBox(boundingBox);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Project(com.revolsys.swing.map.layer.Project) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage)

Example 7 with MappedLocation

use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.

the class EditGeoreferencedImageOverlay method appendTiePointLocations.

protected void appendTiePointLocations(final StringBuilder toolTip, final List<MappedLocation> tiePoints, final List<Integer> indices, final int startNumber, final boolean source) {
    if (!indices.isEmpty()) {
        int i = startNumber - 1;
        for (final Integer index : indices) {
            final MappedLocation tiePoint = tiePoints.get(index);
            toolTip.append("<div style=\"border-top: 1px solid #666666;padding: 1px;");
            if (i == this.moveTiePointIndex) {
                toolTip.append("background-color: #0000ff;color: #ffffff");
            } else {
                toolTip.append("background-color: #ffffff");
            }
            toolTip.append("\">");
            toolTip.append(i);
            toolTip.append(". ");
            final Point point;
            if (source) {
                point = tiePoint.getSourcePixel();
                toolTip.append("Source: ");
            } else {
                point = tiePoint.getTargetPoint();
                toolTip.append("Target: ");
            }
            appendPoint(toolTip, point);
            if (!source) {
                toolTip.append(" (");
                toolTip.append(point.getCoordinateSystemId());
                toolTip.append(")");
            }
            toolTip.append("</div>");
            i++;
        }
        i++;
    }
}
Also used : MappedLocation(com.revolsys.raster.MappedLocation) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 8 with MappedLocation

use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.

the class EditGeoreferencedImageOverlay method moveTiePointMove.

private boolean moveTiePointMove(final MouseEvent event) {
    boolean hasMove = false;
    if (this.image != null) {
        final List<MappedLocation> tiePoints = this.image.getTiePoints();
        if (!tiePoints.isEmpty()) {
            final List<Integer> closeSourcePixelIndexes = new ArrayList<>();
            final List<Integer> closeTargetPointIndexes = new ArrayList<>();
            final BoundingBox hotSpot = getHotspotBoundingBox();
            int i = 0;
            boolean hasSource = false;
            for (final MappedLocation tiePoint : tiePoints) {
                final Point sourcePoint = this.layer.sourcePixelToTargetPoint(tiePoint);
                if (hotSpot.covers(sourcePoint)) {
                    closeSourcePixelIndexes.add(i);
                    hasMove = true;
                    hasSource = true;
                }
                final Point targetPoint = tiePoint.getTargetPoint();
                if (hotSpot.covers(targetPoint)) {
                    closeTargetPointIndexes.add(i);
                    hasMove = true;
                }
                i++;
            }
            final boolean changed = !closeSourcePixelIndexes.equals(this.closeSourcePixelIndexes) || !closeTargetPointIndexes.equals(this.closeTargetPointIndexes);
            this.closeSourcePixelIndexes = closeSourcePixelIndexes;
            this.closeTargetPointIndexes = closeTargetPointIndexes;
            if (changed && hasMove) {
                this.moveTiePointIndex = 0;
                this.moveTiePointEventPoint = event.getPoint();
            }
            final boolean tooltipSet = setMoveTiePointToolTip();
            if (changed && hasMove) {
                if (tooltipSet) {
                    if (hasSource) {
                        setOverlayAction(ACTION_TIE_POINT_MOVE_SOURCE);
                    } else {
                        setOverlayAction(ACTION_TIE_POINT_MOVE_TARGET);
                    }
                    this.moveTiePointSource = hasSource;
                }
            }
        }
    }
    if (hasMove) {
        return true;
    } else {
        moveTiePointClear();
        return false;
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 9 with MappedLocation

use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.

the class EditGeoreferencedImageOverlay method moveTiePointStart.

private boolean moveTiePointStart(final MouseEvent event) {
    if (this.moveTiePointIndex > -1) {
        if (SwingUtilities.isLeftMouseButton(event)) {
            final MappedLocation tiePoint = getMoveTiePoint();
            String action;
            if (this.moveTiePointSource) {
                action = ACTION_TIE_POINT_MOVE_SOURCE;
                this.moveTiePointOpposite = tiePoint.getTargetPoint();
            } else {
                action = ACTION_TIE_POINT_MOVE_TARGET;
                final GeoreferencedImage image = this.image;
                final boolean showOriginalImage = this.layer.isShowOriginalImage();
                final BoundingBox boundingBox = getImageBoundingBox();
                this.moveTiePointOpposite = tiePoint.getSourcePoint(image, boundingBox, !showOriginalImage);
            }
            if (setOverlayAction(action)) {
                this.moveTiePointStarted = true;
                setMapCursor(CURSOR_NODE_ADD);
                getMap().clearToolTipText();
                event.consume();
                repaint();
                return true;
            }
        }
    }
    return false;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) LineString(com.revolsys.geometry.model.LineString)

Aggregations

MappedLocation (com.revolsys.raster.MappedLocation)9 Point (com.revolsys.geometry.model.Point)5 BoundingBox (com.revolsys.geometry.model.BoundingBox)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 LineString (com.revolsys.geometry.model.LineString)3 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)3 BufferedGeoreferencedImage (com.revolsys.raster.BufferedGeoreferencedImage)2 Geometry (com.revolsys.geometry.model.Geometry)1 Polygon (com.revolsys.geometry.model.Polygon)1 Vertex (com.revolsys.geometry.model.vertex.Vertex)1 BaseCloseable (com.revolsys.io.BaseCloseable)1 Project (com.revolsys.swing.map.layer.Project)1 GeoreferencedImageLayer (com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer)1 ListAddUndo (com.revolsys.swing.undo.ListAddUndo)1 SetObjectProperty (com.revolsys.swing.undo.SetObjectProperty)1 ArrayList (java.util.ArrayList)1