use of com.revolsys.raster.MappedLocation 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;
}
use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method moveTiePointFinish.
private boolean moveTiePointFinish(final MouseEvent event) {
if (this.moveTiePointStarted) {
final MappedLocation tiePoint = getMoveTiePoint();
if (tiePoint != null) {
Point point = getPoint(event);
String action;
if (this.moveTiePointSource) {
action = ACTION_TIE_POINT_MOVE_SOURCE;
} else {
action = ACTION_TIE_POINT_MOVE_TARGET;
}
if (clearOverlayAction(action)) {
if (this.moveTiePointSource) {
final Point sourcePixel = this.layer.targetPointToSourcePixel(point);
final SetObjectProperty setSourcePixel = new SetObjectProperty(tiePoint, "sourcePixel", tiePoint.getSourcePixel(), sourcePixel);
addUndo(setSourcePixel);
} else {
final Point snapPoint = getSnapPoint();
if (snapPoint != null) {
point = snapPoint;
}
final GeometryFactory imageGeometryFactory = getImageGeometryFactory();
point = point.newGeometry(imageGeometryFactory);
tiePoint.setTargetPoint(point);
final SetObjectProperty setTargetPoint = new SetObjectProperty(tiePoint, "targetPoint", tiePoint.getTargetPoint(), point);
addUndo(setTargetPoint);
}
this.closeSourcePixelIndexes.clear();
this.closeTargetPointIndexes.clear();
moveTiePointClear();
clearCachedImage();
clearMapCursor();
clearSnapLocations();
if (event != null) {
event.consume();
}
repaint();
return true;
}
}
}
return false;
}
use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method paintComponent.
@Override
protected void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
super.paintComponent(viewport, graphics);
final GeoreferencedImageLayer layer = this.layer;
final GeoreferencedImage image = this.image;
final BoundingBox moveImageBoundingBox = this.moveImageBoundingBox;
if (layer != null && layer.isVisible() && layer.isExists() && image != null) {
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
final GeometryFactory viewportGeometryFactory = viewport.getGeometryFactory();
final boolean showOriginalImage = layer.isShowOriginalImage();
final BoundingBox imageBoundingBox = getImageBoundingBox();
BoundingBox boundingBox = imageBoundingBox;
BoundingBox outlineBoundingBox = boundingBox;
if (moveImageBoundingBox != null) {
if (showOriginalImage) {
boundingBox = moveImageBoundingBox;
}
outlineBoundingBox = moveImageBoundingBox;
}
final GeoreferencedImage cachedImage = getCachedImage(boundingBox);
GeoreferencedImageLayerRenderer.renderAlpha(viewport, graphics, cachedImage, false, layer.getOpacity() / 255.0, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
GeoreferencedImageLayerRenderer.renderDifferentCoordinateSystem(viewport, graphics, imageBoundingBox);
if (outlineBoundingBox != null && !outlineBoundingBox.isEmpty()) {
final Polygon imageBoundary = outlineBoundingBox.convert(getViewportGeometryFactory()).toPolygon(1);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
viewport.drawGeometryOutline(imageBoundary, STYLE_BOX_OUTLINE);
MarkerStyleRenderer.renderMarkerVertices(viewport, graphics, imageBoundary, STYLE_BOX_CORNER);
final List<MappedLocation> tiePoints = image.getTiePoints();
final int tiePointCount = tiePoints.size();
final GeometryFactory viewGeometryFactory = getGeometryFactory();
if (tiePointCount > 0) {
for (final MappedLocation mappedLocation : tiePoints) {
LineString line = mappedLocation.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
if (line != null) {
line = line.convertGeometry(viewportGeometryFactory);
try (BaseCloseable transformCloseable1 = viewport.setUseModelCoordinates(graphics, true)) {
TIE_POINT_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, line);
}
}
}
for (final MappedLocation mappedLocation : tiePoints) {
LineString line = mappedLocation.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
if (line != null) {
line = line.convertGeometry(viewportGeometryFactory);
TIE_POINT_VERTEX_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, line);
}
}
}
if (!showOriginalImage) {
final double width = image.getImageWidth() - 1;
final double height = image.getImageHeight() - 1;
final double[] targetCoordinates = MappedLocation.toModelCoordinates(image, boundingBox, true, 0, height, width, height, width, 0, 0, 0, 0, height);
final LineString line = viewGeometryFactory.lineString(2, targetCoordinates);
GeometryStyleRenderer.renderLineString(viewport, graphics, line, STYLE_IMAGE_LINE);
}
}
final MappedLocation moveTiePoint = getMoveTiePoint();
if (moveTiePoint != null) {
final LineString line = moveTiePoint.getSourceToTargetLine(image, boundingBox, !showOriginalImage);
Vertex vertex;
if (this.moveTiePointSource) {
vertex = line.getVertex(0);
} else {
vertex = line.getToVertex(0);
}
TIE_POINT_CLOSE_VERTEX_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, vertex);
}
}
}
drawXorGeometry(graphics);
}
use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.
the class TiePointsPanel method getEventRowObject.
protected MappedLocation getEventRowObject() {
final ObjectListTableModel<MappedLocation> model = getTableModel();
final int row = getEventRow();
final MappedLocation object = model.getObject(row);
return object;
}
use of com.revolsys.raster.MappedLocation in project com.revolsys.open by revolsys.
the class TiePointsPanel method deleteTiePoint.
public void deleteTiePoint() {
final MappedLocation tiePoint = getEventRowObject();
this.layer.deleteTiePoint(tiePoint);
}
Aggregations