Révision 114
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/swt/JFCComposite.java (revision 114) | ||
---|---|---|
1 |
package org.txm.chartsengine.jfreechart.rcp.swt; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.EventQueue; |
|
5 |
import java.awt.Frame; |
|
6 |
import java.awt.Panel; |
|
7 |
import java.util.EventListener; |
|
8 |
|
|
9 |
import org.eclipse.swt.SWT; |
|
10 |
import org.eclipse.swt.awt.SWT_AWT; |
|
11 |
import org.eclipse.swt.widgets.Composite; |
|
12 |
import org.jfree.chart.ChartMouseListener; |
|
13 |
import org.jfree.chart.ChartPanel; |
|
14 |
import org.jfree.chart.JFreeChart; |
|
15 |
import org.jfree.chart.plot.XYPlot; |
|
16 |
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.FCAItemSelectionRenderer; |
|
17 |
import org.txm.chartsengine.jfreechart.rcp.themes.base.swing.ItemSelectionChartPanel; |
|
18 |
import org.txm.chartsengine.rcp.IChartComponent; |
|
19 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
20 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
|
21 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
|
22 |
|
|
23 |
/** |
|
24 |
* JFreeChart SWT composite. |
|
25 |
* @author sjacquot |
|
26 |
* |
|
27 |
*/ |
|
28 |
public class JFCComposite extends ChartComposite { |
|
29 |
|
|
30 |
|
|
31 |
// For reducing resize flickering on Windows |
|
32 |
static { |
|
33 |
try { |
|
34 |
System.setProperty("sun.awt.noerasebackground", "true"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
35 |
} |
|
36 |
catch (NoSuchMethodError error) { |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
/** |
|
44 |
* Creates a JFreeChart composite. |
|
45 |
* @param parent |
|
46 |
* @param panel |
|
47 |
*/ |
|
48 |
public JFCComposite(ChartEditorPart chartEditor, Composite parent, ChartPanel panel) { |
|
49 |
super(chartEditor, parent, SWT.EMBEDDED | SWT.NO_BACKGROUND); |
|
50 |
//super(parent, SWT.EMBEDDED | SWT.NO_MERGE_PAINTS | SWT.NO_BACKGROUND); // do not fix the transparency problem |
|
51 |
|
|
52 |
this.chartComponent = (IChartComponent) panel; |
|
53 |
|
|
54 |
// FIXME : transparency doesn't work with tool tips |
|
55 |
// The problem here is that we normally need a JFrame but it seems to be impossible to embed a JFrame |
|
56 |
// this.setBackgroundMode(SWT.INHERIT_FORCE); // do not fix |
|
57 |
// panel.setOpaque(false); // do not fix |
|
58 |
// ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); // do not fix |
|
59 |
|
|
60 |
final Frame frame = SWT_AWT.new_Frame(this); |
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
// To fix MAC OS X + Java 1.7/1.8 SWT_AWT BUG |
|
65 |
// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418245#c12 |
|
66 |
// SwingUtilities.invokeLater(new Runnable() { |
|
67 |
// |
|
68 |
// |
|
69 |
// @Override |
|
70 |
// public void run() { |
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
// Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel |
|
76 |
Panel rootPanel = new Panel(new BorderLayout()); |
|
77 |
rootPanel.add(this.getChartPanel()); // commenter cette ligne pour le test de scrolling ci-dessous |
|
78 |
frame.add(rootPanel); |
|
79 |
|
|
80 |
|
|
81 |
// FIXME: test, smarter way to embed the frame ? Actually it doesn't fix neither the tooltip transparency nor the cursor change on pan under Mac OS X |
|
82 |
// // Need to add an AWT Panel to fix mouse events and mouse cursors changes on Swing JPanel |
|
83 |
// Panel rootPanel = new Panel(new BorderLayout()); |
|
84 |
//// rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous |
|
85 |
// frame.add(rootPanel); |
|
86 |
// JRootPane rootPane = new JRootPane(); |
|
87 |
// rootPanel.add(rootPane); |
|
88 |
// rootPane.getContentPane().add(this.chartPanel); |
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
// FIXME: tests with a JApplet as Rootpane rather than Panel |
|
93 |
// JApplet rootPanel = new JApplet(); |
|
94 |
// rootPanel.add(this.chartPanel); // commenter cette ligne pour le test de scrolling ci-dessous |
|
95 |
// frame.add(rootPanel); |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
// FIXME : tests scroll Swing: les width des panel sont définies dans les méthodes de JFCChartsSwingComponentsProvider |
|
101 |
// FIXME : ce code fait bugger le changement de couleur des barres au mouse over et la bordure colorée des tooltips |
|
102 |
// FIXME : ce code augmente à fond la RAM consommée, il y a un prob de composants en double ? |
|
103 |
// En fait c'est un problème Java2D apparemment et qui semble "normal" |
|
104 |
//panel.setPreferredSize(new Dimension(20000, 300)); |
|
105 |
// JScrollPane scrollpane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
106 |
// frame.add(scrollpane); |
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
// FIXME : version AWT |
|
111 |
// FIXME : ce code aussi n'augmente pas la RAM consommée ? à moins que ce soit uniquement quand la largeur du panel est large (bug de JFC sur les larges plots ?) |
|
112 |
// ScrollPane scrollpane = new ScrollPane(); |
|
113 |
// scrollpane.add(panel); |
|
114 |
// frame.add(scrollpane); |
|
115 |
|
|
116 |
//frame.pack(); |
|
117 |
|
|
118 |
|
|
119 |
// FIXME : test scroll SWT : fonctionne presque |
|
120 |
// ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); |
|
121 |
// scrolledComposite.setExpandHorizontal(true); |
|
122 |
// scrolledComposite.setExpandVertical(true); |
|
123 |
// //parent.setLayout(new GridLayout(1, true)); |
|
124 |
// parent.setLayout(new FillLayout(SWT.VERTICAL)); |
|
125 |
// //parent.setLayout(new FormLayout()); |
|
126 |
// this.setParent(scrolledComposite); |
|
127 |
// //this.setLayout(new FillLayout()); |
|
128 |
// |
|
129 |
// scrolledComposite.setContent(this); |
|
130 |
// scrolledComposite.setAlwaysShowScrollBars(true); |
|
131 |
// |
|
132 |
// scrolledComposite.setMinSize(16000, 0); |
|
133 |
// ********** Fin test 1 |
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
// FIXME : test scroll SWT |
|
138 |
// ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); |
|
139 |
// scrolledComposite.setExpandHorizontal(true); |
|
140 |
// scrolledComposite.setExpandVertical(true); |
|
141 |
// //parent.setLayout(new GridLayout(1, true)); |
|
142 |
// parent.setLayout(new FormLayout()); |
|
143 |
// this.setParent(scrolledComposite); |
|
144 |
// this.setLayout(new FillLayout()); |
|
145 |
// |
|
146 |
// scrolledComposite.setContent(this); |
|
147 |
// scrolledComposite.setAlwaysShowScrollBars(true); |
|
148 |
// |
|
149 |
// scrolledComposite.setMinSize(16000, 500); |
|
150 |
// |
|
151 |
// this.setSize(16000, 500); |
|
152 |
|
|
153 |
|
|
154 |
//scrolledComposite.pack(true); |
|
155 |
//scrolledComposite.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
|
156 |
|
|
157 |
// frame.pack(); |
|
158 |
// System.err.println("JFCComposite.JFCComposite() frame: " + frame.getWidth() + " - " + frame.getHeight()); |
|
159 |
|
|
160 |
//scrolledComposite.setMinSize(new Point(2000, 500)); |
|
161 |
//frame.setSize(2000, 500); |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
// Test tool tips transparency : do not fix transparency and create error |
|
166 |
// JFrame jFrame = new JFrame(); |
|
167 |
// //jFrame.setContentPane(panel); |
|
168 |
// jFrame.add(panel); |
|
169 |
// frame.add(jFrame); |
|
170 |
|
|
171 |
|
|
172 |
// FIXME: tests fix bug "Reset view" + Java 6 focus bugs |
|
173 |
// this.chartPanel.addFocusListener(new FocusListener() { |
|
174 |
// |
|
175 |
// @Override |
|
176 |
// public void focusLost(FocusEvent e) { |
|
177 |
// // TODO Auto-generated method stub |
|
178 |
// System.err.println("JFCComposite.JFCComposite(...).new FocusListener() {...}.focusLost() chart panel"); |
|
179 |
// } |
|
180 |
// |
|
181 |
// @Override |
|
182 |
// public void focusGained(FocusEvent e) { |
|
183 |
// // TODO Auto-generated method stub |
|
184 |
// System.err.println("JFCComposite.JFCComposite(...).new FocusListener() {...}.focusGained() chart panel"); |
|
185 |
// } |
|
186 |
// }); |
|
187 |
|
|
188 |
|
|
189 |
// FIXME : axis unit square ratio tests |
|
190 |
// this.addListener(SWT.Resize, new Listener() { |
|
191 |
// |
|
192 |
// @Override |
|
193 |
// public void handleEvent(Event e) { |
|
194 |
// switch (e.type) { |
|
195 |
// case SWT.Resize: |
|
196 |
// System.err.println("ChartComposite.ChartComposite(...).new Listener() {...}.handleEvent()"); |
|
197 |
// resetView(); |
|
198 |
// break; |
|
199 |
// } |
|
200 |
// |
|
201 |
// } |
|
202 |
// }); |
|
203 |
|
|
204 |
|
|
205 |
frame.setVisible(true); |
|
206 |
//parent.pack(); |
|
207 |
|
|
208 |
// } |
|
209 |
// }); |
|
210 |
|
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
@Override |
|
216 |
public void requestFocusInComposite() { |
|
217 |
EventQueue.invokeLater(new Runnable () { |
|
218 |
public void run () { |
|
219 |
getChartPanel().requestFocusInWindow(); |
|
220 |
} |
|
221 |
}); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* Gets the chart. |
|
226 |
* @return the chart |
|
227 |
*/ |
|
228 |
public JFreeChart getChart() { |
|
229 |
return this.getChartPanel().getChart(); |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* @return the chartPanel |
|
234 |
*/ |
|
235 |
public ChartPanel getChartPanel() { |
|
236 |
return (ChartPanel) this.chartComponent; |
|
237 |
} |
|
238 |
|
|
239 |
@Override |
|
240 |
public void loadChart(Object data) { |
|
241 |
|
|
242 |
this.getChartPanel().setChart((JFreeChart) data); |
|
243 |
|
|
244 |
// FIXME: Initialize the item selection listeners |
|
245 |
// if(this.chartPanel instanceof ItemSelectionChartPanel) { |
|
246 |
// ((ItemSelectionChartPanel) this.chartPanel).initItemSelectionListeners(); |
|
247 |
// } |
|
248 |
} |
|
249 |
|
|
250 |
@Override |
|
251 |
public void reloadChart() { |
|
252 |
|
|
253 |
// Get a new chart from the editor input |
|
254 |
this.loadChart(((ChartPanel)this.chartEditor.getEditorInput().getChartContainer()).getChart()); |
|
255 |
|
|
256 |
|
|
257 |
// FIXME: Unit axis ratio constraint for FCA chart |
|
258 |
if(this.getChartPanel().getChart().getPlot() instanceof XYPlot |
|
259 |
&& this.getChartPanel().getChart().getXYPlot().getRenderer() instanceof FCAItemSelectionRenderer) { |
|
260 |
((ItemSelectionChartPanel) this.getChartPanel()).squareOffGraph(); |
|
261 |
} |
|
262 |
|
|
263 |
this.forceFocus(); |
|
264 |
} |
|
265 |
|
|
266 |
|
|
267 |
/** |
|
268 |
* Gets the event call back handler of the specified class. |
|
269 |
* @param listenerType |
|
270 |
* @return |
|
271 |
*/ |
|
272 |
public EventCallBackHandler getCallBackHandler(Class listenerType) { |
|
273 |
EventCallBackHandler handler = null; |
|
274 |
EventListener[] listeners = this.getChartPanel().getListeners(listenerType); |
|
275 |
|
|
276 |
for(int i = 0; i < listeners.length; i++) { |
|
277 |
if(listeners[i] instanceof EventCallBackHandler) { |
|
278 |
handler = (EventCallBackHandler) listeners[i]; |
|
279 |
break; |
|
280 |
} |
|
281 |
} |
|
282 |
return handler; |
|
283 |
} |
|
284 |
|
|
285 |
@Override |
|
286 |
public EventCallBackHandler getMouseCallBackHandler() { |
|
287 |
return this.getCallBackHandler(ChartMouseListener.class); |
|
288 |
} |
|
289 |
|
|
290 |
|
|
291 |
@Override |
|
292 |
public EventCallBackHandler getKeyCallBackHandler() { |
|
293 |
return super.getKeyCallBackHandler(this.getChartPanel()); |
|
294 |
} |
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
} |
|
0 | 300 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/JFCChartsSwingComponentsProvider.java (revision 114) | ||
---|---|---|
1 |
package org.txm.chartsengine.jfreechart.rcp; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import org.jfree.chart.ChartPanel; |
|
6 |
import org.jfree.chart.JFreeChart; |
|
7 |
import org.jfree.chart.LegendItemSource; |
|
8 |
import org.jfree.chart.axis.NumberAxis; |
|
9 |
import org.jfree.chart.plot.CategoryPlot; |
|
10 |
import org.jfree.chart.plot.Marker; |
|
11 |
import org.jfree.chart.plot.Plot; |
|
12 |
import org.jfree.chart.plot.ValueMarker; |
|
13 |
import org.jfree.chart.plot.XYPlot; |
|
14 |
import org.jfree.data.category.DefaultCategoryDataset; |
|
15 |
import org.jfree.data.general.DatasetUtilities; |
|
16 |
import org.jfree.data.xy.XYIntervalSeries; |
|
17 |
import org.jfree.data.xy.XYIntervalSeriesCollection; |
|
18 |
import org.jfree.data.xy.XYSeries; |
|
19 |
import org.jfree.data.xy.XYSeriesCollection; |
|
20 |
import org.jfree.ui.RectangleAnchor; |
|
21 |
import org.jfree.ui.TextAnchor; |
|
22 |
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine; |
|
23 |
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis; |
|
24 |
import org.txm.chartsengine.jfreechart.core.themes.base.Theme; |
|
25 |
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.FCAItemSelectionRenderer; |
|
26 |
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.ItemSelectionCategoryLineAndShapeRenderer; |
|
27 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
28 |
import org.txm.functions.ca.CA; |
|
29 |
import org.txm.functions.classification.CAH; |
|
30 |
import org.txm.functions.specificities.SpecificitesResult; |
|
31 |
|
|
32 |
/** |
|
33 |
* Swing components provider. |
|
34 |
* @author sjacquot |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class JFCChartsSwingComponentsProvider { |
|
38 |
|
|
39 |
/** |
|
40 |
* The chart production engine. |
|
41 |
*/ |
|
42 |
protected JFCChartsEngine chartsEngine; |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* The linked SWT Charts Component Provider. |
|
47 |
*/ |
|
48 |
protected SWTChartsComponentsProvider swtChartsComponentProvider; |
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* @param chartsEngine |
|
54 |
*/ |
|
55 |
public JFCChartsSwingComponentsProvider(SWTChartsComponentsProvider swtChartsComponentProvider, JFCChartsEngine chartsEngine) { |
|
56 |
this.swtChartsComponentProvider = swtChartsComponentProvider; |
|
57 |
this.chartsEngine = chartsEngine; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* |
|
64 |
* @param useSplines |
|
65 |
* @return |
|
66 |
*/ |
|
67 |
// FIXME : test method |
|
68 |
public ChartPanel ___createXYLinesChartPanel(boolean useSplines) { |
|
69 |
return this.___createXYLinesChartPanel(useSplines, true, true); |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
/** |
|
74 |
* |
|
75 |
* @param useSplines |
|
76 |
* @param linesVisible |
|
77 |
* @param shapesVisible |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
// FIXME : test method |
|
81 |
public ChartPanel ___createXYLinesChartPanel(boolean useSplines, boolean linesVisible, boolean shapesVisible) { |
|
82 |
|
|
83 |
ChartPanel chartPanel; |
|
84 |
|
|
85 |
|
|
86 |
// Jeu de données factice |
|
87 |
XYSeries series1 = new XYSeries("faire"); //$NON-NLS-1$ |
|
88 |
series1.add(0.0, 0.2); series1.add(1.0, 0.8); series1.add(2.0, 1.2); series1.add(3.0, 1.9); |
|
89 |
series1.add(4.0, 1.9); series1.add(5.0, 2.4); series1.add(6.0, 2.9); |
|
90 |
|
|
91 |
XYSeries series2 = new XYSeries("voir"); //$NON-NLS-1$ |
|
92 |
series2.add(1.0, 5.0); series2.add(2.0, 7.0); series2.add(3.0, 6.0); series2.add(4.0, 8.0); series2.add(5.0, 4.0); series2.add(6.0, 4.0); |
|
93 |
|
|
94 |
XYSeries series3 = new XYSeries("avoir"); //$NON-NLS-1$ |
|
95 |
series3.add(1.0, 2.0); series3.add(2.0, 3.5); series3.add(3.0, 3.2); series3.add(4.0, 4.5); series3.add(5.0, 1.2); series3.add(6.0, 3); |
|
96 |
|
|
97 |
XYSeries series4 = new XYSeries("être"); //$NON-NLS-1$ |
|
98 |
series4.add(1.0, 4.2); series4.add(2.0, 5); series4.add(3.0, 5.5); series4.add(4.0, 2.2); series4.add(5.0, 4.8); series4.add(6.0, 6.2); |
|
99 |
|
|
100 |
XYSeriesCollection dataset = new XYSeriesCollection(); |
|
101 |
dataset.addSeries(series1); dataset.addSeries(series2); dataset.addSeries(series3); dataset.addSeries(series4); |
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
// Creating the chart from the current charts engine |
|
106 |
JFreeChart chart = this.chartsEngine.createXYLineChart(dataset, "test", "x label", "y label", true, useSplines, linesVisible, shapesVisible); |
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
112 |
|
|
113 |
return chartPanel; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* |
|
118 |
* @return |
|
119 |
*/ |
|
120 |
// FIXME : test method |
|
121 |
public ChartPanel ___createXYDimensionsBarChartPanel() { |
|
122 |
|
|
123 |
ChartPanel chartPanel; |
|
124 |
|
|
125 |
|
|
126 |
// Jeu de données factice |
|
127 |
XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); |
|
128 |
|
|
129 |
XYIntervalSeries series1 = new XYIntervalSeries("faire"); //$NON-NLS-1$ |
|
130 |
series1.add(0.5, 0.0, 0.2, 0.9, 0.0, 1); |
|
131 |
|
|
132 |
dataset.addSeries(series1); |
|
133 |
|
|
134 |
|
|
135 |
// Creating the chart from the current charts engine |
|
136 |
JFreeChart chart = this.chartsEngine.createXYBarChart(dataset, "Dimensions of partition \"P\" in corpus \"C\"", "Part", "Number of words per part", false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
141 |
|
|
142 |
return chartPanel; |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
/** |
|
148 |
* |
|
149 |
* @return |
|
150 |
*/ |
|
151 |
// FIXME : test method |
|
152 |
public ChartPanel ___createCategoryLinesChartPanel() { |
|
153 |
|
|
154 |
ChartPanel chartPanel; |
|
155 |
|
|
156 |
|
|
157 |
// Jeu de données factice |
|
158 |
// row keys |
|
159 |
final String series1 = "faire"; final String series2 = "voir"; final String series3 = "être"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
160 |
|
|
161 |
// column keys |
|
162 |
final String type1 = "années 20"; final String type2 = "années 30"; final String type3 = "années 40"; final String type4 = "années 50"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
163 |
final String type5 = "années 60"; final String type6 = "années 70"; final String type7 = "années 80"; final String type8 = "années 90"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
164 |
|
|
165 |
// create the dataset |
|
166 |
final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
|
167 |
|
|
168 |
dataset.addValue(0.5, series1, type1); dataset.addValue(-0.85, series1, type2); dataset.addValue(0.1, series1, type3); dataset.addValue(0.4, series1, type4); |
|
169 |
dataset.addValue(-0.2, series1, type5); dataset.addValue(-0.3, series1, type6); dataset.addValue(0.48, series1, type7); dataset.addValue(0.56, series1, type8); |
|
170 |
|
|
171 |
dataset.addValue(0.25, series2, type1); dataset.addValue(0.29, series2, type2); dataset.addValue(-0.12, series2, type3); dataset.addValue(0.56, series2, type4); |
|
172 |
dataset.addValue(-0.85, series2, type5); dataset.addValue(-0.23, series2, type6); dataset.addValue(0.8, series2, type7); dataset.addValue(0.4, series2, type8); |
|
173 |
|
|
174 |
dataset.addValue(-0.23, series3, type1); dataset.addValue(0.64, series3, type2); dataset.addValue(0.35, series3, type3); dataset.addValue(0.89, series3, type4); |
|
175 |
dataset.addValue(-0.56, series3, type5); dataset.addValue(0.2, series3, type6); dataset.addValue(-0.36, series3, type7); dataset.addValue(-0.72, series3, type8); |
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
// Creating the chart from the current charts engine |
|
180 |
JFreeChart chart = this.chartsEngine.createCategoryLineChart(dataset, "Specificities of words \"faire\", \"voir\", \"être\" in partition \"P\" of corpus \"C\"", "Part", "Score", true, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
181 |
|
|
182 |
|
|
183 |
// Custom renderer |
|
184 |
chart.getCategoryPlot().setRenderer(new ItemSelectionCategoryLineAndShapeRenderer(true, false)); |
|
185 |
|
|
186 |
// Custom range axis for ticks drawing options |
|
187 |
chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), true, true, -1, 1)); |
|
188 |
|
|
189 |
|
|
190 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
191 |
|
|
192 |
|
|
193 |
// TODO : test markers |
|
194 |
Marker target = new ValueMarker(0.32); |
|
195 |
target.setPaint(Color.red); |
|
196 |
target.setLabel("Score moyen positif"); //$NON-NLS-1$ |
|
197 |
target.setLabelAnchor(RectangleAnchor.TOP_RIGHT); |
|
198 |
target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); |
|
199 |
((CategoryPlot) chart.getPlot()).addRangeMarker(target); |
|
200 |
|
|
201 |
target = new ValueMarker(-0.45); |
|
202 |
target.setPaint(Color.red); |
|
203 |
target.setLabel("Score moyen négatif"); //$NON-NLS-1$ |
|
204 |
target.setLabelAnchor(RectangleAnchor.TOP_RIGHT); |
|
205 |
target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); |
|
206 |
((CategoryPlot) chart.getPlot()).addRangeMarker(target); |
|
207 |
|
|
208 |
|
|
209 |
return chartPanel; |
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
/** |
|
214 |
* |
|
215 |
* @return |
|
216 |
*/ |
|
217 |
// FIXME : test method |
|
218 |
public ChartPanel ___createCategoryDimensionsBarChartPanel() { |
|
219 |
|
|
220 |
ChartPanel chartPanel; |
|
221 |
|
|
222 |
|
|
223 |
// Jeu de donn�es factice |
|
224 |
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
|
225 |
String category = "T"; //$NON-NLS-1$ |
|
226 |
//dataset.setValue(2, "test", "testtt"); |
|
227 |
//dataset.setValue(5, category, "testtt"); |
|
228 |
dataset.setValue(890, category, "Introduction"); //$NON-NLS-1$ |
|
229 |
dataset.setValue(780, category, "Chapter 1"); //$NON-NLS-1$ |
|
230 |
dataset.setValue(1430, category, "Chapter 2"); //$NON-NLS-1$ |
|
231 |
dataset.setValue(700, category, "Chapter 3"); //$NON-NLS-1$ |
|
232 |
dataset.setValue(590, category, "Chapter 4"); //$NON-NLS-1$ |
|
233 |
dataset.setValue(380, category, "Conclusion"); //$NON-NLS-1$ |
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
// Creating the chart from the current charts engine |
|
238 |
JFreeChart chart = this.chartsEngine.createCategoryBarChart(dataset, "Dimensions of partition \"P\" in corpus \"C\"", "Part", "Number of words per part", false, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
239 |
|
|
240 |
// Custom range axis for ticks drawing options |
|
241 |
chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), false, true, 0, DatasetUtilities.findMaximumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue())); |
|
242 |
|
|
243 |
|
|
244 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
245 |
|
|
246 |
return chartPanel; |
|
247 |
} |
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
/** |
|
252 |
* Distribution bar chart of multiple words by parts. |
|
253 |
* @return |
|
254 |
*/ |
|
255 |
// FIXME : test method |
|
256 |
public ChartPanel ___createCategoryDistributionBarsChartPanel() { |
|
257 |
|
|
258 |
ChartPanel chartPanel; |
|
259 |
|
|
260 |
|
|
261 |
// Jeu de données factice |
|
262 |
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
|
263 |
|
|
264 |
dataset.setValue(3, "faire", "Introduction"); dataset.setValue(4, "voir", "Introduction"); dataset.setValue(1, "avoir", "Introduction"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
|
265 |
dataset.setValue(5, "être", "Introduction"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
266 |
|
|
267 |
dataset.setValue(9, "faire", "Chapter 1"); dataset.setValue(3, "voir", "Chapter 1"); dataset.setValue(7, "avoir", "Chapter 1"); dataset.setValue(2, "être", "Chapter 1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
|
268 |
dataset.setValue(1, "faire", "Chapter 2"); dataset.setValue(8, "voir", "Chapter 2"); dataset.setValue(4, "avoir", "Chapter 2"); dataset.setValue(6, "être", "Chapter 2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
|
269 |
dataset.setValue(3, "faire", "Chapter 3"); dataset.setValue(5, "voir", "Chapter 3"); dataset.setValue(0, "avoir", "Chapter 3"); dataset.setValue(11, "être", "Chapter 3"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
|
270 |
dataset.setValue(5, "faire", "Conclusion"); dataset.setValue(0, "voir", "Conclusion"); dataset.setValue(6, "avoir", "Conclusion"); dataset.setValue(1, "être", "Conclusion"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ |
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
// Creating the chart from the current charts engine |
|
275 |
JFreeChart chart = this.chartsEngine.createCategoryBarChart(dataset, "Distribution of words \"faire\", \"voir\", \"avoir\", \"être\" in corpus \"C\"", "Part", "Frequency", true, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
276 |
|
|
277 |
|
|
278 |
// Custom range axis for ticks drawing options |
|
279 |
chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), false, true, 0, DatasetUtilities.findMaximumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue())); |
|
280 |
|
|
281 |
|
|
282 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
283 |
|
|
284 |
return chartPanel; |
|
285 |
} |
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
/** |
|
290 |
* Creates a chart panel containing a CA scatter plot from the specified CA result. |
|
291 |
* @param ca |
|
292 |
* @return the chart panel |
|
293 |
*/ |
|
294 |
public ChartPanel createCAFactorialMapChartPanel(CA ca) { |
|
295 |
|
|
296 |
ChartPanel chartPanel; |
|
297 |
|
|
298 |
// Creating the chart from the current charts engine |
|
299 |
JFreeChart chart = this.chartsEngine.createCAFactorialMapChart(ca); |
|
300 |
|
|
301 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
302 |
|
|
303 |
// Need to be called after the theme is applied to the chart else the legends of not visible series aren't created |
|
304 |
chart.getXYPlot().getRenderer().setSeriesVisible(0, ca.isShowVariables()); // Rows |
|
305 |
chart.getXYPlot().getRenderer().setSeriesVisible(1, ca.isShowIndividuals()); // Columns |
|
306 |
|
|
307 |
((FCAItemSelectionRenderer) chart.getXYPlot().getRenderer()).setChartPanel(chartPanel); |
|
308 |
|
|
309 |
|
|
310 |
return chartPanel; |
|
311 |
} |
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
/** |
|
316 |
* Creates a chart panel containing a bar chart with the singular values of the specified CA result. |
|
317 |
* @param ca |
|
318 |
* @return |
|
319 |
*/ |
|
320 |
public ChartPanel createCASingularValuesBarChartChartPanel(CA ca) { |
|
321 |
|
|
322 |
ChartPanel chartPanel; |
|
323 |
|
|
324 |
// Creating the chart from the current charts engine |
|
325 |
JFreeChart chart = this.chartsEngine.createCASingularValuesBarChart(ca); |
|
326 |
|
|
327 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
328 |
|
|
329 |
return chartPanel; |
|
330 |
} |
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
/** |
|
335 |
* Creates a chart panel containing a CAH plot from the specified CAH result. |
|
336 |
* @param cah |
|
337 |
* @return the chart panel |
|
338 |
*/ |
|
339 |
public ChartPanel createCAHChartPanel(CAH cah, boolean display2D) { |
|
340 |
|
|
341 |
ChartPanel chartPanel; |
|
342 |
|
|
343 |
// Creating the chart from the current charts engine |
|
344 |
JFreeChart chart = (JFreeChart) this.chartsEngine.createCAHChart(cah, display2D); |
|
345 |
|
|
346 |
chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
347 |
|
|
348 |
return chartPanel; |
|
349 |
} |
|
350 |
|
|
351 |
|
|
352 |
// /** |
|
353 |
// * Creates a chart panel containing a bar chart with the dimensions of the specified partition result. |
|
354 |
// * @param partition |
|
355 |
// * @param sortPartsBySize |
|
356 |
// * @return |
|
357 |
// */ |
|
358 |
// public ChartPanel createDimensionsPartitionBarChartChartPanel(Partition partition, boolean sortPartsBySize) { |
|
359 |
// |
|
360 |
// ChartPanel chartPanel; |
|
361 |
// |
|
362 |
// // Creating the chart from the current charts engine |
|
363 |
// JFreeChart chart = this.chartsEngine.createPartitionDimensionsChart(partition, sortPartsBySize); |
|
364 |
// |
|
365 |
// chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
366 |
// |
|
367 |
// // FIXME : pour tests de scrolling sur les diagrammes à bâtons très large |
|
368 |
// //chartPanel.setPreferredSize(new Dimension(20000, 300)); |
|
369 |
// |
|
370 |
//// int panelWidth = chart.getCategoryPlot().getDataset().getColumnCount() * 120; |
|
371 |
//// chartPanel.setPreferredSize(new Dimension(panelWidth, 1)); |
|
372 |
// |
|
373 |
// return chartPanel; |
|
374 |
// } |
|
375 |
|
|
376 |
// /** |
|
377 |
// * Creates a chart panel containing a line chart or a bar chart from the specified Progression result. |
|
378 |
// * @param progression |
|
379 |
// * @param monochrome |
|
380 |
// * @param monostyle |
|
381 |
// * @param doCumulative |
|
382 |
// * @return |
|
383 |
// */ |
|
384 |
// public ChartPanel createProgressionChartPanel(Progression progression, boolean monochrome, boolean monostyle, boolean doCumulative) { |
|
385 |
// |
|
386 |
// ChartPanel chartPanel; |
|
387 |
// |
|
388 |
// // Creating the chart from the current charts engine |
|
389 |
// JFreeChart chart = this.chartsEngine.createProgressionChart(progression, monochrome, monostyle, doCumulative); |
|
390 |
// |
|
391 |
// chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
392 |
// |
|
393 |
// ((ProgressionItemSelectionRenderer) chart.getXYPlot().getRenderer()).setChartPanel(chartPanel); |
|
394 |
// |
|
395 |
// return chartPanel; |
|
396 |
// } |
|
397 |
|
|
398 |
|
|
399 |
// /** |
|
400 |
// * Creates a chart panel containing a chart with the scores of the specified indices. |
|
401 |
// * @param specificitiesResult |
|
402 |
// * @param typeNames |
|
403 |
// * @param partNames |
|
404 |
// * @param specIndex |
|
405 |
// * @param transpose |
|
406 |
// * @param drawBars |
|
407 |
// * @param drawLines |
|
408 |
// * @param banalite |
|
409 |
// * @param monochrome |
|
410 |
// * @return |
|
411 |
// */ |
|
412 |
// public ChartPanel createSpecificitiesChartPanel(SpecificitesResult specificitiesResult, boolean transpose, boolean drawBars, boolean drawLines, float banalite, boolean monochrome) { |
|
413 |
// |
|
414 |
// ChartPanel chartPanel; |
|
415 |
// |
|
416 |
// // Creating the chart from the current charts engine |
|
417 |
// JFreeChart chart = this.chartsEngine.createSpecificitiesChart(specificitiesResult, transpose, drawBars, drawLines, banalite, monochrome); |
|
418 |
// |
|
419 |
// chartPanel = this.getTheme().createChartPanel(this.swtChartsComponentProvider, chart); |
|
420 |
// |
|
421 |
// return chartPanel; |
|
422 |
// } |
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
/** |
|
427 |
* Creates an empty chart panel. |
|
428 |
* @return |
|
429 |
*/ |
|
430 |
public ChartPanel createDefaultEmptyChartPanel() { |
|
431 |
return this.getTheme().createChartPanel(this.swtChartsComponentProvider, null); |
|
432 |
} |
|
433 |
|
|
434 |
|
|
435 |
/** |
|
436 |
* Gets the charts engine. |
|
437 |
* @return the chartsEngine |
|
438 |
*/ |
|
439 |
public JFCChartsEngine getChartsEngine() { |
|
440 |
return chartsEngine; |
|
441 |
} |
|
442 |
|
|
443 |
|
|
444 |
public Theme getTheme() { |
|
445 |
return this.chartsEngine.getTheme(); |
|
446 |
} |
|
447 |
|
|
448 |
|
|
449 |
/** |
|
450 |
* Gets the items renderer of the specified plot. |
|
451 |
* @param plot |
|
452 |
* @return |
|
453 |
*/ |
|
454 |
public static LegendItemSource getRenderer(Plot plot) { |
|
455 |
LegendItemSource renderer = null; |
|
456 |
|
|
457 |
if(plot instanceof XYPlot) { |
|
458 |
renderer = ((XYPlot) plot).getRenderer(); |
|
459 |
} |
|
460 |
else if(plot instanceof CategoryPlot) { |
|
461 |
renderer = ((CategoryPlot) plot).getRenderer(); |
|
462 |
} |
|
463 |
|
|
464 |
return renderer; |
|
465 |
} |
|
466 |
|
|
467 |
/** |
|
468 |
* Gets the items renderer associated to the plot linked to the specified chart panel. |
|
469 |
* @param panel |
|
470 |
* @return |
|
471 |
*/ |
|
472 |
public static LegendItemSource getRenderer(ChartPanel panel) { |
|
473 |
return getRenderer(panel.getChart().getPlot()); |
|
474 |
} |
|
475 |
|
|
476 |
} |
|
0 | 477 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/preferences/JFCChartsEnginePreferencePage.java (revision 114) | ||
---|---|---|
1 |
package org.txm.chartsengine.jfreechart.rcp.preferences; |
|
2 |
|
|
3 |
// Copyright © 2010-2013 ENS de Lyon. |
|
4 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
5 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
6 |
// Sophia Antipolis, University of Paris 3. |
|
7 |
// |
|
8 |
// The TXM platform is free software: you can redistribute it |
|
9 |
// and/or modify it under the terms of the GNU General Public |
|
10 |
// License as published by the Free Software Foundation, |
|
11 |
// either version 2 of the License, or (at your option) any |
|
12 |
// later version. |
|
13 |
// |
|
14 |
// The TXM platform is distributed in the hope that it will be |
|
15 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
16 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
17 |
// PURPOSE. See the GNU General Public License for more |
|
18 |
// details. |
|
19 |
// |
|
20 |
// You should have received a copy of the GNU General |
|
21 |
// Public License along with the TXM platform. If not, see |
|
22 |
// http://www.gnu.org/licenses. |
|
23 |
// |
|
24 |
// |
|
25 |
// |
|
26 |
// $LastChangedDate:$ |
|
27 |
// $LastChangedRevision:$ |
|
28 |
// $LastChangedBy:$ |
|
29 |
// |
|
30 |
|
|
31 |
|
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.TreeSet; |
|
34 |
|
|
35 |
import org.eclipse.jface.preference.ComboFieldEditor; |
|
36 |
import org.eclipse.ui.IWorkbench; |
|
37 |
import org.eclipse.ui.PlatformUI; |
|
38 |
import org.txm.chartsengine.core.ChartsEngine; |
|
39 |
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine; |
|
40 |
import org.txm.chartsengine.jfreechart.core.preferences.JFCChartsEnginePreferences; |
|
41 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
42 |
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages; |
|
43 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
44 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
45 |
import org.txm.rcpapplication.TxmPreferences; |
|
46 |
import org.txm.rcpapplication.preferences.ExportPreferencePage; |
|
47 |
import org.txm.rcpapplication.preferences.UserPreferencePage; |
|
48 |
|
|
49 |
/** |
|
50 |
* JFreeChart charts engine preference page. |
|
51 |
* @author sjacquot |
|
52 |
* |
|
53 |
*/ |
|
54 |
public class JFCChartsEnginePreferencePage extends TXMPreferencePage { |
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
@Override |
|
59 |
public void createFieldEditors() { |
|
60 |
|
|
61 |
// TODO : add JFC Themes selection? |
|
62 |
|
|
63 |
|
|
64 |
ArrayList<String> supportedOutputFormats = new ArrayList<String>(); |
|
65 |
|
|
66 |
|
|
67 |
supportedOutputFormats.addAll(JFCChartsEngine.getSupportedOutputDisplayFormatsStatic()); |
|
68 |
supportedOutputFormats.addAll(JFCChartsEngine.getSupportedOutputFileFormatsStatic()); |
|
69 |
|
|
70 |
// Sort the set |
|
71 |
TreeSet<String> formatsSet = new TreeSet <String>(supportedOutputFormats); |
|
72 |
String[] formats = formatsSet.toArray(new String[formatsSet.size()]); |
|
73 |
|
|
74 |
String[][] displayFormats = new String[formats.length][2]; |
|
75 |
for(int i = 0; i < formats.length; i++) { |
|
76 |
displayFormats[i][0] = formats[i]; |
|
77 |
displayFormats[i][1] = formats[i]; |
|
78 |
} |
|
79 |
|
|
80 |
this.addField(new ComboFieldEditor(JFCChartsEnginePreferences.OUTPUT_FORMAT, SWTComponentsProviderMessages.ChartsEnginePreferencePage_COMBO_FIELD_SELECT_DISPLAY_FORMAT_LABEL, displayFormats, this.getFieldEditorParent())); |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
@Override |
|
85 |
public void init(IWorkbench workbench) { |
|
86 |
this.setPreferenceStore(new TXMPreferenceStore(JFCChartsEnginePreferences.PREFERENCE_NODE)); |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public boolean performOk() { |
|
91 |
try { |
|
92 |
super.performOk(); |
|
93 |
|
|
94 |
// Change the JFC Charts engine output format |
|
95 |
ChartsEngine.getChartsEngine(JFCChartsEngine.class).setOutputFormat(this.getPreferenceStore().getString(JFCChartsEnginePreferences.OUTPUT_FORMAT)); |
|
96 |
|
|
97 |
// Sets the new current charts SWT component provider according to the output format if the charts engine is the current one |
|
98 |
if(ChartsEngine.getCurrent() instanceof JFCChartsEngine) { |
|
99 |
SWTChartsComponentsProvider.setCurrrentComponentsProvider(ChartsEngine.getCurrent()); |
|
100 |
|
|
101 |
// Set the first charts engine supported export file format as default charts export file format |
|
102 |
TxmPreferences.set(ExportPreferencePage.RDEVICE, ChartsEngine.getCurrent().getSupportedOutputFileFormats().get(0)); |
|
103 |
|
|
104 |
// Refresh the User\Export preference page to update "Default charts export file format" combo box |
|
105 |
PlatformUI.getWorkbench().getPreferenceManager(). |
|
106 |
find("org.txm.rcpapplication.preferences.TextometriePreferencePage/" + UserPreferencePage.ID + "/" + ExportPreferencePage.ID).createPage(); //$NON-NLS-1$ //$NON-NLS-2$ |
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
} catch (Exception e) { |
|
113 |
System.err.println(org.txm.rcpapplication.Messages.FAILED_TO_SAVE_PREFERENCES + e); |
|
114 |
} |
|
115 |
return true; |
|
116 |
} |
|
117 |
} |
|
0 | 118 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/events/DefaultChartMouseListener.java (revision 114) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.chartsengine.jfreechart.rcp.events; |
|
5 |
|
|
6 |
import java.awt.event.MouseEvent; |
|
7 |
|
|
8 |
import org.jfree.chart.ChartMouseEvent; |
|
9 |
import org.jfree.chart.ChartMouseListener; |
|
10 |
import org.jfree.chart.ChartPanel; |
|
11 |
import org.jfree.chart.axis.SymbolAxis; |
|
12 |
import org.jfree.chart.entity.CategoryItemEntity; |
|
13 |
import org.jfree.chart.entity.ChartEntity; |
|
14 |
import org.jfree.chart.entity.JFreeChartEntity; |
|
15 |
import org.jfree.chart.entity.PlotEntity; |
|
16 |
import org.jfree.chart.entity.XYItemEntity; |
|
17 |
import org.jfree.chart.plot.CategoryPlot; |
|
18 |
import org.jfree.chart.plot.Plot; |
|
19 |
import org.jfree.chart.plot.XYPlot; |
|
20 |
import org.jfree.data.category.CategoryDataset; |
|
21 |
import org.jfree.data.xy.XYSeriesCollection; |
|
22 |
import org.txm.chartsengine.jfreechart.core.datasets.FCAXYDataset; |
|
23 |
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector; |
|
24 |
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer; |
|
25 |
import org.txm.chartsengine.rcp.IChartComponent; |
|
26 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
27 |
import org.txm.chartsengine.rcp.events.AbstractChartMouseListener; |
|
28 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
|
29 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
|
30 |
|
|
31 |
/** |
|
32 |
* Default JFC chart engine mouse listener. |
|
33 |
* @author sjacquot |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class DefaultChartMouseListener extends EventCallBackHandler implements ChartMouseListener { |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* @param swtChartsComponentProvider |
|
42 |
* @param chartComponent |
|
43 |
*/ |
|
44 |
public DefaultChartMouseListener(SWTChartsComponentsProvider swtChartsComponentProvider, IChartComponent chartComponent) { |
|
45 |
super(swtChartsComponentProvider, chartComponent); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void chartMouseClicked(ChartMouseEvent event) { |
|
50 |
|
|
51 |
ChartEntity entity = event.getEntity(); |
|
52 |
|
|
53 |
int eventArea = -1; |
|
54 |
|
|
55 |
|
|
56 |
String menuText = ""; |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
Plot plot = ((ChartPanel) this.chartComponent).getChart().getPlot(); |
|
61 |
|
|
62 |
IItemSelectionRenderer renderer = null; |
|
63 |
|
|
64 |
if(plot instanceof XYPlot) { |
|
65 |
renderer = (IItemSelectionRenderer) ((XYPlot) plot).getRenderer(); |
|
66 |
} |
|
67 |
else if(plot instanceof CategoryPlot) { |
|
68 |
renderer = (IItemSelectionRenderer) ((CategoryPlot) plot).getRenderer(); |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
// Select/deselect item |
|
73 |
if(entity instanceof XYItemEntity || entity instanceof CategoryItemEntity) { |
|
74 |
|
|
75 |
int series = -1; |
|
76 |
int item = -1; |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
eventArea = EventCallBack.AREA_ITEM; |
|
81 |
|
|
82 |
// Single click |
|
83 |
if(event.getTrigger().getClickCount() == 1) { |
|
84 |
|
|
85 |
// Multiple item selector |
|
86 |
if(renderer.getItemsSelector() instanceof MultipleItemsSelector) { |
|
87 |
|
|
88 |
|
|
89 |
MultipleItemsSelector itemsSelector = (MultipleItemsSelector) renderer.getItemsSelector(); |
|
90 |
|
|
91 |
// XY plot |
|
92 |
if(entity instanceof XYItemEntity) { |
|
93 |
XYItemEntity itemEntity = (XYItemEntity) entity; |
|
94 |
series = itemEntity.getSeriesIndex(); |
|
95 |
item = itemEntity.getItem(); |
|
96 |
} |
|
97 |
// Category plot |
|
98 |
else if(entity instanceof CategoryItemEntity) { |
|
99 |
CategoryItemEntity itemEntity = (CategoryItemEntity) entity; |
|
100 |
CategoryDataset dataset = itemEntity.getDataset(); |
|
101 |
series = dataset.getRowIndex(itemEntity.getRowKey()); |
|
102 |
item = dataset.getColumnIndex(itemEntity.getColumnKey()); |
|
103 |
|
|
104 |
menuText = (String) dataset.getColumnKeys().get(series); |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
int onmask = MouseEvent.BUTTON1_MASK; |
|
109 |
int mods = event.getTrigger().getModifiers(); |
|
110 |
|
|
111 |
// Simple selection mode |
|
112 |
if(itemsSelector.isSimpleSelectionMode() |
|
113 |
&& (mods & onmask) == onmask) { |
|
114 |
itemsSelector.removeAllSelectedItems(); // clear the selection |
|
115 |
itemsSelector.setSelectedItem(series, item, !itemsSelector.isSelectedItem(series, item)); |
|
116 |
|
|
117 |
} |
|
118 |
// Multiple selection mode |
|
119 |
else if((mods & AbstractChartMouseListener.keyboardExtendedSelectionModifierKeyMask) == 0) { |
|
120 |
|
|
121 |
int offmask = AbstractChartMouseListener.mouseMultipleSelectionModifierKeyMask; |
|
122 |
|
|
123 |
if((mods & (onmask | offmask)) == onmask) { |
|
124 |
itemsSelector.removeAllSelectedItems(series); |
|
125 |
} |
|
126 |
if((mods & onmask) == onmask) { |
|
127 |
itemsSelector.setSelectedItem(series, item, !itemsSelector.isSelectedItem(series, item)); |
|
128 |
} |
|
129 |
// right click, do not clear the current selection if the click occurred in the current selection |
|
130 |
if((mods & MouseEvent.BUTTON3_MASK) == MouseEvent.BUTTON3_MASK) { |
|
131 |
if(!itemsSelector.isSelectedItem(series, item)) { |
|
132 |
itemsSelector.removeAllSelectedItems(series); |
|
133 |
} |
|
134 |
itemsSelector.setSelectedItem(series, item, true); |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
138 |
// Extended selection by series |
|
139 |
else if(itemsSelector.getLastSelectedItem() != -1 && itemsSelector.getLastSelectedSeries() == series) { |
|
140 |
// Ascendant |
|
141 |
if(itemsSelector.getLastSelectedItem() < item) { |
|
142 |
for(int i = itemsSelector.getLastSelectedItem(); i < item; i++) { |
|
143 |
itemsSelector.selectNextItem(true); |
|
144 |
} |
|
145 |
} |
|
146 |
// Descendant |
|
147 |
else { |
|
148 |
for(int i = itemsSelector.getLastSelectedItem(); i >= item + 1; i--) { |
|
149 |
itemsSelector.selectPreviousItem(true); |
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
// update text menu according to the current selection |
|
156 |
if(renderer.getItemsSelector() instanceof MultipleItemsSelector && ((MultipleItemsSelector) renderer.getItemsSelector()).getSelectedSeriesCount() > 0) { |
|
157 |
// XY plot |
|
158 |
if(entity instanceof XYItemEntity) { |
|
159 |
XYItemEntity itemEntity = (XYItemEntity) entity; |
|
160 |
|
|
161 |
MultipleItemsSelector selector = (MultipleItemsSelector) renderer.getItemsSelector(); |
|
162 |
int selectedSeries; |
|
163 |
for(int i = 0; i < selector.getSelectedSeriesCount(); i++) { |
|
164 |
selectedSeries = selector.getSelectedSeries()[i]; |
|
165 |
int[] selectedItems = selector.getSelectedItems(selectedSeries); |
|
166 |
for(int j = 0; j < selectedItems.length; j++) { |
|
167 |
// Symbol Axis |
|
168 |
if(((XYPlot) plot).getDomainAxis() instanceof SymbolAxis) { |
|
169 |
menuText += (String)((SymbolAxis) ((XYPlot) plot).getDomainAxis()).getSymbols()[selectedItems[j]]; |
|
170 |
} |
|
171 |
// CA |
|
172 |
else if(itemEntity.getDataset() instanceof FCAXYDataset) { |
|
173 |
menuText += ((FCAXYDataset) ((XYPlot)plot).getDataset()).getLabel(selectedSeries, selectedItems[j]); |
|
174 |
} |
|
175 |
// Progression |
|
176 |
else if(itemEntity.getDataset() instanceof XYSeriesCollection) { |
|
177 |
menuText += ((XYSeriesCollection)itemEntity.getDataset()).getSeriesKey(selectedSeries); |
|
178 |
menuText += " / "; //$NON-NLS-1$ |
|
179 |
break; |
|
180 |
} |
|
181 |
else { |
|
182 |
menuText += String.valueOf(itemEntity.getDataset().getXValue(selectedSeries, selectedItems[j])); |
|
183 |
} |
|
184 |
|
|
185 |
menuText += " / "; //$NON-NLS-1$ |
|
186 |
} |
|
187 |
} |
|
188 |
// remove the last separator |
|
189 |
menuText = menuText.substring(0, menuText.length() - 3); |
|
190 |
// trim the entry |
|
191 |
if(menuText.length() > 30) { |
|
192 |
menuText = menuText.substring(0, 30); |
|
193 |
menuText += "..."; //$NON-NLS-1$ |
|
194 |
} |
|
195 |
|
|
196 |
} |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
// Empty area |
|
202 |
else if(entity instanceof PlotEntity || entity instanceof JFreeChartEntity) { |
|
203 |
eventArea = EventCallBack.AREA_EMPTY; |
|
204 |
|
|
205 |
// FIXME: deselect all items, waiting the discussion about the editor focus policy |
|
206 |
// if(renderer.getItemsSelector() instanceof MultipleItemsSelector) { |
|
207 |
// ((MultipleItemsSelector)renderer.getItemsSelector()).removeAllSelectedItems(); |
|
208 |
// } |
|
209 |
} |
|
210 |
//FIXME: force empty area event type for all non item area (later we need to pass legend item type, title item type, etc.) |
|
211 |
else { |
|
212 |
eventArea = EventCallBack.AREA_EMPTY; |
|
213 |
} |
|
214 |
|
|
215 |
// Set the composite current menu |
|
216 |
final int a = eventArea; |
|
217 |
final String t = menuText; |
|
218 |
((IChartComponent) this.chartComponent).getChartEditor().getComposite().getDisplay().syncExec(new Runnable () { |
|
219 |
public void run() { |
|
220 |
((IChartComponent) chartComponent).getChartEditor().getComposite().setCurrentContextMenu(a); |
|
221 |
if(!t.isEmpty() && ((IChartComponent) chartComponent).getChartEditor().getComposite().getMenu() != null) { |
|
222 |
((IChartComponent) chartComponent).getChartEditor().getComposite().getMenu().getItem(0).setText(t); |
|
223 |
} |
|
224 |
} |
|
225 |
}); |
|
226 |
|
|
227 |
|
|
228 |
// Process event call backs |
|
229 |
for(int i = 0; i < this.eventCallBacks.size(); i++) { |
|
230 |
this.eventCallBacks.get(i).processEvent(event.getTrigger(), eventArea, event); |
|
231 |
} |
|
232 |
|
|
233 |
|
|
234 |
// FIXME: Debug |
|
235 |
// System.out.println("DefaultChartMouseListener.chartMouseClicked(): call backs count: " + eventCallBacks.size()); |
|
236 |
// System.err.println("DefaultChartMouseListener.chartMouseClicked(): click count: " + event.getTrigger().getClickCount()); |
|
237 |
// System.err.println("DefaultChartMouseListener.chartMouseClicked(): entity type: " + entity); |
|
238 |
|
|
239 |
} |
|
240 |
|
|
241 |
@Override |
|
242 |
public void chartMouseMoved(ChartMouseEvent event) { |
|
243 |
|
|
244 |
// Mouse over selection |
|
245 |
ChartEntity entity = event.getEntity(); |
|
246 |
|
|
247 |
Plot plot = ((ChartPanel) this.chartComponent).getChart().getPlot(); |
|
248 |
|
|
249 |
IItemSelectionRenderer renderer = null; |
|
250 |
|
|
251 |
if(plot instanceof XYPlot) { |
|
252 |
renderer = (IItemSelectionRenderer) ((XYPlot) plot).getRenderer(); |
|
253 |
} |
|
254 |
else if(plot instanceof CategoryPlot) { |
|
255 |
renderer = (IItemSelectionRenderer) ((CategoryPlot) plot).getRenderer(); |
|
256 |
} |
|
257 |
|
|
258 |
int series = -1; |
|
259 |
int item = -1; |
|
260 |
|
|
261 |
// Mouse over, storing the current selected entity on mouse over |
|
262 |
if(entity instanceof XYItemEntity || entity instanceof CategoryItemEntity) { |
|
263 |
|
|
264 |
// XY plot |
|
265 |
if(entity instanceof XYItemEntity) { |
|
266 |
XYItemEntity itemEntity = (XYItemEntity) entity; |
|
267 |
series = itemEntity.getSeriesIndex(); |
|
268 |
item = itemEntity.getItem(); |
|
269 |
} |
|
270 |
// Category plot |
|
271 |
else if(entity instanceof CategoryItemEntity) { |
|
272 |
CategoryItemEntity itemEntity = (CategoryItemEntity) entity; |
|
273 |
CategoryDataset dataset = itemEntity.getDataset(); |
|
274 |
series = dataset.getRowIndex(itemEntity.getRowKey()); |
|
275 |
item = dataset.getColumnIndex(itemEntity.getColumnKey()); |
|
276 |
} |
|
277 |
|
|
278 |
// Storing shape coordinates |
|
279 |
renderer.getItemsSelector().setMouseOverItemCoords(entity.getArea().getBounds().x, entity.getArea().getBounds().y); |
|
280 |
|
|
281 |
|
|
282 |
} |
|
283 |
|
|
284 |
renderer.getItemsSelector().setMouseOverItem(series, item); |
|
285 |
|
|
286 |
} |
|
287 |
|
|
288 |
} |
|
0 | 289 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/themes/highcharts/events/JFCItemsKeyboardSelectionCallBack.java (revision 114) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.chartsengine.jfreechart.rcp.themes.highcharts.events; |
|
5 |
|
|
6 |
import java.awt.AWTEvent; |
|
7 |
import java.awt.event.KeyEvent; |
|
8 |
|
|
9 |
import org.jfree.chart.ChartPanel; |
|
10 |
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector; |
|
11 |
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer; |
|
12 |
import org.txm.chartsengine.jfreechart.rcp.JFCChartsSwingComponentsProvider; |
|
13 |
import org.txm.chartsengine.rcp.events.ItemsKeyboardSelectionCallBack; |
|
14 |
import org.txm.chartsengine.rcp.events.ZoomAndPanCallBack; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author sjacquot |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class JFCItemsKeyboardSelectionCallBack extends ItemsKeyboardSelectionCallBack { |
|
21 |
|
|
22 |
|
|
23 |
/** |
|
24 |
* |
|
25 |
*/ |
|
26 |
public JFCItemsKeyboardSelectionCallBack() { |
|
27 |
// TODO Auto-generated constructor stub |
|
28 |
} |
|
29 |
|
|
30 |
/* (non-Javadoc) |
|
31 |
* @see org.txm.rcp.chartsengine.base.events.EventCallBack#processEvent(java.awt.AWTEvent, int, java.lang.Object) |
|
32 |
*/ |
|
33 |
@Override |
|
34 |
public void processEvent(AWTEvent event, int eventArea, Object customData) { |
|
35 |
|
|
36 |
// TODO Auto-generated method stub |
|
37 |
// Keyboard event |
|
38 |
if(event instanceof KeyEvent) { |
|
39 |
|
|
40 |
|
|
41 |
KeyEvent keyEvent = (KeyEvent)event; |
|
42 |
|
|
43 |
// return if zoom and pan modifier |
|
44 |
if((keyEvent.getModifiers() & ZoomAndPanCallBack.keyboardZoomModifierKeyMask) != 0) { |
|
45 |
return; |
|
46 |
} |
|
47 |
|
|
48 |
boolean extendedSelection = false; |
|
49 |
|
|
50 |
// Extended selection |
|
51 |
if((keyEvent.getModifiers() & keyboardExtendedSelectionModifierKeyMask) != 0) { |
|
52 |
extendedSelection = true; |
|
53 |
} |
|
54 |
|
|
55 |
if(keyEvent.getKeyCode() == KeyEvent.VK_LEFT || keyEvent.getKeyCode() == KeyEvent.VK_RIGHT) { |
|
56 |
IItemSelectionRenderer renderer = (IItemSelectionRenderer) JFCChartsSwingComponentsProvider.getRenderer((ChartPanel) customData); |
|
57 |
|
|
58 |
// Select next item or add it to selection |
|
59 |
if(keyEvent.getKeyCode() == KeyEvent.VK_RIGHT) { |
|
60 |
((MultipleItemsSelector)renderer.getItemsSelector()).selectNextItem(extendedSelection); |
|
61 |
} |
|
62 |
else if(keyEvent.getKeyCode() == KeyEvent.VK_LEFT) { |
|
63 |
((MultipleItemsSelector)renderer.getItemsSelector()).selectPreviousItem(extendedSelection); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
} |
|
0 | 70 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/themes/highcharts/events/FCAChartMouseListener.java (revision 114) | ||
---|---|---|
1 |
package org.txm.chartsengine.jfreechart.rcp.themes.highcharts.events; |
|
2 |
|
|
3 |
import org.jfree.chart.ChartMouseEvent; |
|
4 |
import org.txm.chartsengine.jfreechart.rcp.events.DefaultChartMouseListener; |
|
5 |
import org.txm.chartsengine.rcp.IChartComponent; |
|
6 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
7 |
|
|
8 |
/** |
|
9 |
* Mouse listener for CA Factorial Map chart. |
|
10 |
* @author sjacquot |
|
11 |
* |
|
12 |
*/ |
|
13 |
public class FCAChartMouseListener extends DefaultChartMouseListener { |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @param chartPanel |
|
20 |
*/ |
|
21 |
public FCAChartMouseListener(SWTChartsComponentsProvider swtChartsComponentProvider, IChartComponent chartComponent) { |
|
22 |
super(swtChartsComponentProvider, chartComponent); |
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
@Override |
|
27 |
public void chartMouseClicked(ChartMouseEvent event) { |
|
28 |
super.chartMouseClicked(event); |
|
29 |
|
|
30 |
// FIXME: pop up menu tests |
|
31 |
// ChartEntity entity = event.getEntity(); |
|
32 |
// |
|
33 |
// // Only if the AWT embedded Frame has focus |
|
34 |
// //if(this.chartPanelHasFocus()) { |
|
35 |
// |
|
36 |
// if (entity instanceof XYItemEntity) { |
|
37 |
// |
|
38 |
// // FIXME : tests popup menu sur un point |
|
39 |
// System.out.println("ScatterPlotDemo1.CAChartMouseListener.chartMouseClicked()"); |
|
40 |
// //this.renderer.setHighlightedItem(-1, -1); |
|
41 |
// |
|
42 |
// |
|
43 |
// // Récupération des infos liées à l'item via le dataset |
|
44 |
// FCAXYDataset dataset = (FCAXYDataset) ((XYItemEntity) entity).getDataset(); |
|
45 |
// String label = dataset.getLabel(((XYItemEntity) entity).getSeriesIndex(), ((XYItemEntity) entity).getItem()); |
|
46 |
// String frequency = dataset.getFrequency(((XYItemEntity) entity).getSeriesIndex(), ((XYItemEntity) entity).getItem()); |
|
47 |
// |
|
48 |
// JPopupMenu menu = new JPopupMenu(); |
|
49 |
// menu.add(new JLabel(" - " + label + " - ")); |
|
50 |
// menu.add(new JMenuItem("Frequency : " + String.valueOf(Math.abs(Double.valueOf(frequency))))); |
|
51 |
// |
|
52 |
// |
|
53 |
// menu.show(this.chartComponent, event.getTrigger().getX(), event.getTrigger().getY()); |
|
54 |
// |
|
55 |
// return; |
|
56 |
// } |
|
57 |
// //} |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
} |
|
0 | 64 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/themes/highcharts/swing/CustomChartPanel.java (revision 114) | ||
---|---|---|
1 |
package org.txm.chartsengine.jfreechart.rcp.themes.highcharts.swing; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import javax.swing.JToolTip; |
|
6 |
|
|
7 |
import org.jfree.chart.JFreeChart; |
|
8 |
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.swing.CustomHTMLToolTip; |
|
9 |
import org.txm.chartsengine.jfreechart.rcp.themes.base.swing.ItemSelectionChartPanel; |
|
10 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
11 |
|
|
12 |
/** |
|
13 |
* Chart panel providing custom tool tips with Highcharts graphics theme. |
|
14 |
* @author sjacquot |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class CustomChartPanel extends ItemSelectionChartPanel { |
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/** |
|
22 |
* |
|
23 |
* @param chart |
|
24 |
*/ |
|
25 |
public CustomChartPanel(SWTChartsComponentsProvider swtChartsComponentProvider, JFreeChart chart) { |
|
26 |
super(swtChartsComponentProvider, chart); |
|
27 |
|
|
28 |
|
|
29 |
// Set the zoom factors that will be used on key pressed zoom (this value is not use by the internal JFC mouse wheel zoom) |
|
30 |
this.setZoomInFactor(0.9); |
|
31 |
this.setZoomOutFactor(1.1); |
|
32 |
|
|
33 |
|
|
34 |
this.initItemSelectionListeners(); |
|
35 |
|
|
36 |
this.initEventListeners(); |
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
// Dimensions |
|
41 |
//chartPanel.setPreferredSize(new java.awt.Dimension(750, 550)); |
|
42 |
// TODO : DEbug |
|
43 |
//chartPanel.setPreferredSize(new java.awt.Dimension(1024, 768)); |
|
44 |
|
|
45 |
// TODO : test this to keep fonts readable despite of window size |
|
46 |
// chartPanel.setMinimumDrawWidth(400); |
|
47 |
this.setMaximumDrawWidth(100000); |
|
48 |
// chartPanel.setMinimumDrawHeight(400); |
|
49 |
this.setMaximumDrawHeight(100000); |
|
50 |
|
|
51 |
|
|
52 |
//this.setHorizontalAxisTrace(true); |
|
53 |
|
|
54 |
// Mouse wheel zoom |
|
55 |
this.setMouseWheelEnabled(true); |
|
56 |
|
|
57 |
|
|
58 |
// FIXME: test mouse wheel listener for improving the zoom, for sticking axes to the chart |
|
59 |
//this.removeMouseWheelListener(this.getMouseWheelListeners()[0]); |
|
60 |
// this.addMouseWheelListener(new MouseWheelListener() { |
|
61 |
// |
|
62 |
// @Override |
|
63 |
// public void mouseWheelMoved(MouseWheelEvent e) { |
|
64 |
// // TODO Auto-generated method stub |
|
65 |
// if(getChart().getPlot() instanceof XYPlot) { |
|
66 |
// //System.out.println("CustomChartPanel.CustomChartPanel(...).new MouseWheelListener() {...}.mouseWheelMoved(): " + getChart().getXYPlot().getDomainAxisEdge().getInsets()); |
|
67 |
// |
|
68 |
// |
|
69 |
// //getChart().getXYPlot().setAxisOffset(new RectangleInsets(0, 0, 0, 0)); |
|
70 |
// //((NumberAxis) getChart().getXYPlot().getDomainAxis()).setAutoRangeStickyZero(true); |
|
71 |
// getChart().getXYPlot().getDomainAxis().setTickLabelInsets(new RectangleInsets(10, 0, getChart().getXYPlot().getDomainAxis().getTickLabelInsets().getBottom() + 10 * getZoomOutFactor(), 0)); |
|
72 |
// } |
|
73 |
// } |
|
74 |
// }); |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
//this.setMouseZoomable(true); // useless ? |
|
79 |
this.setZoomOutlinePaint(Color.BLUE); |
|
80 |
this.setFillZoomRectangle(false); // TODO : ne fonctionne pas ? En fait ne fonctionne pas si l'appel est avant setMouseZoomable(true) ? |
|
81 |
|
|
82 |
|
|
83 |
// Tooltips |
|
84 |
this.setInitialDelay(500); |
|
85 |
|
|
86 |
// Disable the Swing original pop up menu |
|
87 |
this.setPopupMenu(null); |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
@Override |
|
92 |
public JToolTip createToolTip() { |
|
93 |
JToolTip tip = new CustomHTMLToolTip(this.getChart(), true); |
|
94 |
// TODO |
|
95 |
tip.setComponent(this); |
|
96 |
tip.setVisible(true); |
|
97 |
return tip; |
|
98 |
} |
|
99 |
|
|
100 |
|
|
101 |
} |
|
0 | 102 |
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/themes/highcharts/HighchartsDefaultTheme.java (revision 114) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.chartsengine.jfreechart.rcp.themes.highcharts; |
|
5 |
|
|
6 |
import org.jfree.chart.ChartPanel; |
Formats disponibles : Unified diff