Search in sources :

Example 16 with LayerGroup

use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.

the class SelectRecordsOverlay method selectRecords.

private void selectRecords(final LayerGroup group, final BoundingBox boundingBox) {
    final double scale = getViewportScale();
    final List<Layer> layers = group.getLayers();
    Collections.reverse(layers);
    for (final Layer layer : layers) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            selectRecords(childGroup, boundingBox);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            if (recordLayer.isSelectable(scale)) {
                recordLayer.setSelectedRecords(boundingBox);
            } else {
                recordLayer.clearSelectedRecords();
            }
        }
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 17 with LayerGroup

use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.

the class SelectRecordsOverlay method refreshImageSelectedAndHighlighted.

private void refreshImageSelectedAndHighlighted(final ImageViewport viewport, final Graphics2D graphics, final LayerGroup layerGroup) {
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    final GeometryFactory viewportGeometryFactory = getViewportGeometryFactory2d();
    final List<Geometry> highlightedGeometries = new ArrayList<>();
    for (final Layer layer : layerGroup.getLayers()) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            refreshImageSelectedAndHighlighted(viewport, graphics, childGroup);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            if (recordLayer.isSelectable()) {
                final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
                for (final LayerRecord record : selectedRecords) {
                    if (record != null && recordLayer.isVisible(record)) {
                        if (!recordLayer.isDeleted(record)) {
                            final Geometry geometry = record.getGeometry();
                            if (recordLayer.isHighlighted(record)) {
                                highlightedGeometries.add(geometry);
                            } else {
                                this.selectRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
                            }
                        }
                    }
                }
            }
        }
    }
    for (final Geometry geometry : highlightedGeometries) {
        this.highlightRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) List(java.util.List) ArrayList(java.util.ArrayList) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 18 with LayerGroup

use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.

the class SelectRecordsOverlay method addSelectedRecords.

public void addSelectedRecords(final BoundingBox boundingBox) {
    final LayerGroup project = getProject();
    addSelectedRecords(project, boundingBox);
    final LayerRendererOverlay overlay = getMap().getLayerOverlay();
    overlay.redraw();
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRendererOverlay(com.revolsys.swing.map.overlay.LayerRendererOverlay)

Example 19 with LayerGroup

use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.

the class SelectRecordsOverlay method selectRecords.

public void selectRecords(final BoundingBox boundingBox) {
    try (BaseCloseable closeable = this.selectingRecords.closeable(true)) {
        final LayerGroup project = getProject();
        selectRecords(project, boundingBox);
        final LayerRendererOverlay overlay = getMap().getLayerOverlay();
        overlay.redraw();
        redrawAndRepaint();
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRendererOverlay(com.revolsys.swing.map.overlay.LayerRendererOverlay)

Example 20 with LayerGroup

use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.

the class ComponentViewport2D method updateCachedFields.

private void updateCachedFields() {
    final LayerGroup project = getProject();
    final GeometryFactory geometryFactory = project.getGeometryFactory();
    if (geometryFactory != null) {
        if (geometryFactory != getGeometryFactory()) {
            setGeometryFactory(geometryFactory);
        }
        final Insets insets = this.component.getInsets();
        final int viewWidth = this.component.getWidth() - insets.left - insets.right;
        final int viewHeight = this.component.getHeight() - insets.top - insets.bottom;
        setViewWidth(viewWidth);
        setViewHeight(viewHeight);
        setBoundingBox(getBoundingBox());
        this.component.repaint();
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Insets(java.awt.Insets) LayerGroup(com.revolsys.swing.map.layer.LayerGroup)

Aggregations

LayerGroup (com.revolsys.swing.map.layer.LayerGroup)30 Layer (com.revolsys.swing.map.layer.Layer)16 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)13 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)7 ArrayList (java.util.ArrayList)7 BaseTreeNode (com.revolsys.swing.tree.BaseTreeNode)5 List (java.util.List)5 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)4 Geometry (com.revolsys.geometry.model.Geometry)3 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)3 PathName (com.revolsys.io.PathName)3 LayerRendererOverlay (com.revolsys.swing.map.overlay.LayerRendererOverlay)3 BaseMapLayerGroup (com.revolsys.swing.map.layer.BaseMapLayerGroup)2 Project (com.revolsys.swing.map.layer.Project)2 File (java.io.File)2 LinkedList (java.util.LinkedList)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 RectangularMapGrid (com.revolsys.gis.grid.RectangularMapGrid)1 BaseCloseable (com.revolsys.io.BaseCloseable)1 RecordStore (com.revolsys.record.schema.RecordStore)1