use of com.revolsys.swing.map.layer.LayerGroup 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;
}
use of com.revolsys.swing.map.layer.LayerGroup 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;
}
use of com.revolsys.swing.map.layer.LayerGroup in project com.revolsys.open by revolsys.
the class MapPrintable method print.
@Override
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) throws PrinterException {
final Graphics2D graphics2d = (Graphics2D) graphics;
final PrintViewport2D viewport = new PrintViewport2D(this.map, graphics2d, pageFormat, this.boundingBox, this.contentRect, this.dpi);
graphics2d.translate(pageFormat.getImageableX() * this.dpi / 72.0, pageFormat.getImageableX() * this.dpi / 72.0);
drawFooter(graphics2d);
graphics2d.translate(this.contentRect.getMinX(), this.contentRect.getMinY());
drawRuler(viewport, graphics2d);
graphics2d.clip(new Rectangle2D.Double(0, 0, this.contentRect.getWidth(), this.contentRect.getHeight()));
final LayerGroup map = viewport.getProject();
map.getRenderer().render(viewport);
final double unit = viewport.getModelUnitsPerViewUnit();
final float lineWidth = (float) (unit * this.millimetre / 5);
// final boolean saved = viewport.setUseModelCoordinates(true, graphics2d);
try {
graphics2d.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
final double minX = this.boundingBox.getMinX();
final double maxX = this.boundingBox.getMaxX();
final double minY = this.boundingBox.getMinY();
final double maxY = this.boundingBox.getMaxY();
final int startXIndex = (int) Math.ceil(minX / this.majorDivisions);
final int endXIndex = (int) Math.ceil(maxX / this.majorDivisions);
graphics2d.setColor(Color.GRAY);
for (int i = startXIndex; i < endXIndex; i++) {
final double x = i * this.majorDivisions;
graphics2d.draw(new Line2D.Double(x, minY, x, maxY));
}
final int startYIndex = (int) Math.ceil(minY / this.majorDivisions);
final int endYIndex = (int) Math.ceil(maxY / this.majorDivisions);
for (int i = startYIndex; i < endYIndex; i++) {
final double y = i * this.majorDivisions;
graphics2d.draw(new Line2D.Double(minX, y, maxX, y));
}
} finally {
// viewport.setUseModelCoordinates(saved, graphics2d);
}
return PAGE_EXISTS;
}
use of com.revolsys.swing.map.layer.LayerGroup 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.LayerGroup in project com.revolsys.open by revolsys.
the class WebServiceConnectionTrees method getLayerGroup.
public static LayerGroup getLayerGroup(final WebServiceResource webServiceResource) {
LayerGroup layerGroup = Project.get();
if (layerGroup != null) {
final WebService<?> webService = webServiceResource.getWebService();
if (webService != null) {
final String webServiceName = webService.getName();
if (Property.hasValue(webServiceName)) {
layerGroup = layerGroup.addLayerGroup(webServiceName);
}
}
final PathName layerPath = webServiceResource.getPathName();
if (layerPath != null) {
final PathName parent = layerPath.getParent();
if (parent != null) {
for (final String groupName : parent.getElements()) {
layerGroup = layerGroup.addLayerGroup(groupName);
}
}
}
}
return layerGroup;
}
Aggregations