Search in sources :

Example 1 with Layer

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

the class AbstractTiledLayerRenderer method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final Object newValue = event.getNewValue();
    if (newValue instanceof BoundingBox) {
        final BoundingBox newBoundingBox = (BoundingBox) newValue;
        synchronized (this.cachedTiles) {
            final List<T> mapTiles = new ArrayList<>(this.cachedTiles.keySet());
            final GeometryFactory newGeometryFactory = newBoundingBox.getGeometryFactory();
            for (final T mapTile : mapTiles) {
                final BoundingBox boundingBox = mapTile.getBoundingBox();
                final GeometryFactory geometryFactory = boundingBox.getGeometryFactory();
                if (!geometryFactory.equals(newGeometryFactory) || !newBoundingBox.intersects(boundingBox)) {
                    this.cachedTiles.remove(mapTile);
                }
            }
        }
    } else if (!TILES_LOADED.equals(event.getPropertyName())) {
        clearCachedTiles();
    }
    if (!(event.getSource() instanceof Layer)) {
        firePropertyChange(event);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) Layer(com.revolsys.swing.map.layer.Layer)

Example 2 with Layer

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

the class LayerRendererOverlay method setLayer.

public void setLayer(final Layer layer) {
    final Layer old = this.layer;
    if (old != layer) {
        if (old != null) {
            if (old.getParent() instanceof BaseMapLayerGroup) {
                old.setVisible(false);
            }
            Property.removeListener(old, this);
        }
        this.layer = layer;
        if (layer != null) {
            Property.addListener(layer, this);
            if (layer.getParent() instanceof BaseMapLayerGroup) {
                layer.setVisible(true);
            }
            if (layer.isInitialized()) {
                layer.refresh();
            }
        }
        this.image = null;
        redraw();
        firePropertyChange("layer", old, layer);
    }
}
Also used : BaseMapLayerGroup(com.revolsys.swing.map.layer.BaseMapLayerGroup) Layer(com.revolsys.swing.map.layer.Layer) NullLayer(com.revolsys.swing.map.layer.NullLayer)

Example 3 with Layer

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

the class ElevationModelLayer method getElevation.

static double getElevation(final LayerGroup layerGroup, final double scale, final Point point) {
    if (layerGroup.isVisible(scale)) {
        for (final Layer layer : layerGroup) {
            if (layer instanceof LayerGroup) {
                final LayerGroup childGroup = (LayerGroup) layer;
                final double elevation = getElevation(childGroup, scale, point);
                if (Double.isFinite(elevation)) {
                    return elevation;
                }
            } else if (layer instanceof ElevationModelLayer) {
                final ElevationModelLayer elevationModel = (ElevationModelLayer) layer;
                if (elevationModel.isUseElevationAtScale(scale)) {
                    final double elevation = elevationModel.getElevation(point);
                    if (Double.isFinite(elevation)) {
                        return elevation;
                    }
                }
            }
        }
    }
    return Double.NaN;
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer)

Example 4 with Layer

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

the class ElevationModelLayer method getElevationVisible.

static double getElevationVisible(final LayerGroup layerGroup, final double scale, final Point point) {
    if (layerGroup.isVisible(scale)) {
        for (final Layer layer : layerGroup) {
            if (layer instanceof LayerGroup) {
                final LayerGroup childGroup = (LayerGroup) layer;
                final double elevation = getElevation(childGroup, scale, point);
                if (Double.isFinite(elevation)) {
                    return elevation;
                }
            } else if (layer instanceof ElevationModelLayer) {
                final ElevationModelLayer elevationModel = (ElevationModelLayer) layer;
                if (elevationModel.isVisible(scale)) {
                    final double elevation = elevationModel.getElevation(point);
                    if (Double.isFinite(elevation)) {
                        return elevation;
                    }
                }
            }
        }
    }
    return Double.NaN;
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer)

Example 5 with Layer

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

the class LayerGroupListModel method reorder.

@Override
public void reorder(final int fromIndex, int toIndex) {
    if (fromIndex < toIndex) {
        toIndex--;
    }
    final Layer layer = getElementAt(fromIndex);
    this.group.removeLayer(fromIndex);
    this.group.addLayer(toIndex, layer);
}
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