+++ /dev/null
-/**
-* Copyright (C) 2018 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
-
-import java.util.List;
-
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.swtchart.Chart;
-import org.swtchart.IAxis;
-import org.swtchart.IBarSeries;
-import org.swtchart.ISeries.SeriesType;
-import org.swtchart.ISeriesLabel;
-
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.State;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-
-/**
- * @author pplitzner
- * @since Jul 6, 2018
- *
- */
-public class CategoricalChartTooltip extends ToolTip {
-
- static final String TOOLTIP_NOT_AVAILABLE = Messages.CategoricalChartTooltip_TOOLTIP_NOT_AVAILABLE;
-
- private CharacterMatrix matrix;
-
- public CategoricalChartTooltip(CharacterMatrix matrix) {
- super(matrix.getNatTable(), ToolTip.NO_RECREATE, false);
- this.matrix = matrix;
- }
-
- @Override
- protected Object getToolTipArea(Event event) {
- int col = matrix.getNatTable().getColumnPositionByX(event.x);
- int row = matrix.getNatTable().getRowPositionByY(event.y);
- return new Point(col, row);
- }
-
- @Override
- protected Composite createToolTipContentArea(Event event,
- Composite parent) {
-
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
- CategoricalDataHistogram histogram = matrix.getFeatureToHistogramMap().get(feature);
-
- Composite tooltip;
- if(histogram!=null && !histogram.getStates().isEmpty()){
- parent.setLayout(new GridLayout());
- tooltip = createTooltip(event, parent);
- }
- else{
- tooltip = new Composite(parent, SWT.NONE);
- tooltip.setLayout(new FillLayout());
- Label label = new Label(tooltip, SWT.NONE);
- label.setText(TOOLTIP_NOT_AVAILABLE);
- }
- return tooltip;
- }
-
- private Composite createTooltip(Event event, Composite parent) {
- Chart chart = new Chart(parent, SWT.NONE);
- chart.setLayoutData(new GridData(600, 300));
-
- //get histogram for column
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
- CategoricalDataHistogram histogram = matrix.getFeatureToHistogramMap().get(feature);
-
- // set chart title
- chart.getTitle().setText(feature.getLabel());
- IAxis xAxis = chart.getAxisSet().getXAxis(0);
-
- //initalize x and y axis values
- List<State> statesList = histogram.getStates();
- String[] states = new String[statesList.size()];
- double[] counts = new double[statesList.size()];
-
- int index = 0;
- for (State state : statesList) {
- states[index] = state.getLabel();
- counts[index] = histogram.getCount(state);
- index++;
- }
- xAxis.setCategorySeries(states);
- xAxis.enableCategory(true);
- xAxis.getTitle().setVisible(false);
- xAxis.getTick().setTickLabelAngle(25);
-
- IAxis yAxis = chart.getAxisSet().getYAxis(0);
- yAxis.getTitle().setVisible(false);
-
- chart.getLegend().setVisible(false);
-
- IBarSeries barSeries = (IBarSeries) chart.getSeriesSet()
- .createSeries(SeriesType.BAR, "state counts"); //$NON-NLS-1$
- ISeriesLabel seriesLabel = barSeries.getLabel();
- seriesLabel.setVisible(true);
- barSeries.setYSeries(counts);
-
- chart.getAxisSet().adjustRange();
-
- return chart;
- }
-
- @Override
- protected boolean shouldCreateToolTip(Event event) {
- //Differentiation between "index" and "position" is important here
- //"position" is the current visible index
- //"index" refers to the underlying data model
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- int rowPos = matrix.getNatTable().getRowPositionByY(event.y);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
-
- if(matrix.isShowTooltips()
- && rowPos==1
- && colIndex>=CharacterMatrix.LEADING_COLUMN_COUNT
- && feature!=null
- && feature.isSupportsCategoricalData()) {
- return true;
- }
- return false;
- }
-
-}
private CharacterMatrixToolbar toolbar;
- private boolean isShowTooltips = true;
-
private DescriptionTreeFormat treeFormat;
public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
return featureToQuantDataStatisticsMap;
}
- public void toogleIsShowTooltips() {
- this.isShowTooltips = !this.isShowTooltips;
- }
-
- public boolean isShowTooltips() {
- return isShowTooltips;
- }
-
public ICdmEntitySession getCdmEntitiySession(){
return part.getCdmEntitySession();
}
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.eclipse.core.runtime.ICoreRunnable;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase.AggregationMode;
import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregationConfiguration;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
-import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
-import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
return;
}
aggregatDescriptiveDataSet(matrix.getDescriptiveDataSet().getUuid());
-
-// aggregateCharts();
}
});
if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES)){
}
- private void aggregateCharts() {
- new Job("aggregate charts") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- aggregateCategorcialHistogram(matrix.getFeatureToHistogramMap());
- aggregateQuantitativeSummary(matrix.getFeatureToQuantDataStatisticsMap());
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- @SuppressWarnings("unchecked")
- private void aggregateCategorcialHistogram(Map<Feature, CategoricalDataHistogram> featureToHistogramMap) {
- featureToHistogramMap.clear();
- matrix.getDescriptions().stream()
- .filter(desc->desc instanceof SpecimenRowWrapperDTO)
- .forEach(o -> ((SpecimenRowWrapperDTO) o).getDescription().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()));
- }));
- }
-
- @SuppressWarnings("unchecked")
- private void aggregateQuantitativeSummary(Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap) {
- featureToQuantDataStatisticsMap.clear();
- matrix.getDescriptions().stream()
- .filter(desc->desc instanceof SpecimenRowWrapperDTO)
- .forEach(o -> ((SpecimenRowWrapperDTO) o).getDescription().getElements().stream()
- .filter(descriptionElement -> descriptionElement instanceof QuantitativeData)
- .forEach(quantData -> {
- Feature feature = ((QuantitativeData) quantData).getFeature();
- QuantitativeDataStatistics dataStatistics = featureToQuantDataStatisticsMap.get(feature);
- if(dataStatistics==null){
- dataStatistics = new QuantitativeDataStatistics();
- }
- featureToQuantDataStatisticsMap.put(feature, dataStatistics);
- dataStatistics.addQuantitativeData((QuantitativeData) quantData);
- }));
- }
-
}
wsLabel = new Label(this, SWT.NONE);
- Button btnToggleTooltips = new Button(this, SWT.TOGGLE);
Button btnToggleTree = new Button(this, SWT.PUSH);
Button btnToggleFlat = new Button(this, SWT.PUSH);
Button btnCollapseAll = new Button(this, SWT.PUSH);
Button btnManageState = new Button(this, SWT.PUSH);
Button btnExcelExport = new Button(this, SWT.PUSH);
- /**
- * Toggle tooltips button
- */
- initButton(
- btnToggleTooltips,
- ImageResources.getImage(ImageResources.LIGHT_BULB),
- "Show tooltips",
- null,
- true,
- true,
- (e)->matrix.toogleIsShowTooltips()
- );
/**
* Toogle tree button
*/
+++ /dev/null
-/**
-* Copyright (C) 2018 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
-
-import java.util.List;
-
-import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
-import org.eclipse.jface.window.DefaultToolTip;
-import org.eclipse.jface.window.ToolTip;
-import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.swtchart.Chart;
-import org.swtchart.IAxis;
-import org.swtchart.ILineSeries;
-import org.swtchart.ILineSeries.PlotSymbolType;
-import org.swtchart.ISeries.SeriesType;
-import org.swtchart.LineStyle;
-
-import eu.etaxonomy.cdm.model.description.Feature;
-
-/**
- * @author pplitzner
- * @since Jul 6, 2018
- *
- */
-public class QuantitativeChartTooltip extends DefaultToolTip {
-
- private CharacterMatrix matrix;
-
- public QuantitativeChartTooltip(CharacterMatrix matrix) {
- super(matrix.getNatTable(), ToolTip.NO_RECREATE, false);
- this.matrix = matrix;
- }
-
- @Override
- protected Object getToolTipArea(Event event) {
- int col = matrix.getNatTable().getColumnPositionByX(event.x);
- int row = matrix.getNatTable().getRowPositionByY(event.y);
- return new Point(col, row);
- }
-
- @Override
- protected Composite createToolTipContentArea(Event event,
- Composite parent) {
-
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
- QuantitativeDataStatistics dataStatistics = matrix.getFeatureToQuantDataStatisticsMap().get(feature);
-
- Composite tooltip;
- if(dataStatistics!=null){
- parent.setLayout(new GridLayout());
- tooltip = createTooltip(event, parent);
- }
- else{
- tooltip = new Composite(parent, SWT.NONE);
- tooltip.setLayout(new FillLayout());
- Label label = new Label(tooltip, SWT.NONE);
- label.setText(CategoricalChartTooltip.TOOLTIP_NOT_AVAILABLE);
- }
- return tooltip;
-
- }
-
- private Composite createTooltip(Event event, Composite parent){
- Chart chart = new Chart(parent, SWT.NONE);
- chart.setLayoutData(new GridData(600, 300));
-
- //get statistics for column
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
- QuantitativeDataStatistics quantitativeDataStatistics = matrix.getFeatureToQuantDataStatisticsMap().get(feature);
- List<DescriptiveStatistics> statistics = quantitativeDataStatistics.getStatistics();
-
- //prepare series
- double[] exactMean = statistics.stream().mapToDouble(statistic->statistic.getMean()).toArray();
- double[] mins = statistics.stream().mapToDouble(statistic->statistic.getMin()).toArray();
- double[] maxs = statistics.stream().mapToDouble(statistic->statistic.getMax()).toArray();
-
- // set chart title
- chart.getTitle().setText(feature.getLabel());
-
- // create exact/mean series
- ILineSeries meanExactSeries = (ILineSeries) chart.getSeriesSet()
- .createSeries(SeriesType.LINE, "exact/mean");
- meanExactSeries.setYSeries(exactMean);
- meanExactSeries.setLineStyle(LineStyle.NONE);
- meanExactSeries.setSymbolColor(GUIHelper.COLOR_BLUE);
-
- // create min series
- ILineSeries minSeries = (ILineSeries) chart.getSeriesSet()
- .createSeries(SeriesType.LINE, "min");
- minSeries.setYSeries(mins);
- minSeries.setLineStyle(LineStyle.NONE);
- minSeries.setSymbolType(PlotSymbolType.INVERTED_TRIANGLE);
- minSeries.setSymbolColor(GUIHelper.COLOR_GREEN);
-
- // create max series
- ILineSeries maxSeries = (ILineSeries) chart.getSeriesSet()
- .createSeries(SeriesType.LINE, "max");
- maxSeries.setYSeries(maxs);
- maxSeries.setLineStyle(LineStyle.NONE);
- maxSeries.setSymbolType(PlotSymbolType.TRIANGLE);
- maxSeries.setSymbolColor(GUIHelper.COLOR_RED);
-
- IAxis yAxis = chart.getAxisSet().getYAxis(0);
- yAxis.getTitle().setVisible(false);
- IAxis xAxis = chart.getAxisSet().getXAxis(0);
- xAxis.getTitle().setVisible(false);
-
- chart.getAxisSet().adjustRange();
-
- return chart;
- }
-
- @Override
- protected boolean shouldCreateToolTip(Event event) {
- //Differentiation between "index" and "position" is important here
- //"position" is the current visible index
- //"index" refers to the underlying data model
- int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
- int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
- int rowPos = matrix.getNatTable().getRowPositionByY(event.y);
- Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
-
- if(matrix.isShowTooltips()
- && rowPos==1
- && feature!=null
- && feature.isSupportsQuantitativeData()
- && colIndex>=CharacterMatrix.LEADING_COLUMN_COUNT) {
- return true;
- }
- return false;
- }
-
-}