Search in sources :

Example 21 with LayerRecord

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

the class MergeRecordsDialog method setMergedRecords.

public void setMergedRecords(String errorMessage, final Map<Record, Set<LayerRecord>> mergedRecords) {
    final Set<Record> unMergeableRecords = new HashSet<>(this.mergeableToOiginalRecordMap.keySet());
    unMergeableRecords.removeAll(mergedRecords.keySet());
    if (!mergedRecords.isEmpty()) {
        int i = 0;
        for (final Entry<Record, Set<LayerRecord>> mergedEntry : mergedRecords.entrySet()) {
            final Record mergedObject = mergedEntry.getKey();
            final Set<LayerRecord> originalObjects = mergedEntry.getValue();
            setMergedRecord(i, mergedObject, originalObjects);
            i++;
        }
    }
    if (!unMergeableRecords.isEmpty() || Property.hasValue(errorMessage)) {
        final Set<LayerRecord> records = new LinkedHashSet<>();
        for (final Record record : unMergeableRecords) {
            final LayerRecord originalRecord = this.mergeableToOiginalRecordMap.get(record);
            if (originalRecord != null) {
                records.add(originalRecord);
            }
        }
        final TablePanel tablePanel = RecordListTableModel.newPanel(this.layer, records);
        final RecordListTableModel tableModel = tablePanel.getTableModel();
        tableModel.setEditable(false);
        tablePanel.setPreferredSize(new Dimension(100, 50 + unMergeableRecords.size() * 22));
        final JPanel panel = Panels.titledTransparentBorderLayout(unMergeableRecords.size() + " Un-Mergeable Records");
        if (!Property.hasValue(errorMessage)) {
            errorMessage = "The following records could not be merged and will not be modified.";
        }
        final JLabel unMergeLabel = new JLabel("<html><p style=\"color:red\">" + errorMessage + "</p></html>");
        panel.add(unMergeLabel, BorderLayout.NORTH);
        panel.add(tablePanel, BorderLayout.SOUTH);
        this.mergedRecordsPanel.add(panel);
    }
    SwingUtil.autoAdjustPosition(this);
    setVisible(true);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JPanel(javax.swing.JPanel) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordListTableModel(com.revolsys.swing.table.record.model.RecordListTableModel) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) TablePanel(com.revolsys.swing.table.TablePanel)

Example 22 with LayerRecord

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

the class FilterMultipleRenderer method renderRecords.

@Override
protected void renderRecords(final Viewport2D viewport, final Cancellable cancellable, final AbstractRecordLayer layer, final List<LayerRecord> records) {
    final Map<AbstractRecordLayerRenderer, List<LayerRecord>> rendererToRecordMap = new LinkedHashMap<>();
    final BoundingBox visibleArea = viewport.getBoundingBox();
    final double scaleForVisible = viewport.getScaleForVisible();
    if (isVisible(scaleForVisible)) {
        final List<AbstractRecordLayerRenderer> renderers = new ArrayList<>(getRenderers());
        for (final AbstractRecordLayerRenderer renderer : renderers) {
            rendererToRecordMap.put(renderer, new ArrayList<>());
        }
        for (final LayerRecord record : cancellable.cancellable(records)) {
            if (isFilterAccept(record) && !layer.isHidden(record)) {
                final AbstractRecordLayerRenderer renderer = getRenderer(layer, renderers, record, scaleForVisible);
                if (renderer != null) {
                    Maps.addToList(rendererToRecordMap, renderer, record);
                }
            }
        }
        for (final Entry<AbstractRecordLayerRenderer, List<LayerRecord>> entry : cancellable.cancellable(rendererToRecordMap.entrySet())) {
            final AbstractRecordLayerRenderer renderer = entry.getKey();
            final List<LayerRecord> rendererRecords = entry.getValue();
            for (final LayerRecord record : cancellable.cancellable(rendererRecords)) {
                try {
                    renderer.renderRecord(viewport, visibleArea, layer, record);
                } catch (final TopologyException e) {
                } catch (final Throwable e) {
                    if (!cancellable.isCancelled()) {
                        Logs.error(this, "Unabled to render " + layer.getName() + " #" + record.getIdentifier(), e);
                    }
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) TopologyException(com.revolsys.geometry.model.TopologyException) LinkedHashMap(java.util.LinkedHashMap) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 23 with LayerRecord

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

the class RecordLayerErrorsTableModel method valueChanged.

@Override
public void valueChanged(final ListSelectionEvent event) {
    final RecordRowTable table = getTable();
    final ListSelectionModel selectionModel = table.getSelectionModel();
    final int rowCount = super.getRowCount();
    final boolean mergedSelected = selectionModel.isSelectedIndex(rowCount);
    for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
        final Record record = getRecord(rowIndex);
        if (record != null) {
            if (mergedSelected || selectionModel.isSelectedIndex(rowIndex)) {
                this.layer.addHighlightedRecords((LayerRecord) record);
            } else {
                this.layer.unHighlightRecords((LayerRecord) record);
            }
        }
    }
    this.layer.zoomToHighlighted();
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordRowTable(com.revolsys.swing.table.record.RecordRowTable)

Example 24 with LayerRecord

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

the class RecordLayerListSelectionModel method setSelectionInterval.

@Override
public void setSelectionInterval(int index0, final int index1) {
    if (index0 == -1 || index1 == -1) {
        return;
    } else if (getSelectionMode() == SINGLE_SELECTION) {
        index0 = index1;
    }
    final boolean valueIsAdjusting = getValueIsAdjusting();
    try {
        setValueIsAdjusting(true);
        final List<LayerRecord> records = getRecords(index0, index1);
        final AbstractRecordLayer layer = this.model.getLayer();
        layer.setSelectedRecords(records);
        super.setSelectionInterval(index0, index1);
    } finally {
        setValueIsAdjusting(valueIsAdjusting);
    }
}
Also used : AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 25 with LayerRecord

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

the class RecordLayerListSelectionModel method getRecords.

protected List<LayerRecord> getRecords(final int index0, final int index1) {
    final List<LayerRecord> records = new ArrayList<>();
    for (int i = index0; i <= index1; i++) {
        final int rowIndex = convertRowIndexToModel(i);
        final LayerRecord record = this.model.getRecord(rowIndex);
        records.add(record);
    }
    return records;
}
Also used : ArrayList(java.util.ArrayList) 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