Revision 647

tmp/org.txm.para.rcp/META-INF/MANIFEST.MF (revision 647)
1 1
Manifest-Version: 1.0
2 2
Bundle-ManifestVersion: 2
3
Bundle-Name: Rcp
3
Bundle-Name: Para RCP
4 4
Bundle-SymbolicName: org.txm.para.rcp;singleton:=true
5 5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.txm.para.rcp.Activator
7 6
Require-Bundle: org.txm.utils;bundle-version="1.0.0",
8 7
 org.eclipse.core.runtime;bundle-version="3.10.0",
9 8
 org.eclipse.osgi;bundle-version="3.10.2",
......
16 15
 org.txm.searchengine.core;bundle-version="1.0.0"
17 16
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
18 17
Bundle-ActivationPolicy: lazy
19
Export-Package: org.txm.para.rcp,
20
 org.txm.para.rcp.editors
18
Export-Package: org.txm.para.rcp.editors
tmp/org.txm.para.rcp/src/org/txm/para/rcp/Activator.java (revision 647)
1
package org.txm.para.rcp;
2

  
3
import org.eclipse.ui.plugin.AbstractUIPlugin;
4
import org.osgi.framework.BundleContext;
5

  
6
/**
7
 * The activator class controls the plug-in life cycle
8
 */
9
public class Activator extends AbstractUIPlugin {
10

  
11
	// The plug-in ID
12
	public static final String PLUGIN_ID = "org.txm.para.rcp"; //$NON-NLS-1$
13

  
14
	// The shared instance
15
	private static Activator plugin;
16
	
17
	/**
18
	 * The constructor
19
	 */
20
	public Activator() {
21
	}
22

  
23
	/*
24
	 * (non-Javadoc)
25
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
26
	 */
27
	public void start(BundleContext context) throws Exception {
28
		super.start(context);
29
		plugin = this;
30
	}
31

  
32
	/*
33
	 * (non-Javadoc)
34
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
35
	 */
36
	public void stop(BundleContext context) throws Exception {
37
		plugin = null;
38
		super.stop(context);
39
	}
40

  
41
	/**
42
	 * Returns the shared instance
43
	 *
44
	 * @return the shared instance
45
	 */
46
	public static Activator getDefault() {
47
		return plugin;
48
	}
49

  
50
}
tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/ParaBrowserEditor.java (revision 647)
57 57
import org.eclipse.ui.IEditorSite;
58 58
import org.eclipse.ui.PartInitException;
59 59
import org.eclipse.ui.part.EditorPart;
60
import org.txm.para.functions.ParaBrowser;
60
import org.txm.para.core.functions.ParaBrowser;
61 61
import org.txm.rcp.Messages;
62 62
import org.txm.rcp.StatusLine;
63 63
import org.txm.rcp.editors.input.ParaBrowserEditorInput;
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/swt/JFCComposite.java (revision 647)
288 288
		// loads the chart from the result
289 289
		Object chart = this.chartEditor.getChart();
290 290
		
291
		//FIXME: old version
292
		//if(!this.chartEditor.getResultData().isChartDirty())	{
