19 |
19 |
import org.txm.chartsengine.jfreechart.core.themes.base.SymbolAxisBetweenTicks;
|
20 |
20 |
import org.txm.specificities.core.functions.SpecificitiesSelection;
|
21 |
21 |
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
|
|
22 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
|
22 |
23 |
|
23 |
24 |
/**
|
24 |
25 |
* Creates a bar chart from the specified <code>SpecificitiesSelection</code> result.
|
... | ... | |
74 |
75 |
chart.setNotify(false);
|
75 |
76 |
|
76 |
77 |
|
77 |
|
// Fill the data set
|
78 |
|
XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset();
|
79 |
|
dataset.removeAllSeries();
|
80 |
|
String[] xAxisSymbols;
|
81 |
|
|
82 |
|
// Transpose the data set
|
83 |
|
if(specificitiesSelection.isGroupingByLines()) {
|
84 |
|
xAxisSymbols = new String[specificitiesSelection.getSelectedTypeNames().length];
|
85 |
|
|
86 |
|
for(int i = 0; i < specificitiesSelection.getSelectedPartNames().length; i++) {
|
87 |
|
XYSeries series = new XYSeries(specificitiesSelection.getSelectedPartNames()[i]);
|
88 |
|
dataset.addSeries(series);
|
89 |
|
|
90 |
|
for(int j = 0; j < specificitiesSelection.getSelectedTypeNames().length; j++) {
|
91 |
|
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[j][i]);
|
92 |
|
// Add X axis symbol
|
93 |
|
xAxisSymbols[j] = specificitiesSelection.getSelectedTypeNames()[j];
|
94 |
|
}
|
95 |
|
}
|
96 |
|
|
97 |
|
}
|
98 |
|
else {
|
99 |
|
xAxisSymbols = new String[specificitiesSelection.getSelectedPartNames().length];
|
100 |
|
|
101 |
|
for(int i = 0; i < specificitiesSelection.getSelectedTypeNames().length; i++) {
|
102 |
|
|
103 |
|
XYSeries series = new XYSeries(specificitiesSelection.getSelectedTypeNames()[i]);
|
104 |
|
dataset.addSeries(series);
|
105 |
|
|
106 |
|
for(int j = 0; j < specificitiesSelection.getSelectedPartNames().length; j++) {
|
107 |
|
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[i][j]);
|
108 |
|
// Add X axis symbol
|
109 |
|
xAxisSymbols[j] = specificitiesSelection.getSelectedPartNames()[j];
|
110 |
|
}
|
111 |
|
}
|
112 |
|
}
|
113 |
|
|
114 |
78 |
// removes all existing range marker
|
115 |
79 |
chart.getXYPlot().clearRangeMarkers();
|
116 |
80 |
|
... | ... | |
132 |
96 |
chart.getXYPlot().addRangeMarker(marker);
|
133 |
97 |
|
134 |
98 |
|
135 |
|
|
136 |
|
// Custom range axis for ticks drawing options
|
137 |
|
double minimumValue = DatasetUtilities.findMinimumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
|
138 |
|
double maximumValue = DatasetUtilities.findMaximumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
|
139 |
|
// Adjust ticks values according to data set contains only positives values or only negatives values
|
140 |
|
if(minimumValue > 0) {
|
141 |
|
minimumValue = 0;
|
|
99 |
// Transpose or not / group by lines or not
|
|
100 |
if(result.hasRenderingParameterChanged(SpecificitiesPreferences.CHART_TRANSPOSE)) {
|
|
101 |
|
|
102 |
// Fill the data set
|
|
103 |
XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset();
|
|
104 |
dataset.removeAllSeries();
|
|
105 |
String[] xAxisSymbols;
|
|
106 |
|
|
107 |
// Transpose the data set
|
|
108 |
if(specificitiesSelection.isGroupingByLines()) {
|
|
109 |
xAxisSymbols = new String[specificitiesSelection.getSelectedTypeNames().length];
|
|
110 |
|
|
111 |
for(int i = 0; i < specificitiesSelection.getSelectedPartNames().length; i++) {
|
|
112 |
XYSeries series = new XYSeries(specificitiesSelection.getSelectedPartNames()[i]);
|
|
113 |
dataset.addSeries(series);
|
|
114 |
|
|
115 |
for(int j = 0; j < specificitiesSelection.getSelectedTypeNames().length; j++) {
|
|
116 |
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[j][i]);
|
|
117 |
// Add X axis symbol
|
|
118 |
xAxisSymbols[j] = specificitiesSelection.getSelectedTypeNames()[j];
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
}
|
|
123 |
else {
|
|
124 |
xAxisSymbols = new String[specificitiesSelection.getSelectedPartNames().length];
|
|
125 |
|
|
126 |
for(int i = 0; i < specificitiesSelection.getSelectedTypeNames().length; i++) {
|
|
127 |
|
|
128 |
XYSeries series = new XYSeries(specificitiesSelection.getSelectedTypeNames()[i]);
|
|
129 |
dataset.addSeries(series);
|
|
130 |
|
|
131 |
for(int j = 0; j < specificitiesSelection.getSelectedPartNames().length; j++) {
|
|
132 |
series.add(j, specificitiesSelection.getSelectedSpecificitiesIndex()[i][j]);
|
|
133 |
// Add X axis symbol
|
|
134 |
xAxisSymbols[j] = specificitiesSelection.getSelectedPartNames()[j];
|
|
135 |
}
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
// Custom range axis for ticks drawing options
|
|
142 |
double minimumValue = DatasetUtilities.findMinimumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
|
|
143 |
double maximumValue = DatasetUtilities.findMaximumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
|
|
144 |
// Adjust ticks values according to data set contains only positives values or only negatives values
|
|
145 |
if(minimumValue > 0) {
|
|
146 |
minimumValue = 0;
|
|
147 |
}
|
|
148 |
if(maximumValue < 0) {
|
|
149 |
maximumValue = specificitiesSelection.getBanality();
|
|
150 |
}
|
|
151 |
// Custom range axis to cut the values to minimum and maximum values
|
|
152 |
chart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
|
|
153 |
|
|
154 |
chart.getXYPlot().setDomainAxis(new SymbolAxisBetweenTicks(SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, xAxisSymbols));
|
142 |
155 |
}
|
143 |
|
if(maximumValue < 0) {
|
144 |
|
maximumValue = specificitiesSelection.getBanality();
|
145 |
|
}
|
146 |
|
// Custom range axis to cut the values to minimum and maximum values
|
147 |
|
chart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
|
148 |
|
|
149 |
|
chart.getXYPlot().setDomainAxis(new SymbolAxisBetweenTicks(SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, xAxisSymbols));
|
150 |
|
|
151 |
156 |
|
152 |
157 |
super.updateChart(result);
|
153 |
158 |
|