31 |
import schmitzm.jfree.chart.selection.DatasetSelectionModel; |
import schmitzm.jfree.chart.selection.DatasetSelectionModel; |
32 |
import schmitzm.jfree.chart.selection.DatasetSelectionModelProvider; |
import schmitzm.jfree.chart.selection.DatasetSelectionModelProvider; |
33 |
import schmitzm.jfree.chart.selection.DatasetSelectionChangeEvent; |
import schmitzm.jfree.chart.selection.DatasetSelectionChangeEvent; |
34 |
|
import schmitzm.jfree.feature.Feature2DatasetItemDatasetGroup; |
35 |
|
|
36 |
/** |
/** |
37 |
* This class keeps the selection of a {@link Dataset} (based on feature |
* This class keeps the selection of a {@link Dataset} (based on feature |
53 |
public class ChartSelectionSynchronizer extends StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> |
public class ChartSelectionSynchronizer extends StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> |
54 |
implements DatasetSelectionListener { |
implements DatasetSelectionListener { |
55 |
|
|
56 |
/** |
/** Holds the chart datset to keep synchronized with the layer selection model. */ |
|
* Holds the chart datset to keep synchronized with the layer selection model. |
|
|
*/ |
|
57 |
protected DatasetSelectionModel<?> datasetSelModel = null; |
protected DatasetSelectionModel<?> datasetSelModel = null; |
58 |
|
/** Hold the mapping between feature IDs and dataset items. */ |
59 |
|
protected Feature2DatasetItemDatasetGroup<?> mapping = null; |
60 |
|
|
61 |
/** |
/** |
62 |
* Creates a new synchronizer. |
* Creates a new synchronizer. |
63 |
* @param layerSelModel |
* @param layerSelModel |
69 |
*/ |
*/ |
70 |
public ChartSelectionSynchronizer(StyledFeatureLayerSelectionModel layerSelModel, DatasetSelectionModel<?> datasetSelModel) { |
public ChartSelectionSynchronizer(StyledFeatureLayerSelectionModel layerSelModel, DatasetSelectionModel<?> datasetSelModel) { |
71 |
super(layerSelModel); |
super(layerSelModel); |
72 |
|
// the dataset selection model must provide a mapping |
73 |
|
// to the feature IDs |
74 |
|
if ( datasetSelModel.getDataset() == null || |
75 |
|
!(datasetSelModel.getDataset().getGroup() instanceof Feature2DatasetItemDatasetGroup) ) |
76 |
|
throw new UnsupportedOperationException("Dataset must provide a Feature2DatasetItemDatasetGroup as DatasetGroup."); |
77 |
this.datasetSelModel = datasetSelModel; |
this.datasetSelModel = datasetSelModel; |
78 |
|
this.mapping = (Feature2DatasetItemDatasetGroup<?>)datasetSelModel.getDataset().getGroup(); |
79 |
} |
} |
80 |
|
|
81 |
/** |
/** |
106 |
datasetSelModel.setValueIsAdjusting(true); |
datasetSelModel.setValueIsAdjusting(true); |
107 |
datasetSelModel.clearSelection(); |
datasetSelModel.clearSelection(); |
108 |
|
|
109 |
XYSeriesCollection dataset = (XYSeriesCollection)datasetSelModel.getDataset(); |
for (String fID : newSelection) { |
110 |
// dataset.getSeries(0).getDataItem(index); |
Comparable dataID = mapping.getDataID(fID); |
111 |
// |
if (dataID != null ) { |
112 |
// |
//TODO: Fallunterscheidung zwischen den unterschiedlichen DatasetSelectionModel-Typen!! |
113 |
// for (String fid : newSelection) { |
} else { |
114 |
// int modelIdx = featureTableModel.findFeature(fid); |
LOGGER.warn("Something that is not visible in the chart should be selected"); |
115 |
// if (modelIdx >= 0) { |
} |
116 |
// int tableIdx = featureTable.convertRowIndexToView(modelIdx); |
} |
|
// tableSelModel.addSelectionInterval(tableIdx, tableIdx); |
|
|
// } else { |
|
|
// LOGGER.warn("Something that is not visible in the Table should be selected"); |
|
|
// } |
|
|
// } |
|
117 |
datasetSelModel.setValueIsAdjusting(false); // event is fired autmatically! |
datasetSelModel.setValueIsAdjusting(false); // event is fired autmatically! |
118 |
|
|
119 |
// Danger of event circles in valueChanged(..) banned |
// Danger of event circles in valueChanged(..) banned |