293
		if(chart != null)	{
291
		if(chart != null) {
294 292
			// creates components if they not exist
295
			if(this.chartComponent == null)	{
293
			if(this.chartComponent == null) {
296 294

  
297 295
				// recreates the chart if not of right type
298 296
				if(!(chart instanceof JFreeChart))	{
......
313 311

  
314 312
				this.frame.setVisible(true);
315 313
			}
316

  
317
			// recreates the chart if not of right type
318
			// FIXME: does not work? step to reproduce : create a chart with R/SVG, close the editor, select JFC/Java2d as chart engine, double click on the result 
319
//			if(!(chart instanceof JFreeChart))	{
320
//				this.loadChart(this.chartEditor.getSWTChartsComponentsProvider().getChartsEngine().getChartCreator(this.chartEditor.getResult()).createChart(this.chartEditor.getResult()));
321
//			}
322
//			else	{
323
				this.loadChart(this.chartEditor.getChart());
324
//			}
325
			
314
			this.loadChart(this.chartEditor.getChart());
326 315
			this.forceFocus();
327 316
		}
328 317
	}
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/events/DefaultChartMouseListener.java (revision 647)
19 19
import org.jfree.chart.plot.XYPlot;
20 20
import org.jfree.data.category.CategoryDataset;
21 21
import org.jfree.data.xy.XYSeriesCollection;
22
import org.txm.ca.core.chartsengine.jfreechart.datasets.FCAXYDataset;
22
import org.txm.ca.core.chartsengine.jfreechart.datasets.CAXYDataset;
23 23
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector;
24 24
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection;
25 25
import org.txm.chartsengine.rcp.IChartComponent;
......
169 169
										menuText += (String)((SymbolAxis) ((XYPlot) plot).getDomainAxis()).getSymbols()[selectedItems[j]] + "\n";
170 170
									}
171 171
									// CA
172
									else if(itemEntity.getDataset() instanceof FCAXYDataset)	{
173
										menuText += ((FCAXYDataset) ((XYPlot)plot).getDataset()).getLabel(selectedSeries, selectedItems[j]);
172
									else if(itemEntity.getDataset() instanceof CAXYDataset)	{
173
										menuText += ((CAXYDataset) ((XYPlot)plot).getDataset()).getLabel(selectedSeries, selectedItems[j]);
174 174
									}
175 175
									// Progression
176 176
									else if(itemEntity.getDataset() instanceof XYSeriesCollection)	{
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/themes/base/swing/ItemSelectionJFCChartPanel.java (revision 647)
177 177

  
178 178
				// FIXME: this code must be moved to the CA plugin
179 179
				// FCA
180
//				if(((XYPlot)plot).getRenderer() instanceof FCAItemSelectionRenderer)	{
180
//				if(((XYPlot)plot).getRenderer() instanceof CAItemSelectionRenderer)	{
181 181
//
182 182
//					// Axis unit square ratio constraint
183 183
//					this.squareOffGraph();
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 647)
160 160
		this.cex = Math.abs(cex);
161 161
		if (col.matches(pattern)) {
162 162
			this.colfilter = col;
163
		} else {
163
		}
164
		else {
164 165
			System.out.println("Col filter malformed follow this pattern " + pattern);
165 166
		}
166 167
		
167 168
		if (row.matches(pattern)) {
168 169
			this.rowfilter = row;
169
		} else {
170
		}
171
		else {
170 172
			System.out.println("Row filter malformed follow this pattern " + pattern);
171 173
		}
172 174
	}
......
197 199
			for (int i  = 0 ; i < infos.length ; i++) {
198 200
				List<Object> list = (List<Object>) infos[i];
199 201
				writer.write(textseparator + list.get(0) + textseparator + colseparator);
200
				for (int j = 1 ; j < list.size() ; j++)
202
				for (int j = 1 ; j < list.size() ; j++) {
201 203
					writer.write(list.get(j) + colseparator);
204
				}
202 205
				writer.write("\n"); //$NON-NLS-1$
203 206
			}
204 207
			writer.flush();
......
580 583
	 * @throws StatException the stat exception
581 584
	 */
582 585
	public String[] getRowNames() throws StatException {
583
		if (rownames == null)
586
		if (rownames == null) {
584 587
			rownames = getLexicalTable().getRowNames().asStringsArray();
588
		}
585 589
		return rownames;
586 590
	}
587 591

  
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/renderers/FCAItemSelectionRenderer.java (revision 647)
1
package org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers;
2

  
3
import java.awt.Color;
4
import java.awt.Font;
5
import java.awt.Graphics2D;
6
import java.awt.Paint;
7
import java.awt.Shape;
8
import java.awt.font.GlyphVector;
9
import java.awt.geom.AffineTransform;
10
import java.awt.geom.Area;
11
import java.awt.geom.Rectangle2D;
12
import java.awt.geom.RoundRectangle2D;
13
import java.text.DecimalFormat;
14
import java.util.ArrayList;
15

  
16
import org.jfree.chart.labels.XYItemLabelGenerator;
17
import org.jfree.chart.labels.XYToolTipGenerator;
18
import org.jfree.data.xy.XYDataset;
19
import org.txm.ca.core.chartsengine.jfreechart.datasets.FCAXYDataset;
20
import org.txm.ca.core.functions.CA;
21
import org.txm.ca.core.messages.CACoreMessages;
22
import org.txm.chartsengine.core.ChartsEngine;
23
import org.txm.chartsengine.core.messages.ChartsEngineCoreMessages;
24
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection;
25
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.ItemSelectionXYLineAndShapeRenderer;
26
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.swing.CustomHTMLToolTip;
27

  
28
/**
29
 * Renderer providing item selection system and drawing features for selected item and custom rendering for CA charts.
30
 * @author sjacquot
31
 *
32
 */
33
public class FCAItemSelectionRenderer extends ItemSelectionXYLineAndShapeRenderer {
34

  
35

  
36
	/**
37
	 * Stack to store selected items to draw at last, over other items.
38
	 */
39
	protected ArrayList itemsToDrawAtLast; 
40
	
41
	/**
42
	 * Point shapes visibility.
43
	 */
44
	protected boolean shapesVisible;
45

  
46
	/**
47
	 * Creates a renderer dedicated to CA charts.
48
	 */
49
	public FCAItemSelectionRenderer(CA ca) {
50
		super();
51
		this.shapesVisible = false;
52
		this.multipleItemsSelector.setResultData(ca);
53
		this.setChartType(ChartsEngine.CHART_TYPE_CA_FACTORIAL_MAP);
54
	}
55

  
56

  
57

  
58
	@Override
59
	public void initToolTipGenerator(final IRendererWithItemSelection renderer)	{
60
		// Rows
61
		this.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
62

  
63
			@Override
64
			public String generateToolTip(XYDataset dataset, int series, int item) {
65

  
66
				try {
67
					// Coordinates format
68
					String pattern = new String("#.##");
69
					DecimalFormat format = new DecimalFormat(pattern);
70

  
71
					// Hexadecimal color
72
					Color color = (Color) getSeriesPaint(series);
73
					String hex = "#" + Integer.toHexString(color.getRGB()).substring(2);
74

  
75
					FCAXYDataset caDataset = (FCAXYDataset) dataset;
76
					return CustomHTMLToolTip.getDefaultHTMLBody(renderer, hex) + "<p style=\"color: " + hex + "\"><b>" + caDataset.getLabel(series, item) + "</b></p><p>"
77
							+ CACoreMessages.charts_factorialMap_tooltipRowsLabel + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>" + caDataset.getFrequency(series, item).replace("-", "") + "</b></p>"
78
					+ "<p>" +  CACoreMessages.charts_factorialMap_tooltipCoordinates + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>[" + format.format(caDataset.getX(series, item)) + ":" + format.format(caDataset.getY(series, item)) + "]</b></p></body><html>";
79
				}
80
				catch (Exception e) {
81
				}
82
				return "";
83
			}
84
		});
85

  
86
		// Columns
87
		this.setSeriesToolTipGenerator(1, new XYToolTipGenerator() {
88

  
89
			@Override
90
			public String generateToolTip(XYDataset dataset, int series, int item) {
91

  
92
				try {
93
					// Coordinates format
94
					String pattern = new String("#.##");
95
					DecimalFormat format = new DecimalFormat(pattern);
96

  
97
					// Hexadecimal color
98
					Color color = (Color) getSeriesPaint(series);
99
					String hex = "#" + Integer.toHexString(color.getRGB()).substring(2);
100

  
101
					FCAXYDataset caDataset = (FCAXYDataset) dataset;
102
					// FIXME: to disable tool tip we can return null here or in other renderers generateToolTip methods
103
//				return null;
104
					return CustomHTMLToolTip.getDefaultHTMLBody(renderer, hex) + "<p style=\"color: " + hex + "\"><b>" + caDataset.getLabel(series, item) + "</b></p><p>"
105
						+ CACoreMessages.charts_factorialMap_tooltipColsLabel + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>" + caDataset.getFrequency(series, item).replace("-", "") + "</b></p>"
106
					+ "<p>" + CACoreMessages.charts_factorialMap_tooltipCoordinates + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>[" + format.format(caDataset.getX(series, item)) + ":" + format.format(caDataset.getY(series, item)) + "]</b></p></body><html>";
107
				}
108
				catch (Exception e) {
109
				}
110
				return "";
111
			}
112
		});
113

  
114
	}
115

  
116

  
117
	@Override
118
	public void initItemLabelGenerator()	{
119
		XYItemLabelGenerator generator = new XYItemLabelGenerator() {
120

  
121
			@Override
122
			public String generateLabel(XYDataset dataset, int series, int item) {
123
				FCAXYDataset caDataset = (FCAXYDataset) dataset;
124
				return caDataset.getLabel(series, item);
125
			}
126
		};
127

  
128
		this.setBaseItemLabelGenerator(generator);
129
		this.setBaseItemLabelsVisible(true);
130
	}
131

  
132
	@Override
133
	public Font getItemLabelFont(int series, int item) {
134

  
135
		// regular
136
		Font font = super.getItemLabelFont(series, item);
137
		font = font.deriveFont(Font.PLAIN, font.getSize());
138

  
139
		// Change item label font size and style
140
		if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
141
			font = font.deriveFont(Font.BOLD, font.getSize() * 1.2f);
142
		}
143
		return font;
144
	}
145

  
146

  
147
	@Override
