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);
}
}
}
}
}
}
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();
}
}
}
}
}
}
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;
}
}
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);
}
}
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;
}
Aggregations