Search in sources :

Example 1 with GeoreferencedImage

use of com.revolsys.raster.GeoreferencedImage 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 GeoreferencedImage

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

the class GeoreferencedImageLayer method getBoundingBox.

@Override
public BoundingBox getBoundingBox() {
    final GeoreferencedImage image = getImage();
    if (image == null) {
        return BoundingBox.empty();
    } else {
        BoundingBox boundingBox = image.getBoundingBox();
        if (boundingBox.isEmpty()) {
            final boolean hasChanges = isHasChanges();
            boundingBox = fitToViewport();
            if (hasChanges) {
                saveChanges();
            } else {
                cancelChanges();
            }
        }
        return boundingBox;
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage)

Example 3 with GeoreferencedImage

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

the class TiledImageLayerRenderer method renderTile.

@Override
protected void renderTile(final Viewport2D viewport, final Cancellable cancellable, final T tile) {
    final Graphics2D graphics = viewport.getGraphics();
    if (graphics != null) {
        final GeometryFactory viewportGeometryFactory = viewport.getGeometryFactory();
        final GeoreferencedImage image = tile.getImage(viewportGeometryFactory);
        if (image != null) {
            GeoreferencedImageLayerRenderer.render(viewport, graphics, image, false);
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) Graphics2D(java.awt.Graphics2D)

Example 4 with GeoreferencedImage

use of com.revolsys.raster.GeoreferencedImage 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);
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BufferedGeoreferencedImage(com.revolsys.raster.BufferedGeoreferencedImage) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) MappedLocation(com.revolsys.raster.MappedLocation) GeoreferencedImageLayer(com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer) Point(com.revolsys.geometry.model.Point) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox) Polygon(com.revolsys.geometry.model.Polygon)

Example 5 with GeoreferencedImage

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

the class GeoreferencedImageLayerRenderer method render.

@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final GeoreferencedImageLayer layer) {
    final double scaleForVisible = viewport.getScaleForVisible();
    if (layer.isVisible(scaleForVisible)) {
        if (!layer.isEditable()) {
            final GeoreferencedImage image = layer.getImage();
            if (image != null) {
                BoundingBox boundingBox = layer.getBoundingBox();
                if (boundingBox == null || boundingBox.isEmpty()) {
                    boundingBox = layer.fitToViewport();
                }
                final Graphics2D graphics = viewport.getGraphics();
                if (graphics != null) {
                    if (!cancellable.isCancelled()) {
                        renderAlpha(viewport, graphics, image, true, layer.getOpacity() / 255.0, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                    }
                    if (!cancellable.isCancelled()) {
                        renderDifferentCoordinateSystem(viewport, graphics, boundingBox);
                    }
                }
            }
        }
    }
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 LineString (com.revolsys.geometry.model.LineString)4 BufferedGeoreferencedImage (com.revolsys.raster.BufferedGeoreferencedImage)4 MappedLocation (com.revolsys.raster.MappedLocation)3 AffineTransform (java.awt.geom.AffineTransform)3 Geometry (com.revolsys.geometry.model.Geometry)2 Point (com.revolsys.geometry.model.Point)2 Vertex (com.revolsys.geometry.model.vertex.Vertex)2 BaseCloseable (com.revolsys.io.BaseCloseable)2 Project (com.revolsys.swing.map.layer.Project)2 Graphics2D (java.awt.Graphics2D)2 Polygon (com.revolsys.geometry.model.Polygon)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 Resource (com.revolsys.spring.resource.Resource)1 MapPanel (com.revolsys.swing.map.MapPanel)1 NullLayer (com.revolsys.swing.map.layer.NullLayer)1 GeoreferencedImageLayer (com.revolsys.swing.map.layer.raster.GeoreferencedImageLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1