148
	public Shape getItemShape(int series, int item) {
149

  
150
		Shape s;
151

  
152
		// visible shapes mode
153
		if(this.shapesVisible)	{
154

  
155
			// Scale selected item shape
156
			s = super.getItemShape(series, item);
157
			
158
			// Highlight selected item
159
			if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
160

  
161
				// Add a background rectangle to the label selected item
162
				String label2 = ((FCAXYDataset) this.getPlot().getDataset()).getLabel(series, item);
163

  
164
				Font font2 = this.getItemLabelFont(series, item);
165
				Rectangle2D bounds2 = font2.getStringBounds(label2, ((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext());
166

  
167
				// FIXME : not rounded rectangle version
168
//				Shape labelBackground = new Rectangle2D.Double(-bounds.getWidth() / 2, -s.getBounds2D().getHeight() / 2 + 1, bounds.getWidth() + 4, bounds.getHeight() / 2 + 8);
169

  
170
				Shape labelBackground = new RoundRectangle2D.Double(-(bounds2.getWidth() + 4) / 2, -s.getBounds2D().getHeight() / 2 + 1, bounds2.getWidth() + 8, bounds2.getHeight() / 2 + 10, 5, 5);
171

  
172
				AffineTransform t = new AffineTransform();
173
				t.setToTranslation(0,  bounds2.getCenterY() - 2 - bounds2.getHeight() / 2);
174
				labelBackground = t.createTransformedShape(labelBackground);
175
				
176
				Area a = new Area(s);
177
				a.add(new Area(labelBackground));
178

  
179
				// FIXME : test de tooltip text à la main
180
//				Shape tooltip = new Rectangle2D.Double(10, 10, 50, 50);
181
//				GlyphVector text =  this.getBaseItemLabelFont().createGlyphVector(((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext(), "testteezrezrzerzerzerzerze");
182
////				t.setToTranslation(-100,  -200);
183
//				Shape textShape = t.createTransformedShape(text.getOutline());
184
//				a.add(new Area(tooltip));
185
//				a.add(new Area(textShape));
186
				
187
				return a;
188
			}
189

  
190
		}
191
		// non visible shapes mode, sets the shape as bounding box of the item label
192
		else	{
193
			String label = ((FCAXYDataset) this.getPlot().getDataset()).getLabel(series, item);
194

  
195
			Font font = this.getItemLabelFont(series, item);
196
			Rectangle2D bounds = font.getStringBounds(label, ((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext());
197
			s = new RoundRectangle2D.Double(-(bounds.getWidth()) / 2, -bounds.getHeight() / 2, bounds.getWidth(), bounds.getHeight() - 2 , 5, 5);
198
			
199
			// Highlight selected item
200
			if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
201
				AffineTransform t = new AffineTransform();
202
				t.setToScale(1.1f, 1.1f);
203
				s = t.createTransformedShape(s);
204
			}
205

  
206
		}
207

  
208
		return s;
209
	}
210

  
211

  
212
	@Override
213
	public Paint getItemPaint(int series, int item) {
214

  
215
		Color color = null;
216
		
217
		if(this.shapesVisible)	{
218
			color = (Color) super.getItemPaint(series, item);
219
	
220
			// Mouse over shape
221
			if(this.multipleItemsSelector.isMouseOverItem(series, item)) {
222
				return new Color(color.getRed(), color.getGreen(), color.getBlue(), 195);
223
			}
224
			// Multiple item selection
225
			else if(this.multipleItemsSelector.isSelectedItem(series, item))	{
226
				// FIXME: rendering tests
227
				//return new Color(255, 255, 255, 195);
228
				return new Color(color.getRed(), color.getGreen(), color.getBlue(), 140);
229
			}
230
		}
231
		else	{
232
			
233
			// Mouse over shape
234
			if(this.multipleItemsSelector.isMouseOverItem(series, item)) {
235
				color = new Color(255, 255, 255, 220);
236
			}
237
			// Multiple item selection
238
			else if(this.multipleItemsSelector.isSelectedItem(series, item))	{
239
				return new Color(255, 255, 255, 140);
240
			}
241
			else	{
242
				color = new Color(0, 0, 0, 0);	
243
			}
244
			
245
		}
246
		return color;
247
	}
248

  
249

  
250
	
251
	@Override
252
	public void updateDatasetForDrawingSelectedItemAsLast() {
253
		this.multipleItemsSelector.setItemDrawnAtLast(this);
254
	}
255

  
256

  
257

  
258
	/**
259
	 * @param shapesVisible the shapesVisible to set
260
	 */
261
	public void setShapesVisible(boolean shapesVisible) {
262
		this.shapesVisible = shapesVisible;
263
	}
264

  
265

  
266

  
267
}
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/renderers/CAItemSelectionRenderer.java (revision 647)
1
package org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers;
2

  
3
import java.awt.BasicStroke;
4
import java.awt.Color;
5
import java.awt.Font;
6
import java.awt.Graphics2D;
7
import java.awt.Paint;
8
import java.awt.Shape;
9
import java.awt.geom.AffineTransform;
10
import java.awt.geom.Area;
11
import java.awt.geom.Rectangle2D;
12
import java.awt.geom.RoundRectangle2D;
13
import java.text.DecimalFormat;
14
import java.util.ArrayList;
15

  
16
import org.jfree.chart.JFreeChart;
17
import org.jfree.chart.labels.XYItemLabelGenerator;
18
import org.jfree.chart.labels.XYToolTipGenerator;
19
import org.jfree.chart.title.LegendTitle;
20
import org.jfree.data.xy.XYDataset;
21
import org.txm.ca.core.chartsengine.jfreechart.datasets.CAXYDataset;
22
import org.txm.ca.core.functions.CA;
23
import org.txm.ca.core.messages.CACoreMessages;
24
import org.txm.chartsengine.core.ChartsEngine;
25
import org.txm.chartsengine.core.messages.ChartsEngineCoreMessages;
26
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine;
27
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection;
28
import org.txm.chartsengine.jfreechart.core.themes.base.BlockRoundBorder;
29
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.ItemSelectionXYLineAndShapeRenderer;
30
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.swing.CustomHTMLToolTip;
31

  
32
/**
33
 * Renderer providing item selection system and drawing features for selected item and custom rendering for CA charts.
34
 * @author sjacquot
35
 *
36
 */
37
public class CAItemSelectionRenderer extends ItemSelectionXYLineAndShapeRenderer {
38

  
39
	
40
	/**
41
	 * The linked chart.
42
	 */
43
	protected JFreeChart chart;
44

  
45
	/**
46
	 * Stack to store selected items to draw at last, over other items.
47
	 */
48
	protected ArrayList itemsToDrawAtLast; 
49
	
50
	
51
	
52
	/**
53
	 * Creates a renderer dedicated to CA charts.
54
	 */
55
	public CAItemSelectionRenderer(CA ca, JFreeChart chart) {
56
		super();
57
		this.chart = chart;
58
		this.multipleItemsSelector.setResult(ca);
59
		this.setChartType(ChartsEngine.CHART_TYPE_CA_FACTORIAL_MAP);
60
		
61
		
62
    	this.setBaseLinesVisible(false);
63
    	this.setBaseOutlinePaint(Color.decode("#666666"));
64

  
65
		
66
      	// Items colors (Highcharts color codes)
67
        Color blue = new Color(47, 126, 216, 90);
68
        this.setSeriesPaint(0, blue);
69
        Color red = new Color(255, 0, 0, 90);
70
        this.setSeriesPaint(1, red);
71

  
72
        // Create the fonts
73
        ((JFCChartsEngine) ca.getChartsEngine()).getJFCTheme().createFonts(ca);
74
        
75
		// Legends
76
		ArrayList<Color> palette = new ArrayList<Color>(2);
77
		palette.add(blue);
78
		palette.add(red);
79
		LegendTitle legendTitle = chart.getLegend(0);
80
		if (legendTitle != null) {
81
			legendTitle.setFrame(new BlockRoundBorder(Color.GRAY));
82
			((JFCChartsEngine) ca.getChartsEngine()).getJFCTheme().applyLegendDefaultSettings(legendTitle, false, false, palette);
83
		}
84
        
85
    	// Grid
86
		chart.getXYPlot().setDomainGridlineStroke(new BasicStroke(0.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] {2f}, 0f)); // Dashed
87
		chart.getXYPlot().setRangeGridlineStroke(chart.getXYPlot().getDomainGridlineStroke());
88
		chart.getXYPlot().setDomainZeroBaselineVisible(true);
89
		chart.getXYPlot().setRangeZeroBaselineVisible(true);
90
    	
91
    	// Axis
92
		chart.getXYPlot().getRangeAxis().setAxisLineVisible(true);
93
		chart.getXYPlot().getRangeAxis().setTickMarksVisible(true);
94
		chart.getXYPlot().getDomainAxis().setVerticalTickLabels(false);
95
		chart.getXYPlot().getDomainAxis().setAxisLineVisible(true);
96
  
97
	}
98

  
99

  
100

  
101
	@Override
102
	public void initToolTipGenerator(final IRendererWithItemSelection renderer)	{
103
		// Rows
104
		this.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
105

  
106
			@Override
107
			public String generateToolTip(XYDataset dataset, int series, int item) {
108

  
109
				try {
110
					// Coordinates format
111
					String pattern = new String("#.##");
112
					DecimalFormat format = new DecimalFormat(pattern);
113

  
114
					// Hexadecimal color
115
					Color color = (Color) getSeriesPaint(series);
116
					String hex = "#" + Integer.toHexString(color.getRGB()).substring(2);
117

  
118
					CAXYDataset caDataset = (CAXYDataset) dataset;
119
					return CustomHTMLToolTip.getDefaultHTMLBody(renderer, hex) + "<p style=\"color: " + hex + "\"><b>" + caDataset.getLabel(series, item) + "</b></p><p>"
120
							+ CACoreMessages.charts_factorialMap_tooltipRowsLabel + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>" + caDataset.getFrequency(series, item).replace("-", "") + "</b></p>"
121
					+ "<p>" +  CACoreMessages.charts_factorialMap_tooltipCoordinates + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>[" + format.format(caDataset.getX(series, item)) + ":" + format.format(caDataset.getY(series, item)) + "]</b></p></body><html>";
122
				}
123
				catch (Exception e) {
124
				}
125
				return "";
126
			}
127
		});
