From: Patrick Plitzner Date: Fri, 13 Jul 2018 08:20:39 +0000 (+0200) Subject: ref #7549 Refactoring X-Git-Tag: 5.2.0^2~90 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/bd5a558a0b224e21a4cc84c775cda21abafc8190 ref #7549 Refactoring --- diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java index 3069e41c6..a93003071 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java @@ -130,7 +130,6 @@ public class CharacterMatrixBottomToolbar extends Composite{ Button btnAggregate = new Button(this, SWT.PUSH); btnAggregate.setText("Aggregate"); btnAggregate.addSelectionListener(new SelectionAdapter() { - @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { Set taxonSubtreeFilter = matrix.getDescriptiveDataSet().getTaxonSubtreeFilter(); @@ -161,23 +160,29 @@ public class CharacterMatrixBottomToolbar extends Composite{ //aggregate histogram for categorical tooltip Map 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 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 wsFeatures = matrix.getDescriptiveDataSet().getDescriptiveSystem().getDistinctFeatures(); List matchingDescriptionElements = new ArrayList<>();