Search in sources :

Example 26 with Layer

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

the class LayerStylePanel method propertyChange.

@SuppressWarnings("unchecked")
@Override
public void propertyChange(final PropertyChangeEvent event) {
    final String propertyName = event.getPropertyName();
    if ("replaceRenderer".equals(propertyName)) {
        saveStylePanel();
        final LayerRenderer<? extends Layer> oldRenderer = (LayerRenderer<? extends Layer>) event.getOldValue();
        final LayerRenderer<? extends Layer> newRenderer = (LayerRenderer<? extends Layer>) event.getNewValue();
        if (oldRenderer == this.rootRenderer && newRenderer != null && newRenderer != oldRenderer) {
            Property.removeListener(oldRenderer, this);
            this.rootNode.removeNode(0);
            Property.addListener(newRenderer, this);
            final LayerRendererTreeNode newNode = new LayerRendererTreeNode(newRenderer);
            this.rootNode.addNode(newNode);
            this.tree.expandAllNodes();
            this.rootRenderer = newRenderer;
            // setVisible(newRenderer,true);
            setSelectedRenderer(newRenderer);
        }
    } else if ("renderers".equals(propertyName)) {
        this.tree.expandAllNodes();
    }
}
Also used : LayerRendererTreeNode(com.revolsys.swing.tree.node.layer.LayerRendererTreeNode) LayerRenderer(com.revolsys.swing.map.layer.LayerRenderer) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 27 with Layer

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

the class EditRecordGeometryOverlay method addRecords.

private void addRecords(final List<LayerRecord> results, final LayerGroup group, final Geometry 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;
            addRecords(results, childGroup, boundingBox);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            if (recordLayer.isSelectable(scale)) {
                final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
                for (final LayerRecord selectedRecord : selectedRecords) {
                    final Geometry geometry = selectedRecord.getGeometry();
                    if (boundingBox.intersects(geometry)) {
                        results.add(selectedRecord);
                    }
                }
            }
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) 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) ElevationModelLayer(com.revolsys.swing.map.layer.elevation.ElevationModelLayer) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 28 with Layer

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

the class AbstractLayerTreeNode method setOpen.

@Override
public void setOpen(final boolean open) {
    final Layer layer = getLayer();
    layer.setOpen(open);
}
Also used : Layer(com.revolsys.swing.map.layer.Layer)

Example 29 with Layer

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

the class LayerGroupTreeNode method propertyChangeDo.

@Override
public void propertyChangeDo(final PropertyChangeEvent e) {
    super.propertyChangeDo(e);
    final Object source = e.getSource();
    final LayerGroup layerGroup = getGroup();
    if (source == layerGroup) {
        final String propertyName = e.getPropertyName();
        if ("layers".equals(propertyName)) {
            if (e instanceof IndexedPropertyChangeEvent) {
                final IndexedPropertyChangeEvent indexedEvent = (IndexedPropertyChangeEvent) e;
                final int index = indexedEvent.getIndex();
                final Layer oldLayer = (Layer) e.getOldValue();
                final Layer newLayer = (Layer) e.getNewValue();
                final List<BaseTreeNode> children = new ArrayList<>(getChildren());
                if (newLayer == null) {
                    if (oldLayer != null) {
                        children.remove(index);
                    }
                } else if (oldLayer == null) {
                    final BaseTreeNode newTreeNode = newTreeNode(newLayer);
                    children.add(index, newTreeNode);
                }
                setChildren(children);
            }
        } else if ("visible".equals(propertyName)) {
            if (isChildrenInitialized()) {
                for (final BaseTreeNode childNode : getChildren()) {
                    if (childNode instanceof LayerTreeNode) {
                        final LayerTreeNode childLayerNode = (LayerTreeNode) childNode;
                        childLayerNode.refreshIcon();
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) IndexedPropertyChangeEvent(java.beans.IndexedPropertyChangeEvent) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 30 with Layer

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

the class LayerGroupTreeNode method addChild.

@Override
public int addChild(final Object object) {
    if (object instanceof Layer) {
        final Layer layer = (Layer) object;
        final LayerGroup group = getGroup();
        group.addLayer(layer);
        return getChildCount();
    } else {
        return -1;
    }
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

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