128

  
129
		// Columns
130
		this.setSeriesToolTipGenerator(1, new XYToolTipGenerator() {
131

  
132
			@Override
133
			public String generateToolTip(XYDataset dataset, int series, int item) {
134

  
135
				try {
136
					// Coordinates format
137
					String pattern = new String("#.##");
138
					DecimalFormat format = new DecimalFormat(pattern);
139

  
140
					// Hexadecimal color
141
					Color color = (Color) getSeriesPaint(series);
142
					String hex = "#" + Integer.toHexString(color.getRGB()).substring(2);
143

  
144
					CAXYDataset caDataset = (CAXYDataset) dataset;
145
					// FIXME: to disable tool tip we can return null here or in other renderers generateToolTip methods
146
//				return null;
147
					return CustomHTMLToolTip.getDefaultHTMLBody(renderer, hex) + "<p style=\"color: " + hex + "\"><b>" + caDataset.getLabel(series, item) + "</b></p><p>"
148
						+ CACoreMessages.charts_factorialMap_tooltipColsLabel + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>" + caDataset.getFrequency(series, item).replace("-", "") + "</b></p>"
149
					+ "<p>" + CACoreMessages.charts_factorialMap_tooltipCoordinates + ChartsEngineCoreMessages.charts_labelValueSeparator + " <b>[" + format.format(caDataset.getX(series, item)) + ":" + format.format(caDataset.getY(series, item)) + "]</b></p></body><html>";
150
				}
151
				catch (Exception e) {
152
				}
153
				return "";
154
			}
155
		});
156

  
157
	}
158

  
159

  
160
	@Override
161
	public void initItemLabelGenerator()	{
162
		XYItemLabelGenerator generator = new XYItemLabelGenerator() {
163

  
164
			@Override
165
			public String generateLabel(XYDataset dataset, int series, int item) {
166
				CAXYDataset caDataset = (CAXYDataset) dataset;
167
				return caDataset.getLabel(series, item);
168
			}
169
		};
170

  
171
		this.setBaseItemLabelGenerator(generator);
172
		this.setBaseItemLabelsVisible(true);
173
	}
174

  
175
	@Override
176
	public Font getItemLabelFont(int series, int item) {
177

  
178
		// regular
179
		Font font = super.getItemLabelFont(series, item);
180
		font = font.deriveFont(Font.PLAIN, font.getSize());
181

  
182
		// Change item label font size and style
183
		if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
184
			font = font.deriveFont(Font.BOLD, font.getSize() * 1.2f);
185
		}
186
		return font;
187
	}
188

  
189

  
190
	@Override
191
	public Shape getItemShape(int series, int item) {
192

  
193
		Shape s;
194

  
195
		// visible shapes mode
196
		if(((CA) this.multipleItemsSelector.getResult()).isShowPointShapes())	{
197

  
198
			// Scale selected item shape
199
			s = super.getItemShape(series, item);
200
			
201
			// Highlight selected item
202
			if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
203

  
204
				// Add a background rectangle to the label selected item
205
				String label2 = ((CAXYDataset) this.getPlot().getDataset()).getLabel(series, item);
206

  
207
				Font font2 = this.getItemLabelFont(series, item);
208
				Rectangle2D bounds2 = font2.getStringBounds(label2, ((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext());
209

  
210
				// FIXME : not rounded rectangle version
211
//				Shape labelBackground = new Rectangle2D.Double(-bounds.getWidth() / 2, -s.getBounds2D().getHeight() / 2 + 1, bounds.getWidth() + 4, bounds.getHeight() / 2 + 8);
212

  
213
				Shape labelBackground = new RoundRectangle2D.Double(-(bounds2.getWidth() + 4) / 2, -s.getBounds2D().getHeight() / 2 + 1, bounds2.getWidth() + 8, bounds2.getHeight() / 2 + 10, 5, 5);
214

  
215
				AffineTransform t = new AffineTransform();
216
				t.setToTranslation(0,  bounds2.getCenterY() - 2 - bounds2.getHeight() / 2);
217
				labelBackground = t.createTransformedShape(labelBackground);
218
				
219
				Area a = new Area(s);
220
				a.add(new Area(labelBackground));
221

  
222
				// FIXME : test de tooltip text à la main
223
//				Shape tooltip = new Rectangle2D.Double(10, 10, 50, 50);
224
//				GlyphVector text =  this.getBaseItemLabelFont().createGlyphVector(((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext(), "testteezrezrzerzerzerzerze");
225
////				t.setToTranslation(-100,  -200);
226
//				Shape textShape = t.createTransformedShape(text.getOutline());
227
//				a.add(new Area(tooltip));
228
//				a.add(new Area(textShape));
229
				
230
				return a;
231
			}
232

  
233
		}
234
		// non visible shapes mode, sets the shape as bounding box of the item label
235
		else	{
236
			String label = ((CAXYDataset) this.getPlot().getDataset()).getLabel(series, item);
237

  
238
			Font font = this.getItemLabelFont(series, item);
239
			Rectangle2D bounds = font.getStringBounds(label, ((Graphics2D) this.multipleItemsSelector.getChartPanel().getGraphics()).getFontRenderContext());
240
			s = new RoundRectangle2D.Double(-(bounds.getWidth()) / 2, -bounds.getHeight() / 2, bounds.getWidth(), bounds.getHeight() - 2 , 5, 5);
241
			
242
			// Highlight selected item
243
			if(this.multipleItemsSelector.isMouseOverItem(series, item) || this.multipleItemsSelector.isSelectedItem(series, item)) {
244
				AffineTransform t = new AffineTransform();
245
				t.setToScale(1.1f, 1.1f);
246
				s = t.createTransformedShape(s);
247
			}
248

  
249
		}
250

  
251
		return s;
252
	}
253

  
254

  
255
	@Override
256
	public Paint getItemPaint(int series, int item) {
257

  
258
		Color color = null;
259
		
260
		if(((CA) this.multipleItemsSelector.getResult()).isShowPointShapes())	{
261
			color = (Color) super.getItemPaint(series, item);
262
	
263
			// Mouse over shape
264
			if(this.multipleItemsSelector.isMouseOverItem(series, item)) {
265
				return new Color(color.getRed(), color.getGreen(), color.getBlue(), 195);
266
			}
267
			// Multiple item selection
268
			else if(this.multipleItemsSelector.isSelectedItem(series, item))	{
269
				// FIXME: rendering tests
270
				//return new Color(255, 255, 255, 195);
271
				return new Color(color.getRed(), color.getGreen(), color.getBlue(), 140);
272
			}
273
		}
274
		else	{
275
			
276
			// Mouse over shape
277
			if(this.multipleItemsSelector.isMouseOverItem(series, item)) {
278
				color = new Color(255, 255, 255, 220);
279
			}
280
			// Multiple item selection
281
			else if(this.multipleItemsSelector.isSelectedItem(series, item))	{
282
				return new Color(255, 255, 255, 140);
283
			}
284
			else	{
285
				color = new Color(0, 0, 0, 0);	
286
			}
287
			
288
		}
289
		return color;
290
	}
291

  
292

  
293
	
294
	@Override
295
	public void updateDatasetForDrawingSelectedItemAsLast() {
296
		this.multipleItemsSelector.setItemDrawnAtLast(this);
297
	}
298

  
299

  
300

  
301
}
0 302

  
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/renderers/CASingularValuesItemSelectionRenderer.java (revision 647)
35 35
	 */
