Search in sources :

Example 1 with BufferedGeoreferencedImage

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

the class LayerRendererOverlay method paintComponent.

@Override
public void paintComponent(final Graphics g) {
    if (!(this.layer instanceof NullLayer)) {
        GeoreferencedImage image;
        synchronized (this.loadSync) {
            image = this.image;
            if ((image == null || this.loadImage) && this.imageWorker == null) {
                final BoundingBox boundingBox = this.viewport.getBoundingBox();
                final int viewWidthPixels = this.viewport.getViewWidthPixels();
                final int viewHeightPixels = this.viewport.getViewHeightPixels();
                final GeoreferencedImage loadImage = new BufferedGeoreferencedImage(boundingBox, viewWidthPixels, viewHeightPixels);
                this.imageWorker = new LayerRendererOverlaySwingWorker(this, loadImage);
                Invoke.worker(this.imageWorker);
            }
        }
        if (image != null) {
            render((Graphics2D) g);
        }
    }
}
Also used : NullLayer(com.revolsys.swing.map.layer.NullLayer) BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage)

Example 2 with BufferedGeoreferencedImage

use of com.revolsys.raster.BufferedGeoreferencedImage 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;
}
Also used : Viewport2D(com.revolsys.swing.map.Viewport2D) ImageViewport(com.revolsys.swing.map.ImageViewport) BoundingBox(com.revolsys.geometry.model.BoundingBox) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

BoundingBox (com.revolsys.geometry.model.BoundingBox)2 BufferedGeoreferencedImage (com.revolsys.raster.BufferedGeoreferencedImage)2 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)1 ImageViewport (com.revolsys.swing.map.ImageViewport)1 Viewport2D (com.revolsys.swing.map.Viewport2D)1 NullLayer (com.revolsys.swing.map.layer.NullLayer)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1