use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class SelectRecordsOverlay method refreshImageSelectedAndHighlighted.
private void refreshImageSelectedAndHighlighted(final ImageViewport viewport, final Graphics2D graphics, final LayerGroup layerGroup) {
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final GeometryFactory viewportGeometryFactory = getViewportGeometryFactory2d();
final List<Geometry> highlightedGeometries = new ArrayList<>();
for (final Layer layer : layerGroup.getLayers()) {
if (layer instanceof LayerGroup) {
final LayerGroup childGroup = (LayerGroup) layer;
refreshImageSelectedAndHighlighted(viewport, graphics, childGroup);
} else if (layer instanceof AbstractRecordLayer) {
final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
if (recordLayer.isSelectable()) {
final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
for (final LayerRecord record : selectedRecords) {
if (record != null && recordLayer.isVisible(record)) {
if (!recordLayer.isDeleted(record)) {
final Geometry geometry = record.getGeometry();
if (recordLayer.isHighlighted(record)) {
highlightedGeometries.add(geometry);
} else {
this.selectRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
}
}
}
}
}
}
}
for (final Geometry geometry : highlightedGeometries) {
this.highlightRenderer.paintSelected(viewport, graphics, viewportGeometryFactory, geometry);
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class MapPanel method mouseMovedCloseSelected.
public boolean mouseMovedCloseSelected(final MouseEvent event) {
if (isOverlayAction(SelectRecordsOverlay.ACTION_SELECT_RECORDS) || isOverlayAction(ZoomOverlay.ACTION_ZOOM_BOX) || isOverlayAction(ZoomOverlay.ACTION_PAN)) {
clearCloseSelected();
return false;
} else {
final double scale = getViewport().getScale();
final Point point = MouseOverlay.getEventPoint();
final double x = point.getX();
final double y = point.getY();
final double maxDistance = this.viewport.getHotspotMapUnits();
final GeometryFactory geometryFactory = this.viewport.getGeometryFactory2dFloating();
final BoundingBox boundingBox = point.newBoundingBox().expand(maxDistance);
final List<LayerRecord> closeRecords = new ArrayList<>();
final List<CloseLocation> closeLocations = new ArrayList<>();
for (final LayerRecord closeRecord : getSelectedRecords(boundingBox)) {
final AbstractRecordLayer layer = closeRecord.getLayer();
if (layer.isVisible(scale) && layer.isVisible(closeRecord)) {
final Geometry geometry = closeRecord.getGeometry();
final CloseLocation closeLocation = findCloseLocation(geometryFactory, layer, closeRecord, geometry, x, y, maxDistance);
if (closeLocation != null) {
closeRecords.add(closeRecord);
closeLocations.add(closeLocation);
}
}
}
this.closeSelectedRecords = closeRecords;
this.closeSelectedLocations = closeLocations;
repaint();
return true;
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class OpenStreetMapApiLayer method getRecords.
@Override
public List<LayerRecord> getRecords(BoundingBox boundingBox) {
if (hasGeometryField()) {
boundingBox = convertBoundingBox(boundingBox);
if (Property.hasValue(boundingBox)) {
final Map<Identifier, LayerRecord> recordMap = new HashMap<>();
final List<BoundingBox> boundingBoxes = getTileBoundingBoxes(boundingBox);
for (final BoundingBox tileBoundingBox : boundingBoxes) {
final OsmDocument document = getTile(tileBoundingBox);
for (final OsmElement record : document.getRecords()) {
final Geometry geometry = record.getGeometry();
if (geometry != null && !geometry.isEmpty()) {
if (boundingBox.intersects(geometry.getBoundingBox())) {
final Identifier identifier = record.getIdentifier();
final OsmProxyLayerRecord layerRecord = new OsmProxyLayerRecord(this, document, identifier);
recordMap.put(identifier, layerRecord);
}
}
}
}
this.boundingBoxTileMap.keySet().retainAll(boundingBoxes);
return new ArrayList<>(recordMap.values());
}
}
return Collections.emptyList();
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class LayerRecordForm method pasteGeometry.
public void pasteGeometry() {
final LayerRecord record = getRecord();
final AbstractRecordLayer layer = getLayer();
if (layer != null) {
if (record != null) {
layer.pasteRecordGeometry(record);
}
}
}
use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.
the class AbstractRecordLayerRenderer method render.
@Override
public void render(final Viewport2D viewport, final Cancellable cancellable, final AbstractRecordLayer layer) {
if (layer.hasGeometryField()) {
final BoundingBox boundingBox = viewport.getBoundingBox();
final List<LayerRecord> records = layer.getRecordsBackground(boundingBox);
try (BaseCloseable transformCloseable = viewport.setUseModelCoordinates(true)) {
renderRecords(viewport, cancellable, layer, records);
}
}
}
Aggregations