36 36
	public CASingularValuesItemSelectionRenderer(CA ca) {
37 37
		super();
38
		this.mouseOverItemSelector.setResultData(ca);
38
		this.mouseOverItemSelector.setResult(ca);
39 39
		this.setChartType(ChartsEngine.CHART_TYPE_CA_SINGULAR_VALUES);
40 40

  
41 41
		this.percentValuesNumberFormat = new DecimalFormat("#.00");
......
58 58
				Number value = catDataset.getValue(row, column);
59 59

  
60 60

  
61
				CA ca = (CA) getItemsSelector().getResultData();
61
				CA ca = (CA) getItemsSelector().getResult();
62 62
				List<List<Object>> singularValuesData = ca.getSingularValuesInfos();
63 63

  
64 64
				return CustomHTMLToolTip.getDefaultHTMLBody(renderer, hex) + "<p>#" + catDataset.getColumnKey(column) + "</p>"
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCCAChartCreator.java (revision 647)
10 10

  
11 11
import org.jfree.chart.ChartFactory;
12 12
import org.jfree.chart.JFreeChart;
13
import org.jfree.chart.annotations.XYAnnotation;
14 13
import org.jfree.chart.annotations.XYLineAnnotation;
15 14
import org.jfree.chart.labels.ItemLabelAnchor;
16 15
import org.jfree.chart.labels.ItemLabelPosition;
17 16
import org.jfree.chart.plot.PlotOrientation;
18 17
import org.jfree.chart.plot.XYPlot;
19
import org.jfree.chart.title.LegendTitle;
20 18
import org.jfree.data.xy.XYDataset;
21 19
import org.jfree.ui.TextAnchor;
22 20
import org.txm.ca.core.chartsengine.base.CAChartCreator;
23 21
import org.txm.ca.core.chartsengine.base.Utils;
24
import org.txm.ca.core.chartsengine.jfreechart.datasets.FCAXYDataset;
25
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.FCAItemSelectionRenderer;
22
import org.txm.ca.core.chartsengine.jfreechart.datasets.CAXYDataset;
23
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.CAItemSelectionRenderer;
26 24
import org.txm.ca.core.functions.CA;
27 25
import org.txm.ca.core.messages.CACoreMessages;
28 26
import org.txm.ca.core.preferences.CAPreferences;
......
30 28
import org.txm.chartsengine.core.results.ChartResult;
31 29
import org.txm.chartsengine.jfreechart.core.JFCChartCreator;
32 30
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector;
33
import org.txm.chartsengine.jfreechart.core.themes.base.BlockRoundBorder;
34 31
import org.txm.core.preferences.TXMPreferences;
35 32
import org.txm.statsengine.core.StatException;
36 33
import org.txm.utils.logger.Log;
......
46 43
	@Override
47 44
	public JFreeChart createChart(ChartResult result) {
48 45

  
49
		
50 46
		CA ca = (CA) result;
51
		
52
		// parameters
53
//		boolean monochrome = (TXMPreferences.getInt(preferencesNode, resultData, ChartsEnginePreferences.RENDERING_COLORS_MODE, ChartsEnginePreferences.PREFERENCES_NODE)
54
//				== ChartsEngine.RENDERING_MONOCHROME_MODE);
55
//		boolean monostyle = TXMPreferences.getBoolean(preferencesNode, resultData, CAPreferences.CHART_MONO_STYLE);
56
//		boolean cumulative = TXMPreferences.getBoolean(preferencesNode, resultData, CAPreferences.CHART_CUMULATIVE);
57
		
58
		
59 47
		JFreeChart chart  = null;
60 48

  
61 49
		try {
62
			FCAXYDataset dataset = new FCAXYDataset(ca);
50
			CAXYDataset dataset = new CAXYDataset(ca);
63 51

  
64 52
//			DecimalFormat f = new DecimalFormat("###.00"); //$NON-NLS-1$
65 53
//			double singularValuesSum = ca.getValeursPropresSum();
......
76 64
					CAPreferences.PREFERENCES_NODE), false, false);
77 65

  
78 66
			// Custom renderer
79
			chart.getXYPlot().setRenderer(new FCAItemSelectionRenderer(ca));
67
			chart.getXYPlot().setRenderer(new CAItemSelectionRenderer(ca, chart));
80 68
		}
