Search in sources :

Example 6 with GeoreferencedImage

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Vertex(com.revolsys.geometry.model.vertex.Vertex) MapPanel(com.revolsys.swing.map.MapPanel) BaseCloseable(com.revolsys.io.BaseCloseable) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 7 with GeoreferencedImage

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);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Project(com.revolsys.swing.map.layer.Project) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) MappedLocation(com.revolsys.raster.MappedLocation) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage)

Example 8 with GeoreferencedImage

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);
}
Also used : GeoreferencedImage(com.revolsys.raster.GeoreferencedImage)

Example 9 with GeoreferencedImage

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;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) AffineTransform(java.awt.geom.AffineTransform) Point(com.revolsys.geometry.model.Point)

Example 10 with GeoreferencedImage

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);
}
Also used : GeoreferencedImage(com.revolsys.raster.GeoreferencedImage) Resource(com.revolsys.spring.resource.Resource)

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