Search in sources :

Example 16 with Viewport2D

use of com.revolsys.swing.map.Viewport2D in project com.revolsys.open by revolsys.

the class AbstractOverlay method appendPoint.

protected void appendPoint(final StringBuilder text, final Point point) {
    final Viewport2D viewport = getViewport();
    final double unitsPerPixel = viewport.getMetresPerPixel();
    final GeometryFactory geometryFactory = getGeometryFactory();
    double scale = geometryFactory.getScaleXY();
    if (geometryFactory.isProjected()) {
        if (unitsPerPixel > 2) {
            scale = 1.0;
        }
    }
    final double x = point.getX();
    text.append(Doubles.toString(Doubles.makePrecise(scale, x)));
    text.append(",");
    final double y = point.getY();
    text.append(Doubles.toString(Doubles.makePrecise(scale, y)));
}
Also used : Viewport2D(com.revolsys.swing.map.Viewport2D) ComponentViewport2D(com.revolsys.swing.map.ComponentViewport2D) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 17 with Viewport2D

use of com.revolsys.swing.map.Viewport2D 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

Viewport2D (com.revolsys.swing.map.Viewport2D)17 Point (com.revolsys.geometry.model.Point)10 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 MapPanel (com.revolsys.swing.map.MapPanel)7 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)5 Project (com.revolsys.swing.map.layer.Project)5 ComponentViewport2D (com.revolsys.swing.map.ComponentViewport2D)3 Graphics2D (java.awt.Graphics2D)3 LineSegment (com.revolsys.geometry.model.segment.LineSegment)2 BaseCloseable (com.revolsys.io.BaseCloseable)2 ImageViewport (com.revolsys.swing.map.ImageViewport)2 BufferedImage (java.awt.image.BufferedImage)2 PageFormat (java.awt.print.PageFormat)2 PrinterException (java.awt.print.PrinterException)2 PrinterJob (java.awt.print.PrinterJob)2 WebColors (com.revolsys.awt.WebColors)1 Maps (com.revolsys.collection.map.Maps)1 DataType (com.revolsys.datatype.DataType)1 DataTypes (com.revolsys.datatype.DataTypes)1 Geometry (com.revolsys.geometry.model.Geometry)1