81 69
		catch(StatException e) {
82 70
			Log.severe("Can't create CA factorial map scatter plot" + e);
......
98 86
		chart.setNotify(false);
99 87
		
100 88
		
101
		FCAItemSelectionRenderer renderer = (FCAItemSelectionRenderer) chart.getXYPlot().getRenderer(); 
102
   	 	XYPlot plot = chart.getXYPlot();
89
		CAItemSelectionRenderer renderer = (CAItemSelectionRenderer) chart.getXYPlot().getRenderer(); 
90
   	 //	XYPlot plot = chart.getXYPlot();
103 91
		
104 92
		
105 93
		renderer.setSeriesVisible(0, ca.isShowVariables());
......
110 98

  
111 99
		this.updateChartCAFactorialMapSetDimensions(ca);
112 100
		
113

  
114

  
115
		
116
    	renderer.setBaseLinesVisible(false);
117
    	renderer.setBaseOutlinePaint(Color.decode("#666666"));
118
    	
119
      	// Items colors (Highcharts color codes)
120
        Color blue = new Color(47, 126, 216, 90);
121
        renderer.setSeriesPaint(0, blue);
122

  
123
        Color red = new Color(255, 0, 0, 90);
124
        renderer.setSeriesPaint(1, red);
125

  
126

  
127
        // Legends
128
        ArrayList<Color> palette = new ArrayList<Color>(2);
129
        palette.add(blue);
130
        palette.add(red);
131
        LegendTitle legendTitle = chart.getLegend(0);
132
    	if(legendTitle != null)	{
133
    		legendTitle.setFrame(new BlockRoundBorder(Color.GRAY));
134
        	this.getChartsEngine().getJFCTheme().applyLegendDefaultSettings(legendTitle, false, false, palette);
135
    	}
136

  
137

  
138
    	// Grid
139
    	plot.setRangeGridlineStroke(plot.getDomainGridlineStroke());
140
    	plot.setDomainZeroBaselineVisible(true);
141
    	plot.setRangeZeroBaselineVisible(true);
142
    	
143
    	// Axis
144
     	plot.getRangeAxis().setAxisLineVisible(true);
145
    	plot.getRangeAxis().setTickMarksVisible(true);
146
		plot.getDomainAxis().setVerticalTickLabels(false);
147
		
148
  
149
        
150
        renderer.setShapesVisible(ca.isShowPointShapes());
151
        renderer.setBaseLinesVisible(false);
152
        
101
//        
153 102
        // Draw the point shapes and the item labels
154 103
        if(ca.isShowPointShapes())	{
155 104
            
......
192 141
        
193 142

  
194 143
		super.updateChart(result);
195

  
144
		//this.getChartsEngine().getJFCTheme().apply(chart);
196 145
    	
197 146
    	// FIXME
198 147
    //	this.getChartsEngine().squareOffGraph((JFreeChart) chart, 200, 200d);
......
210 159
		XYPlot plot = chart.getXYPlot();
211 160

  
212 161
		// Remove all existent annotations
213
		for(int i = plot.getAnnotations().size() - 1; i >= 0; i--) {
214
			plot.removeAnnotation((XYAnnotation) plot.getAnnotations().get(i));
215
		}
162
		plot.clearAnnotations();
163
//		for(int i = plot.getAnnotations().size() - 1; i >= 0; i--) {
164
//			plot.removeAnnotation((XYAnnotation) plot.getAnnotations().get(i));
165
//		}
216 166

  
217 167

  
218 168
        // Gets the extreme coordinates values
......
228 178
		// FIXME: old version, to remove when new version will be validated
229 179
		// Rows
230 180
		if(plot.getRenderer().isSeriesVisible(0))	{
231
			minX = ((FCAXYDataset)plot.getDataset()).getMinX(0);
181
			minX = ((CAXYDataset)plot.getDataset()).getMinX(0);
232 182
		}
233 183
		// Cols
234 184
		if(plot.getRenderer().isSeriesVisible(1))	{
235
			double tmpMinX = ((FCAXYDataset)plot.getDataset()).getMinX(1);
185
			double tmpMinX = ((CAXYDataset)plot.getDataset()).getMinX(1);
236 186
			if(tmpMinX < minX)	{
237 187
				minX = tmpMinX;
238 188
			}
......
240 190

  
241 191
		// Rows
242 192
		if(plot.getRenderer().isSeriesVisible(0))	{
243
			maxX = ((FCAXYDataset)plot.getDataset()).getMaxX(0);
193
			maxX = ((CAXYDataset)plot.getDataset()).getMaxX(0);
244 194
		}
245 195
		// Cols
246 196
		if(plot.getRenderer().isSeriesVisible(1))	{
247
			double tmpMaxX = ((FCAXYDataset)plot.getDataset()).getMaxX(1);
197
			double tmpMaxX = ((CAXYDataset)plot.getDataset()).getMaxX(1);
248 198
			if(tmpMaxX > maxX)	{
249 199
				maxX = tmpMaxX;
250 200
			}
......
252 202

  
253 203
		// Rows
254 204
		if(plot.getRenderer().isSeriesVisible(0))	{
255
			minY = ((FCAXYDataset)plot.getDataset()).getMinY(0);
205
			minY = ((CAXYDataset)plot.getDataset()).getMinY(0);
256 206
		}
257 207
		// Cols
258 208
		if(plot.getRenderer().isSeriesVisible(1))	{
259
			double tmpMinY = ((FCAXYDataset)plot.getDataset()).getMinY(1);
209
			double tmpMinY = ((CAXYDataset)plot.getDataset()).getMinY(1);
260 210
			if(tmpMinY < minY)	{
261 211
				minY = tmpMinY;
262 212
			}
......
264 214

  
265 215
		// Rows
266 216
		if(plot.getRenderer().isSeriesVisible(0))	{
267
			maxY = ((FCAXYDataset)plot.getDataset()).getMaxY(0);
217
			maxY = ((CAXYDataset)plot.getDataset()).getMaxY(0);
268 218
		}
269 219
		// Cols
270 220
		if(plot.getRenderer().isSeriesVisible(1))	{
271
			double tmpMaxY = ((FCAXYDataset)plot.getDataset()).getMaxY(1);
221
			double tmpMaxY = ((CAXYDataset)plot.getDataset()).getMaxY(1);
272 222
			if(tmpMaxY > maxY)	{
273 223
				maxY = tmpMaxY;
274 224
			}
......
312 262
	@Override
313 263
	public void updateChartCAFactorialMapHighlightPoints(Object chart, boolean rows, String[] labels) {
314 264

  
315
		MultipleItemsSelector selector = (MultipleItemsSelector) ((FCAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
265
		MultipleItemsSelector selector = (MultipleItemsSelector) ((CAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
316 266

  
317 267
		// Rows
318 268
		int series = 0;
......
321 271
			series = 1;
322 272
		}
323 273
		selector.removeAllSelectedItems(series);
324
		int[] items = ((FCAXYDataset)((JFreeChart) chart).getXYPlot().getDataset()).getLabelIndices(series, labels);
274
		int[] items = ((CAXYDataset)((JFreeChart) chart).getXYPlot().getDataset()).getLabelIndices(series, labels);
325 275

  
326 276
		for(int i = 0; i < items.length; i++) {
327 277
			selector.addSelectedItem(series, items[i]);
......
340 290
		JFreeChart chart = (JFreeChart) ca.getChart();
341 291
		
342 292
		 // Modify data set
343
		 ((FCAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset()).setAxis1(dimension1);
344
		 ((FCAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset()).setAxis2(dimension2);
293
		 ((CAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset()).setAxis1(dimension1);
294
		 ((CAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset()).setAxis2(dimension2);
345 295

  
346 296
		 // Update axis labels
347 297
		 // FIXME : create a method in CA to directly get a singular value as percent ?
......
373 323
	@Override
374 324
	public ArrayList<String> getCAFactorialMapChartSelectedPoints(Object chart, int series) {
375 325

  
376
		MultipleItemsSelector selector = (MultipleItemsSelector) ((FCAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
326
		MultipleItemsSelector selector = (MultipleItemsSelector) ((CAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
377 327
		ArrayList<String> pointLabels = new ArrayList<String>(selector.getSelectedItemsCount(series));
378 328

  
379 329
		if(selector.getSelectedItemsCount(series) > 0)	{
380 330

  
381
			FCAXYDataset dataset = (FCAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset();
331
			CAXYDataset dataset = (CAXYDataset) ((JFreeChart) chart).getXYPlot().getDataset();
382 332
			int[] selectedItems = selector.getSelectedItems(series);
383 333

  
384 334
			for(int i = 0; i < selectedItems.length; i++) {
......
394 344
	@Override
395 345
	public void updateChartCAFactorialMapSetLabelItemsSelectionOrder(Object chart, String[] rowLabels, String[] colLabels) {
396 346
		
397
		MultipleItemsSelector selector = (MultipleItemsSelector) ((FCAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
398
		selector.setCyclicItemsOrder(this.getItemsAndSeriesOrderedByLabels((FCAXYDataset)((JFreeChart) chart).getXYPlot().getDataset(), rowLabels, colLabels)); 
347
		MultipleItemsSelector selector = (MultipleItemsSelector) ((CAItemSelectionRenderer)((JFreeChart) chart).getXYPlot().getRenderer()).getItemsSelector();
348
		selector.setCyclicItemsOrder(this.getItemsAndSeriesOrderedByLabels((CAXYDataset)((JFreeChart) chart).getXYPlot().getDataset(), rowLabels, colLabels)); 
399 349
	}
400 350

  
401 351
	
......
404 354
	 * @param dataset
405 355
	 * @return
406 356
	 */
407
	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, String[] rowLabels, String[] colLabels)	{
357
	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(CAXYDataset dataset, String[] rowLabels, String[] colLabels)	{
408 358
		
409 359
		TreeMap<Object, ArrayList<Integer>> orderedValues = new TreeMap<Object, ArrayList<Integer>>();
410 360
		
......
447 397
//				allFlattenValues.put((int) dataset.getXValue(i, j), itemData);
448 398

  
449 399

  
450
				// Test FCAXYDataset
400
				// Test CAXYDataset
451 401
				
452 402
				// FIXME: tests, navigation clavier par ordre alphabétique d'une AFC (toute séries confondues)
453
				String label = ((FCAXYDataset)dataset).getLabel(i,  j);
403
				String label = ((CAXYDataset)dataset).getLabel(i,  j);
454 404
				allFlattenValues.put(label, itemData);
455 405
				
456 406
				// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
......
498 448
	 * @return
499 449
	 */
500 450
	// FIXME: tests
501
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset)	{
451
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(CAXYDataset dataset)	{
502 452
//		return this.getItemsAndSeriesOrderedByLabels(dataset, false, false);
503 453
//	}
504 454
//	
......
507 457
	 * @param dataset
508 458
	 * @return
509 459
	 */
510
	// FIXME: tests, became useless ? (since we can give labels order with getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, String[] rowLabels, String[] colLabels)) )
511
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, boolean rowsReverse, boolean colsReverse)	{
460
	// FIXME: tests, became useless ? (since we can give labels order with getItemsAndSeriesOrderedByLabels(CAXYDataset dataset, String[] rowLabels, String[] colLabels)) )
461
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(CAXYDataset dataset, boolean rowsReverse, boolean colsReverse)	{
512 462
//		
513 463
//		Comparator rowsComparator;
514 464
//		Comparator colsComparator;
......
536 486
//			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
537 487
//			itemData.add(0); // series
538 488
//			itemData.add(i); // item
539
//			allFlattenRowsValues.put(((FCAXYDataset)dataset).getLabel(0,  i), itemData);
489
//			allFlattenRowsValues.put(((CAXYDataset)dataset).getLabel(0,  i), itemData);
540 490
//			
541 491
//			// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
542 492
//			//allFlattenRowsValues.put(dataset.getX(0, j), itemData);
......
548 498
//			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
549 499
//			itemData.add(1); // series
550 500
//			itemData.add(i); // item
551
//			allFlattenColsValues.put(((FCAXYDataset)dataset).getLabel(1,  i), itemData);
501
//			allFlattenColsValues.put(((CAXYDataset)dataset).getLabel(1,  i), itemData);
552 502
//			
553 503
//			// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
554 504
//			//allFlattenColsValues.put(dataset.getX(1, j), itemData);
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCSingularValueChartCreator.java (revision 647)
53 53
		}
54 54
		catch(StatException e) {
55 55
			Log.severe(CACoreMessages.charts_error_singularValues_cantCreateSingularValuesChart + e);
56
			Log.printStackTrace(e);
56 57
		}
57 58

  
58 59

  
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/datasets/FCAXYDataset.java (revision 647)
1
package org.txm.ca.core.chartsengine.jfreechart.datasets;
2

  
3
import org.jfree.data.xy.AbstractXYDataset;
4
import org.jfree.data.xy.XYDataset;
5
import org.txm.ca.core.functions.CA;
6
import org.txm.ca.core.messages.CACoreMessages;
7
import org.txm.statsengine.core.StatException;
8

  
9
/**
10
 * XY data set for storing coordinates and frequencies of CA plots.  
11
 * @author sjacquot
12
 *
13
 */
14
// TODO: some CA data are duplicated in this data set. We could directly use the CA methods here
15
// rather than copy some data but the performances due off access may be altered, however we would gain memory.
16
public class FCAXYDataset extends AbstractXYDataset implements XYDataset { 
17

  
18
	/**
19
	 * The linked CA result.
20
	 */
21
	protected CA ca;
22
	
23
	/**
24
	 * The row labels.
25
	 */
26
	protected String[] rowLabels;
27
	
28
	/**
29
	 * The column labels.
30
	 */
31
	protected String[] columnLabels;
32
	
33
	
34
	/**
35
	 * The row coordinates. 
36
	 */
37
	protected double rowCoordinates[][];
38
	
39
	/**
40
	 * The column coordinates.
41
	 */
42
	protected double columnCoordinates[][];
43
	
44
	
45
	/**
46
	 * The row frequencies.	
47
	 */
48
	protected int[] rowFrequencies;
49
	
50
	
51
	/**
52
	 * The column frequencies. 
53
	 */
54
	protected int[] columnFrequencies;
55

  
56
	/**
57
	 * First axis for point coordinates.
58
	 */
59
	protected int axis1;
60

  
61
	/**
62
	 * Second axis for point coordinates.
63
	 */
64
	protected int axis2;
65

  
66

  
67
	/**
68
	 * Creates a data set from the specified CA result.
69
	 * @param ca
70
	 * @throws StatException 
71
	 */
72
	public FCAXYDataset(CA ca) throws StatException {
73

  
74
		this.ca = ca;
75
		
76
		// Axis/dimensions
77
		this.axis1 = ca.getFirstDimension() - 1;
78
		this.axis2 = ca.getSecondDimension() - 1;
79
		
80
		// Labels
81
		this.rowLabels = ca.getRowNames();
82
		this.columnLabels = ca.getColNames();
83

  
84
		// Coordinates
85
		this.rowCoordinates = ca.getRowsCoords();
86
		this.columnCoordinates = ca.getColsCoords();
87

  
88
		// Frequencies
89
		this.rowFrequencies = ca.getLexicalTable().getRowMarginsVector().asIntArray();
90
		this.columnFrequencies = ca.getLexicalTable().getColMarginsVector().asIntArray();
91

  
92
	}
93

  
94

  
95
	@Override
96
	public Number getX(int series, int item) {
97
		if(item == -1)	{
98
			System.out.println("FCAXYDataset.getX()");
99
		}
100
		// Rows
101
		if(series == 0) {
102
			return this.rowCoordinates[item][this.axis1];
103
		}
104
		// Cols
105
		else {
106
			return this.columnCoordinates[item][this.axis1];
107
		}
108
	}
109

  
110
	@Override
111
	public Number getY(int series, int item) {
112
		// Rows
113
		if(series == 0) {
114
			return this.rowCoordinates[item][this.axis2];
115
		}
116
		// Cols
117
		else {
118
			return this.columnCoordinates[item][this.axis2];
119
		}
120

  
121
	}
122

  
123

  
124
	/**
125
	 * Gets the maximum X coordinates value in the specified series.
126
	 * @param series
127
	 * @return
128
	 */
129
	public double getMaxX(int series)	{
130
		return this.getMaxValue(series, this.axis1);
131
	}
132
	
133

  
134
	/**
135
	 * Gets the maximum Y coordinates value in the specified series.
136
	 * @param series
137
	 * @return
138
	 */
139
	public double getMaxY(int series)	{
140
		return this.getMaxValue(series, this.axis2);
141
	}
142

  
143

  
144
	/**
145
	 * Gets the maximum value in the specified series according to the specified axis.
146
	 * @param series
147
	 * @param axis
148
	 * @return
149
	 */
150
	public double getMaxValue(int series, int axis)	{
151

  
152
		double maxValue = 0;
153
		double tmpMaxValue;
154

  
155
		double[][] coordinates = this.rowCoordinates;
156
		if(series != 0)	{
157
			coordinates = this.columnCoordinates;
158
		}
159
		
160
		for(int i = 0; i < coordinates.length; i++) {
161
			tmpMaxValue = coordinates[i][axis];
162
			if(tmpMaxValue > maxValue)	{
163
				maxValue = tmpMaxValue;
164
			}
165
		}
166

  
167
		return maxValue;
168
	}
169
	
170
	
171
	
172
	/**
173
	 * Gets the minimum X coordinates value in the specified series.
174
	 * @param series
175
	 * @return
176
	 */
177
	public double getMinX(int series)	{
178
		return this.getMinValue(series, this.axis1);
179
	}
180
	
181

  
182
	/**
183
	 * Gets the minimum Y coordinates value in the specified series.
184
	 * @param series
185
	 * @return
186
	 */
187
	public double getMinY(int series)	{
188
		return this.getMinValue(series, this.axis2);
189
	}
190

  
191
	
192
	/**
193
	 * Gets the minimum value in the specified series according to the specified axis.
194
	 * @param series
195
	 * @param axis
196
	 * @return
197
	 */
198
	public double getMinValue(int series, int axis)	{
199

  
200
		double minValue = 0;
201
		double tmpMinValue;
202

  
203
		double[][] coordinates = this.rowCoordinates;
204
		if(series != 0)	{
205
			coordinates = this.columnCoordinates;
206
		}
207
		
208
		for(int i = 0; i < coordinates.length; i++) {
209
			tmpMinValue = coordinates[i][axis];
210
			if(tmpMinValue < minValue)	{
211
				minValue = tmpMinValue;
212
			}
213
		}
214

  
215
		return minValue;
216
	}
217
	
218
	
219
	@Override
220
	public int getSeriesCount() {
221
		return 2;
222
	}
223

  
224
	@Override
225
	public int getItemCount(int series) {
226
		// Rows
227
		if(series == 0) {
228
			return this.rowCoordinates.length;
229
		}
230
		// Cols
231
		else {
232
			return this.columnCoordinates.length;
233
		}
234
	}
235

  
236
	/**
237
	 * Gets the key of the specified series.
238
	 */
239
	public Comparable getSeriesKey(int series) {
240
		// Rows
241
		if(series == 0) {
242
			return CACoreMessages.charts_factorialMap_legendRowsLabel;
243
		}
244
		// Cols
245
		else {
246
			return CACoreMessages.charts_factorialMap_legendColumnsLabel;
247
		}
248
	}
249

  
250
	/**
251
	 * Gets the label of a point.
252
	 * @param series
253
	 * @param item
254
	 * @return
255
	 */
256
	public String getLabel(int series, int item) {
257
		// Rows
258
		if(series == 0) {
259
			return this.rowLabels[item];
260
		}
261
		// Cols
262
		else {
263
			return this.columnLabels[item];
264
		}
265
	}
266

  
267
	
268
	/**
269
	 * Gets the indices of point from their labels.
270
	 * @param series
271
	 * @param label
272
	 * @return
273
	 */
274
	public int[] getLabelIndices(int series, String[] labels)	{
275
		int[] indices = new int[labels.length];
276
	
277
		// Rows
278
		if(series == 0) {
279
			for(int i = 0, j = 0; i < this.rowLabels.length; i++) {
280
				for(int k = 0; k < labels.length; k++) {
281
					if(this.rowLabels[i].equals(labels[k]))	{
282
						indices[j++] = i;
283
					}
284
				}
285
			}
286
		}
287
		// Cols
288
		else {
289
			for(int i = 0, j = 0; i < this.columnLabels.length; i++) {
290
				for(int k = 0; k < labels.length; k++) {
291
					if(this.columnLabels[i].equals(labels[k]))	{
292
						indices[j++] = i;
293
					}
294
				}
295
			}
296
		}
297
		
298
		return indices;
299
	}
300
	
301
	/**
302
	 * Gets the indices of point from their labels keeping the specified label order.
303
	 * @param series
304
	 * @param labels
305
	 * @return
306
	 */
307
	public int[] getOrderedLabelIndices(int series, String[] labels)	{
308
		int[] indices = new int[labels.length];
309
		
310
		// Rows
311
		if(series == 0) {
312
			for(int i = 0, k = 0; i < labels.length; i++) {
313
				for(int j = 0; j < this.rowLabels.length; j++) {
314
					if(this.rowLabels[j].equals(labels[i]))	{
315
						indices[k++] = j;
316
						continue;
317
					}
318
				}
319
			}
320
		}
321
		// Cols
322
		else {
323
			for(int i = 0, k = 0; i < labels.length; i++) {
324
				for(int j = 0; j < this.columnLabels.length; j++) {
325
					if(this.columnLabels[j].equals(labels[i]))	{
326
						indices[k++] = j;
327
						continue;
328
					}
329
				}
330
			}
331
		}
332
		
333
		return indices;
334
	}
335
	
336
	
337
	
338
	/**
339
	 * Gets the frequency of the specified series and items.
340
	 * If <code>series</code> is equal to 0, the method returns the frequency of the specified row, otherwise the sum of the occurrences of the specified column.
341
	 * @param series
342
	 * @param item
343
	 * @return
344
	 */
345
	public String getFrequency(int series, int item) {
346
		// Rows
347
		if(series == 0) {
348
			return String.valueOf(this.rowFrequencies[item]);
349
		}
350
		// Columns
351
		else {
352
			return String.valueOf(this.columnFrequencies[item]);
353
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff