use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class LayerRendererOverlaySwingWorker method handleBackground.
@Override
protected Void handleBackground() {
try {
final Layer layer = this.overlay.getLayer();
if (layer != null) {
final Project project = this.overlay.getProject();
final int imageWidth = this.referencedImage.getImageWidth();
final int imageHeight = this.referencedImage.getImageHeight();
if (imageWidth > 0 && imageHeight > 0 && project != null) {
final BoundingBox boundingBox = this.referencedImage.getBoundingBox();
try (final ImageViewport viewport = new ImageViewport(project, imageWidth, imageHeight, boundingBox)) {
if (layer != null && layer.isExists() && layer.isVisible()) {
final LayerRenderer<Layer> renderer = layer.getRenderer();
if (renderer != null) {
renderer.render(viewport, this);
}
}
if (!isCancelled()) {
final BufferedImage image = viewport.getImage();
this.referencedImage.setRenderedImage(image);
}
}
}
}
return null;
} catch (final Throwable t) {
if (!isCancelled()) {
Logs.error(this, "Unable to paint", t);
}
return null;
}
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class EditRecordGeometryOverlay method addSnapLayers.
protected boolean addSnapLayers(final Set<AbstractRecordLayer> layers, final Project project, final AbstractRecordLayer layer, final double scale) {
if (layer != null) {
if (layer.isSnapToAllLayers()) {
return true;
} else {
layers.add(layer);
final Collection<String> layerPaths = layer.getSnapLayerPaths();
if (layerPaths != null) {
for (final String layerPath : layerPaths) {
final Layer snapLayer = project.getLayer(layerPath);
if (snapLayer instanceof AbstractRecordLayer) {
if (snapLayer.isVisible(scale)) {
layers.add((AbstractRecordLayer) snapLayer);
}
}
}
}
}
}
return false;
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class MapPanel method propertyChange.
@SuppressWarnings("unchecked")
@Override
public void propertyChange(final PropertyChangeEvent event) {
final Object source = event.getSource();
final String propertyName = event.getPropertyName();
final Object oldValue = event.getOldValue();
final Object newValue = event.getNewValue();
if (AbstractRecordLayer.RECORDS_SELECTED.equals(propertyName)) {
final List<LayerRecord> oldRecords = (List<LayerRecord>) oldValue;
this.selectedRecordsIndex.removeRecords(oldRecords);
final List<LayerRecord> newRecords = (List<LayerRecord>) newValue;
this.selectedRecordsIndex.addRecords(newRecords);
} else if (source == this.project) {
if ("viewBoundingBox".equals(propertyName)) {
final BoundingBox boundingBox = (BoundingBox) newValue;
setBoundingBox(boundingBox);
} else if ("geometryFactory".equals(propertyName)) {
final GeometryFactory oldGeometryFactory = (GeometryFactory) oldValue;
final GeometryFactory newGeometryFactory = (GeometryFactory) newValue;
setGeometryFactory(oldGeometryFactory, newGeometryFactory);
}
} else if (source == this.viewport) {
if ("geometryFactory".equals(propertyName)) {
final GeometryFactory oldGeometryFactory = (GeometryFactory) oldValue;
final GeometryFactory newGeometryFactory = (GeometryFactory) newValue;
setGeometryFactory(oldGeometryFactory, newGeometryFactory);
} else if ("boundingBox".equals(propertyName)) {
final BoundingBox boundingBox = this.viewport.getBoundingBox();
setBoundingBox(boundingBox);
} else if ("unitsPerPixel".equals(propertyName)) {
repaint();
}
} else if (source == this.baseMapOverlay) {
if ("layer".equals(propertyName)) {
final Layer layer = (Layer) newValue;
if (this.baseMapLayerField != null) {
if (layer == null) {
this.baseMapLayerField.setSelectedItem(0);
} else {
this.baseMapLayerField.setSelectedItem(layer);
}
}
}
} else if (source == this.baseMapLayers) {
if ("layers".equals(propertyName)) {
if (this.baseMapOverlay != null) {
final Layer selectedLayer = this.baseMapOverlay.getLayer();
final Layer newLayer = (Layer) newValue;
if (selectedLayer != newLayer) {
if (selectedLayer != null) {
final LayerGroup selectedLayerParent = selectedLayer.getLayerGroup();
if (selectedLayer.isDeleted() || selectedLayerParent != null && selectedLayerParent != this.baseMapLayers) {
this.baseMapOverlay.setLayer(null);
}
}
if (newLayer != null && newLayer.isVisible()) {
this.baseMapOverlay.setLayer(newLayer);
this.baseMapLayerField.setSelectedItem(newLayer);
if (selectedLayer != null) {
selectedLayer.setVisible(false);
}
}
}
}
}
} else if (source instanceof Layer) {
final Layer layer = (Layer) source;
if (layer.getParent() == this.baseMapLayers) {
if ("visible".equals(propertyName)) {
final boolean visible = layer.isVisible();
if (visible) {
this.baseMapLayerField.setSelectedItem(layer);
} else if (!this.baseMapLayers.isHasVisibleLayer()) {
this.baseMapLayerField.setSelectedIndex(0);
}
}
}
} else if (source instanceof LayerRecord) {
final LayerRecord record = (LayerRecord) source;
if (propertyName.equals(record.getGeometryFieldName())) {
if (record.isSelected()) {
final Geometry oldGeometry = (Geometry) oldValue;
if (oldGeometry == null) {
final BoundingBox boundingBox = record.getGeometry().getBoundingBox();
this.selectedRecordsIndex.removeItem(boundingBox, record);
} else {
final BoundingBox boundingBox = oldGeometry.getBoundingBox();
this.selectedRecordsIndex.removeItem(boundingBox, record);
}
this.selectedRecordsIndex.addRecord(record);
}
}
}
repaint();
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class MapPanel method setBaseMapLayer.
public synchronized void setBaseMapLayer(final Layer layer) {
if (layer == NullLayer.INSTANCE || this.baseMapLayers.containsLayer(layer)) {
final Layer oldValue = getBaseMapLayer();
this.baseMapOverlay.setLayer(layer);
firePropertyChange("baseMapLayer", oldValue, layer);
}
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class AbstractLayerTreeNode method getTreeCellRendererComponent.
@Override
public Component getTreeCellRendererComponent(Component renderer, final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
renderer = super.getTreeCellRendererComponent(renderer, tree, value, selected, expanded, leaf, row, hasFocus);
if (isUserObjectInitialized()) {
final Layer layer = getLayer();
final MapPanel map = layer.getMapPanel();
if (map != null) {
final double scale = map.getScale();
if (layer.getRenderer() != null && !layer.isVisible(scale)) {
renderer.setForeground(WebColors.Gray);
}
}
}
return renderer;
}
Aggregations