use of com.revolsys.swing.map.ImageViewport in project com.revolsys.open by revolsys.
the class LayerRendererOverlaySwingWorker method handleBackground.
@Override
protected Void handleBackground() {
try {
final Layer layer = this.overlay.getLayer();
if (layer != null) {
final Project project = this.overlay.getProject();
final int imageWidth = this.referencedImage.getImageWidth();
final int imageHeight = this.referencedImage.getImageHeight();
if (imageWidth > 0 && imageHeight > 0 && project != null) {
final BoundingBox boundingBox = this.referencedImage.getBoundingBox();
try (final ImageViewport viewport = new ImageViewport(project, imageWidth, imageHeight, boundingBox)) {
if (layer != null && layer.isExists() && layer.isVisible()) {
final LayerRenderer<Layer> renderer = layer.getRenderer();
if (renderer != null) {
renderer.render(viewport, this);
}
}
if (!isCancelled()) {
final BufferedImage image = viewport.getImage();
this.referencedImage.setRenderedImage(image);
}
}
}
}
return null;
} catch (final Throwable t) {
if (!isCancelled()) {
Logs.error(this, "Unable to paint", t);
}
return null;
}
}
use of com.revolsys.swing.map.ImageViewport in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method refreshImageSelected.
private GeoreferencedImage refreshImageSelected() {
final Viewport2D viewport = getViewport();
if (viewport != null) {
final int width = viewport.getViewWidthPixels();
final int height = viewport.getViewHeightPixels();
if (width > 0 && height > 0) {
try (final ImageViewport imageViewport = new ImageViewport(viewport, BufferedImage.TYPE_INT_ARGB_PRE);
BaseCloseable transformCloseable = imageViewport.setUseModelCoordinates(true)) {
final Graphics2D graphics = imageViewport.getGraphics();
final Project project = getProject();
refreshImageRenderer(imageViewport, project);
refreshImageSelectedAndHighlighted(imageViewport, graphics, project);
return imageViewport.getGeoreferencedImage();
}
}
}
return null;
}
use of com.revolsys.swing.map.ImageViewport in project com.revolsys.open by revolsys.
the class EditGeoreferencedImageOverlay method getCachedImage.
private GeoreferencedImage getCachedImage(BoundingBox boundingBox) {
boundingBox = boundingBox.convert(getViewportGeometryFactory());
final Viewport2D viewport = getViewport();
final BoundingBox viewBoundingBox = viewport.getBoundingBox();
if (this.cachedImage == null || !this.cachedImage.getBoundingBox().equals(viewBoundingBox)) {
try (final ImageViewport imageViewport = new ImageViewport(viewport)) {
final BufferedImage image = imageViewport.getImage();
final Graphics2D graphics = (Graphics2D) image.getGraphics();
this.image.drawImage(graphics, viewBoundingBox, viewport.getViewWidthPixels(), viewport.getViewHeightPixels(), !this.layer.isShowOriginalImage(), RenderingHints.VALUE_INTERPOLATION_BILINEAR);
GeoreferencedImageLayerRenderer.render(imageViewport, graphics, this.image, !this.layer.isShowOriginalImage());
this.cachedImage = new BufferedGeoreferencedImage(imageViewport.getBoundingBox(), image);
}
}
return this.cachedImage;
}
Aggregations