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);
}
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);
}
}
}
}
}
}
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();
}
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);
}
}
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;
}
Aggregations