Button btnAggregate = new Button(this, SWT.PUSH);
btnAggregate.setText("Aggregate");
btnAggregate.addSelectionListener(new SelectionAdapter() {
- @SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
Set<TaxonNode> taxonSubtreeFilter = matrix.getDescriptiveDataSet().getTaxonSubtreeFilter();
//aggregate histogram for categorical tooltip
Map<Feature, CategoricalDataHistogram> featureToHistogramMap = matrix.getFeatureToHistogramMap();
featureToHistogramMap.clear();
- // matrix.getFeatures().forEach(feature->{
- matrix.getDescriptions()
- .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
- .filter(descriptionElement -> descriptionElement instanceof CategoricalData)
- .forEach(categoricalData -> {
- Feature feature = ((CategoricalData) categoricalData).getFeature();
- CategoricalDataHistogram dataHistogram = featureToHistogramMap.get(feature);
- if(dataHistogram==null){
- dataHistogram = new CategoricalDataHistogram(feature);
- }
- featureToHistogramMap.put(feature, dataHistogram);
- ((CategoricalData) categoricalData).getStateData()
- .forEach(stateData -> featureToHistogramMap.get(feature).addState(stateData.getState()));
- }));
+ aggregateCategorcialHistogram(featureToHistogramMap);
}
+
});
}
+
+ @SuppressWarnings("unchecked")
+ private void aggregateCategorcialHistogram(Map<Feature, CategoricalDataHistogram> featureToHistogramMap) {
+ matrix.getDescriptions()
+ .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
+ .filter(descriptionElement -> descriptionElement instanceof CategoricalData)
+ .forEach(categoricalData -> {
+ Feature feature = ((CategoricalData) categoricalData).getFeature();
+ CategoricalDataHistogram dataHistogram = featureToHistogramMap.get(feature);
+ if(dataHistogram==null){
+ dataHistogram = new CategoricalDataHistogram(feature);
+ }
+ featureToHistogramMap.put(feature, dataHistogram);
+ ((CategoricalData) categoricalData).getStateData()
+ .forEach(stateData -> featureToHistogramMap.get(feature).addState(stateData.getState()));
+ }));
+ }
+
private SpecimenDescription getDescriptionForDescriptiveDataSet(SpecimenOrObservationBase specimen){
Set<Feature> wsFeatures = matrix.getDescriptiveDataSet().getDescriptiveSystem().getDistinctFeatures();
List<DescriptionElementBase> matchingDescriptionElements = new ArrayList<>();