Search in sources :

Example 26 with LayerGroup

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

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

use of com.revolsys.swing.map.layer.LayerGroup 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)

Example 29 with LayerGroup

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

the class LayerGroupTreeNode method dndImportData.

@SuppressWarnings("unchecked")
@Override
public boolean dndImportData(final TransferSupport support, final int index) throws IOException, UnsupportedFlavorException {
    final LayerGroup group = getGroup();
    if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        final Transferable transferable = support.getTransferable();
        final List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
        group.openFiles(index, files);
        return true;
    } else {
        return super.dndImportData(support, index);
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) ArrayList(java.util.ArrayList) List(java.util.List) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) File(java.io.File)

Example 30 with LayerGroup

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

the class LayerGroupTreeNode method newTreeNode.

protected BaseTreeNode newTreeNode(final Layer layer) {
    BaseTreeNode childNode;
    if (layer instanceof LayerGroup) {
        final LayerGroup childGroup = (LayerGroup) layer;
        childNode = new LayerGroupTreeNode(childGroup);
    } else {
        childNode = new LayerTreeNode(layer);
    }
    return childNode;
}
Also used : BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) 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