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);
}
}
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++;
}
}
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;
}
}
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;
}
Aggregations