use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method paintComponent.
@Override
public void paintComponent(final Viewport2D viewport, final Graphics2D graphics) {
final GeoreferencedImage imageSelected = this.imageSelected.getResource();
if (imageSelected != null) {
GeoreferencedImageLayerRenderer.render(viewport, graphics, imageSelected, false);
}
final GeometryFactory viewportGeometryFactory = getViewportGeometryFactory2d();
final MapPanel map = getMap();
final List<LayerRecord> closeSelectedRecords = map.getCloseSelectedRecords();
if (!closeSelectedRecords.isEmpty()) {
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, true)) {
for (final LayerRecord record : closeSelectedRecords) {
final Geometry geometry = record.getGeometry();
if (record.isHighlighted()) {
this.highlightVertexRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
} else {
this.selectVertexRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
}
}
}
}
final List<CloseLocation> closeSelectedLocations = map.getCloseSelectedLocations();
if (Property.hasValue(closeSelectedLocations)) {
for (final CloseLocation location : closeSelectedLocations) {
final Vertex vertex = location.getVertex();
CLOSE_VERTEX_STYLE_RENDERER.paintSelected(viewport, graphics, viewportGeometryFactory, vertex);
}
}
paintSelectBox(graphics);
}
use of com.revolsys.raster.GeoreferencedImage 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.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method setImage.
public void setImage(final GeoreferencedImage image) {
final GeoreferencedImage old = this.image;
Property.removeListener(this.image, this);
this.image = image;
if (image == null) {
setExists(false);
} else {
setExists(true);
Property.addListener(image, this);
}
firePropertyChange("image", old, this.image);
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method sourcePixelToTargetPoint.
public Point sourcePixelToTargetPoint(final BoundingBox boundingBox, final boolean useTransform, final double... coordinates) {
if (useTransform) {
final AffineTransform transform = this.image.getAffineTransformation(boundingBox);
transform.transform(coordinates, 0, coordinates, 0, 1);
}
final double imageX = coordinates[0];
final double imageY = coordinates[1];
final GeoreferencedImage image = getImage();
final double xPercent = imageX / image.getImageWidth();
final double yPercent = imageY / image.getImageHeight();
final double modelWidth = boundingBox.getWidth();
final double modelHeight = boundingBox.getHeight();
final double modelX = boundingBox.getMinX() + modelWidth * xPercent;
final double modelY = boundingBox.getMinY() + modelHeight * yPercent;
final GeometryFactory geometryFactory = boundingBox.getGeometryFactory();
final Point imagePoint = geometryFactory.point(modelX, modelY);
return imagePoint;
}
use of com.revolsys.raster.GeoreferencedImage in project com.revolsys.open by revolsys.
the class GeoreferencedImageLayer method cancelChanges.
public void cancelChanges() {
if (this.image == null && this.resource != null) {
GeoreferencedImage image = null;
final Resource imageResource = Resource.getResource(this.url);
if (imageResource.exists()) {
try {
image = GeoreferencedImageReadFactory.loadGeoreferencedImage(imageResource);
if (image == null) {
Logs.error(GeoreferencedImageLayer.class, "Cannot load image: " + this.url);
}
} catch (final RuntimeException e) {
Logs.error(GeoreferencedImageLayer.class, "Unable to load image: " + this.url, e);
}
} else {
Logs.error(GeoreferencedImageLayer.class, "Image does not exist: " + this.url);
}
setImage(image);
} else {
this.image.cancelChanges();
}
firePropertyChange("hasChanges", true, false);
}
Aggregations