Project

General

Profile

« Previous | Next » 

Revision 3a6e3f9e

Added by Patrick Plitzner almost 6 years ago

ref #7549 Show chart for quantitative values

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/QuantitativeChartTooltip.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10 10

  
11
import java.util.Arrays;
12

  
11 13
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
12 14
import org.eclipse.jface.window.DefaultToolTip;
13 15
import org.eclipse.jface.window.ToolTip;
16
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
17
import org.eclipse.swt.SWT;
14 18
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Composite;
15 22
import org.eclipse.swt.widgets.Event;
23
import org.swtchart.Chart;
24
import org.swtchart.IAxis;
25
import org.swtchart.ILineSeries;
26
import org.swtchart.ISeries.SeriesType;
27
import org.swtchart.LineStyle;
16 28

  
17 29
import eu.etaxonomy.cdm.model.description.Feature;
18 30

  
......
38 50
    }
39 51

  
40 52
    @Override
41
    protected String getText(Event event) {
53
    protected Composite createToolTipContentArea(Event event,
54
            Composite parent) {
55
        parent.setLayout(new GridLayout());
56

  
57
        Chart chart = new Chart(parent, SWT.NONE);
58
        chart.setLayoutData(new GridData(600, 300));
59

  
60
        //get statistics for column
42 61
        int colPos = matrix.getNatTable().getColumnPositionByX(event.x);
43 62
        int colIndex = matrix.getNatTable().getColumnIndexByPosition(colPos);
44 63
        Feature feature = matrix.getIndexToFeatureMap().get(colIndex);
45 64
        DescriptiveStatistics statistics = matrix.getFeatureToQuantStatisticsMap().get(feature);
65
        double[] ySeries = statistics.getValues();
66
        Arrays.sort(ySeries);
67

  
68
        // set chart title
69
        chart.getTitle().setText(feature.getLabel());
70

  
71
        // create exact/mean series
72
        ILineSeries meanExactSeries = (ILineSeries) chart.getSeriesSet()
73
                .createSeries(SeriesType.LINE, "exact/mean");
74
        meanExactSeries.setYSeries(ySeries);
75
        meanExactSeries.setLineStyle(LineStyle.NONE);
76
        meanExactSeries.setSymbolColor(GUIHelper.COLOR_BLUE);
77

  
78
        //TODO get min and max values
79
        // create min series
80
//        ILineSeries minSeries = (ILineSeries) chart.getSeriesSet()
81
//                .createSeries(SeriesType.LINE, "min");
82
//        double[] mins = { 0.3, 0.4, 0.3, 0.9, 1.1, 2.5, 2.6, 2.6};
83
//        minSeries.setYSeries(mins);
84
//        minSeries.setLineStyle(LineStyle.NONE);
85
//        minSeries.setSymbolType(PlotSymbolType.INVERTED_TRIANGLE);
86
//        minSeries.setSymbolColor(GUIHelper.COLOR_GREEN);
87
//
88
//        // create max series
89
//        ILineSeries maxSeries = (ILineSeries) chart.getSeriesSet()
90
//                .createSeries(SeriesType.LINE, "max");
91
//        double[] maxs = { 1.3, 2.4, 2.5, 2.6, 2.8, 3.6, 3.6, 3.8 };
92
//        maxSeries.setYSeries(maxs);
93
//        maxSeries.setLineStyle(LineStyle.NONE);
94
//        maxSeries.setSymbolType(PlotSymbolType.TRIANGLE);
95
//        maxSeries.setSymbolColor(GUIHelper.COLOR_RED);
96

  
97
        IAxis yAxis = chart.getAxisSet().getYAxis(0);
98
        yAxis.getTitle().setVisible(false);
99
        IAxis xAxis = chart.getAxisSet().getXAxis(0);
100
        xAxis.getTitle().setVisible(false);
101

  
102
        chart.getAxisSet().adjustRange();
46 103

  
47
        return statistics.toString();
104
        return chart;
48 105
    }
49 106

  
50 107
    @Override

Also available in: Unified diff