Search in sources :

Example 51 with LayerRecord

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);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) List(java.util.List) ArrayList(java.util.ArrayList) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 52 with LayerRecord

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;
    }
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Point(com.revolsys.geometry.model.Point) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 53 with LayerRecord

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();
}
Also used : OsmElement(com.revolsys.record.io.format.openstreetmap.model.OsmElement) Geometry(com.revolsys.geometry.model.Geometry) Identifier(com.revolsys.identifier.Identifier) HashMap(java.util.HashMap) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) OsmDocument(com.revolsys.record.io.format.openstreetmap.model.OsmDocument)

Example 54 with LayerRecord

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);
        }
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 55 with LayerRecord

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);
        }
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) BoundingBox(com.revolsys.geometry.model.BoundingBox) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Aggregations

LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)79 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)34 Geometry (com.revolsys.geometry.model.Geometry)15 IdentifierProxyLayerRecord (com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord)15 NewProxyLayerRecord (com.revolsys.swing.map.layer.record.NewProxyLayerRecord)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Record (com.revolsys.record.Record)11 ArrayList (java.util.ArrayList)11 List (java.util.List)10 Test (org.junit.Test)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Point (com.revolsys.geometry.model.Point)6 Condition (com.revolsys.record.query.Condition)4 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)4 LineString (com.revolsys.geometry.model.LineString)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)3 Layer (com.revolsys.swing.map.layer.Layer)3