Search in sources :

Example 21 with Layer

use of com.revolsys.swing.map.layer.Layer 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 22 with Layer

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

the class ProjectFrame method expandLayers.

public void expandLayers(final Layer layer) {
    if (layer != null) {
        Invoke.later(() -> {
            final LayerGroup group;
            if (layer instanceof LayerGroup) {
                group = (LayerGroup) layer;
            } else {
                group = layer.getLayerGroup();
            }
            if (group != null) {
                final List<Layer> layerPath = group.getPathList();
                this.tocTree.expandPath(layerPath);
            }
        });
    }
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer)

Example 23 with Layer

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

the class ProjectFrame method loadProjectAfter.

protected void loadProjectAfter() {
    this.bottomTabLayerPaths = Sets.newLinkedHash(this.project.<Collection<String>>getProperty("bottomTabLayerPaths"));
    // TODO cleanup on save
    this.project.setProperty("bottomTabLayerPaths", this.bottomTabLayerPaths);
    for (final Iterator<String> iterator = this.bottomTabLayerPaths.iterator(); iterator.hasNext(); ) {
        final String layerPath = iterator.next();
        final Layer layer = this.project.getLayerByPath(layerPath);
        if (layer == null) {
            iterator.remove();
        } else {
            Invoke.later(layer::showTableView);
        }
    }
}
Also used : Collection(java.util.Collection) Layer(com.revolsys.swing.map.layer.Layer)

Example 24 with Layer

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

the class AbstractRecordLayer method addVisibleLayers.

public static void addVisibleLayers(final List<AbstractRecordLayer> layers, final LayerGroup group, final double scale) {
    if (group.isExists() && group.isVisible(scale)) {
        for (final Layer layer : group) {
            if (layer instanceof LayerGroup) {
                final LayerGroup layerGroup = (LayerGroup) layer;
                addVisibleLayers(layers, layerGroup, scale);
            } else if (layer instanceof AbstractRecordLayer) {
                if (layer.isExists() && layer.isVisible(scale)) {
                    final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
                    layers.add(recordLayer);
                }
            }
        }
    }
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) Layer(com.revolsys.swing.map.layer.Layer)

Example 25 with Layer

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

the class LayerGroupListModel method setSelectedItem.

@Override
public void setSelectedItem(final Object selectedItem) {
    if (selectedItem instanceof Layer) {
        final Layer layer = (Layer) selectedItem;
        if (this.selectedItem != layer) {
            this.selectedItem = layer;
            final int index = this.group.indexOf(layer);
            fireContentsChanged(layer, index, index);
        }
    }
}
Also used : Layer(com.revolsys.swing.map.layer.Layer) NullLayer(com.revolsys.swing.map.layer.NullLayer)

Aggregations

Layer (com.revolsys.swing.map.layer.Layer)33 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)18 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)16 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)10 ArrayList (java.util.ArrayList)8 NullLayer (com.revolsys.swing.map.layer.NullLayer)5 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)4 BaseTreeNode (com.revolsys.swing.tree.BaseTreeNode)4 List (java.util.List)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Geometry (com.revolsys.geometry.model.Geometry)3 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)3 TreePath (javax.swing.tree.TreePath)3 MapPanel (com.revolsys.swing.map.MapPanel)2 BaseMapLayerGroup (com.revolsys.swing.map.layer.BaseMapLayerGroup)2 Project (com.revolsys.swing.map.layer.Project)2 ElevationModelLayer (com.revolsys.swing.map.layer.elevation.ElevationModelLayer)2 Rectangle (java.awt.Rectangle)2 JTree (javax.swing.JTree)2 TreeUI (javax.swing.plaf.TreeUI)2