Search in sources :

Example 16 with BaseCloseable

use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.

the class UndoManager method addEdit.

@Override
public synchronized boolean addEdit(final UndoableEdit edit) {
    if (edit == null) {
        return false;
    } else {
        final boolean enabled = isEventsEnabled();
        if (enabled) {
            try (BaseCloseable c = setEventsEnabled(false)) {
                if (edit instanceof AbstractUndoableEdit) {
                    final AbstractUndoableEdit abstractEdit = (AbstractUndoableEdit) edit;
                    if (!abstractEdit.isHasBeenDone()) {
                        if (abstractEdit.canRedo()) {
                            abstractEdit.redo();
                        } else {
                            return false;
                        }
                    }
                }
            }
            if (isEventsEnabled()) {
                final boolean added = super.addEdit(edit);
                fireEvents();
                return added;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable)

Example 17 with BaseCloseable

use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.

the class GeoreferencedImageLayerRenderer method renderAlpha.

public static void renderAlpha(final Viewport2D viewport, final Graphics2D graphics, final GeoreferencedImage image, final boolean useTransform, final double alpha, Object interpolationMethod) {
    final Composite composite = graphics.getComposite();
    try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(graphics, false)) {
        AlphaComposite alphaComposite = AlphaComposite.SrcOver;
        if (alpha < 1) {
            alphaComposite = alphaComposite.derive((float) alpha);
        }
        graphics.setComposite(alphaComposite);
        render(viewport, graphics, image, useTransform, interpolationMethod);
    } finally {
        graphics.setComposite(composite);
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite)

Example 18 with BaseCloseable

use of com.revolsys.io.BaseCloseable 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 19 with BaseCloseable

use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.

the class LasPointCloud method forEachPointLaz.

private void forEachPointLaz(final Consumer<? super LasPoint> action) {
    try (ArithmeticDecoder decoder = new ArithmeticDecoder(this.reader);
        BaseCloseable closable = this) {
        final LasZipHeader lasZipHeader = getLasZipHeader();
        final LazDecompress[] pointDecompressors = newLazDecompressors(lasZipHeader, decoder);
        if (lasZipHeader.isCompressor(LasZipHeader.LASZIP_COMPRESSOR_POINTWISE)) {
            forEachPointLazPointwise(decoder, pointDecompressors, action);
        } else {
            forEachPointLazChunked(decoder, pointDecompressors, action);
        }
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) LazDecompress(com.revolsys.elevation.cloud.las.zip.LazDecompress) ArithmeticDecoder(com.revolsys.elevation.cloud.las.zip.ArithmeticDecoder)

Example 20 with BaseCloseable

use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.

the class LasPointCloud method forEachPoint.

@Override
public void forEachPoint(final Consumer<? super LasPoint> action) {
    final long pointCount = getPointCount();
    try {
        final ChannelReader reader = this.reader;
        if (reader == null) {
            this.points.forEach(action);
        } else if (pointCount == 0) {
            this.reader = null;
        } else if (this.header.isLaszip()) {
            forEachPointLaz(action);
        } else {
            try (BaseCloseable closable = this) {
                final LasPointFormat pointFormat = getPointFormat();
                for (int i = 0; i < pointCount; i++) {
                    final LasPoint point = pointFormat.readLasPoint(this, reader);
                    action.accept(point);
                }
            }
        }
    } finally {
        this.reader = null;
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) ChannelReader(com.revolsys.io.channels.ChannelReader) LasPointFormat(com.revolsys.elevation.cloud.las.pointformat.LasPointFormat) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) Point(com.revolsys.geometry.model.Point)

Aggregations

BaseCloseable (com.revolsys.io.BaseCloseable)46 Point (com.revolsys.geometry.model.Point)9 BoundingBox (com.revolsys.geometry.model.BoundingBox)8 Geometry (com.revolsys.geometry.model.Geometry)7 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)6 Polygon (com.revolsys.geometry.model.Polygon)6 Record (com.revolsys.record.Record)5 LineString (com.revolsys.geometry.model.LineString)4 Identifier (com.revolsys.identifier.Identifier)4 RecordReader (com.revolsys.record.io.RecordReader)4 Graphics2D (java.awt.Graphics2D)4 ArrayList (java.util.ArrayList)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 CloseableAffineTransform (com.revolsys.awt.CloseableAffineTransform)2 GeoreferencedImage (com.revolsys.raster.GeoreferencedImage)2 ArrayRecord (com.revolsys.record.ArrayRecord)2 RecordStore (com.revolsys.record.schema.RecordStore)2 Resource (com.revolsys.spring.resource.Resource)2 MapPanel (com.revolsys.swing.map.MapPanel)2