Search in sources :

Example 36 with AbstractRecordLayer

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

the class SelectRecordsOverlay method addSelectedRecords.

private void addSelectedRecords(final LayerGroup group, final BoundingBox boundingBox) {
    final double scale = getViewportScale();
    final List<Layer> layers = group.getLayers();
    Collections.reverse(layers);
    for (final Layer layer : layers) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            addSelectedRecords(childGroup, boundingBox);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            if (recordLayer.isSelectable(scale)) {
                recordLayer.addSelectedRecords(boundingBox);
            }
        }
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 37 with AbstractRecordLayer

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

the class GeometryCoordinatesTableModel method setGeometry.

public void setGeometry(final Geometry geometry) {
    final LayerRecordForm form = this.geometryCoordinatesPanel.getForm();
    final LayerRecord record = form.getRecord();
    final Geometry oldGeometry = record.getGeometry();
    if (oldGeometry != geometry) {
        final AbstractRecordLayer layer = record.getLayer();
        final String geometryFieldName = record.getGeometryFieldName();
        final UndoableEdit setGeometryUndo = layer.newSetFieldUndo(record, geometryFieldName, oldGeometry, geometry);
        final UndoManager undoManager = form.getUndoManager();
        undoManager.addEdit(setGeometryUndo);
    }
    if (this.geometry != geometry) {
        this.geometry = geometry;
        if (geometry == null) {
            this.geometryFactory = GeometryFactory.DEFAULT_3D;
            this.vertexIndexMap = Collections.emptyMap();
            this.vertexIndices = Collections.emptyList();
        } else {
            this.geometryFactory = geometry.getGeometryFactory();
            this.vertexIndexMap = getIndexOfVertices(geometry);
            this.vertexIndices = new ArrayList<>(this.vertexIndexMap.keySet());
        }
        this.axisCount = this.geometryFactory.getAxisCount();
        this.axisNames = new ArrayList<>();
        if (geometry.isGeometryCollection()) {
            this.axisNames.add("P");
        }
        if (geometry instanceof Polygonal) {
            this.axisNames.add("R");
        }
        this.vertexIndexColumn = this.axisNames.size();
        this.axisNames.add("#");
        this.segmentIndexColumn = this.axisNames.size();
        this.axisNames.add("S #");
        this.numIndexItems = this.axisNames.size();
        this.axisNames.add("X");
        this.axisNames.add("Y");
        if (this.axisCount > 2) {
            this.axisNames.add("Z");
        }
        if (this.axisCount > 3) {
            this.axisNames.add("M");
        }
        this.columnCount = this.axisNames.size();
        fireTableStructureChanged();
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LayerRecordForm(com.revolsys.swing.map.form.LayerRecordForm) UndoManager(com.revolsys.swing.undo.UndoManager) UndoableEdit(javax.swing.undo.UndoableEdit) Polygonal(com.revolsys.geometry.model.Polygonal) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 38 with AbstractRecordLayer

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

the class SelectRecordsOverlay method refreshImageRenderer.

private void refreshImageRenderer(final ImageViewport viewport, final LayerGroup layerGroup) {
    for (final Layer layer : layerGroup.getLayers()) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            refreshImageRenderer(viewport, childGroup);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            final AbstractRecordLayerRenderer layerRenderer = layer.getRenderer();
            if (recordLayer.isSelectable()) {
                final List<LayerRecord> selectedRecords = recordLayer.getSelectedRecords();
                for (final LayerRecord record : selectedRecords) {
                    if (record != null && recordLayer.isVisible(record)) {
                        if (!recordLayer.isDeleted(record)) {
                            layerRenderer.renderSelectedRecord(viewport, recordLayer, record);
                        }
                    }
                }
            }
        }
    }
}
Also used : AbstractRecordLayerRenderer(com.revolsys.swing.map.layer.record.renderer.AbstractRecordLayerRenderer) 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 39 with AbstractRecordLayer

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

the class SelectRecordsOverlay method selectRecords.

private void selectRecords(final LayerGroup group, final BoundingBox boundingBox) {
    final double scale = getViewportScale();
    final List<Layer> layers = group.getLayers();
    Collections.reverse(layers);
    for (final Layer layer : layers) {
        if (layer instanceof LayerGroup) {
            final LayerGroup childGroup = (LayerGroup) layer;
            selectRecords(childGroup, boundingBox);
        } else if (layer instanceof AbstractRecordLayer) {
            final AbstractRecordLayer recordLayer = (AbstractRecordLayer) layer;
            if (recordLayer.isSelectable(scale)) {
                recordLayer.setSelectedRecords(boundingBox);
            } else {
                recordLayer.clearSelectedRecords();
            }
        }
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 40 with AbstractRecordLayer

use of com.revolsys.swing.map.layer.record.AbstractRecordLayer 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)

Aggregations

AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)71 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)35 Geometry (com.revolsys.geometry.model.Geometry)9 ArrayList (java.util.ArrayList)8 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)7 Layer (com.revolsys.swing.map.layer.Layer)7 List (java.util.List)7 Record (com.revolsys.record.Record)6 Condition (com.revolsys.record.query.Condition)6 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)6 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 Color (java.awt.Color)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Point (com.revolsys.geometry.model.Point)3 Field (com.revolsys.swing.field.Field)3 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)3 WebColors (com.revolsys.awt.WebColors)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)2 Identifier (com.revolsys.identifier.Identifier)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)2