Revision 191

tmp/org.txm.chartsengine.jfreechart.core/META-INF/MANIFEST.MF (revision 191)
6 6
Require-Bundle: jfreechart;bundle-version="1.0.17";visibility:=reexport,
7 7
 org.eclipse.core.runtime,
8 8
 org.txm.chartsengine.core;bundle-version="1.0.0";visibility:=reexport,
9
 org.txm.core,
10
 org.txm.ca.core
9
 org.txm.core
11 10
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
12 11
Bundle-ActivationPolicy: lazy
13 12
Export-Package: org.txm.chartsengine.jfreechart.core,
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/themes/highcharts/defaulttheme/HighchartsDefaultTheme.java (revision 191)
39 39
import org.jfree.ui.RectangleEdge;
40 40
import org.jfree.ui.RectangleInsets;
41 41
import org.jfree.util.ShapeUtilities;
42
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.CASingularValuesItemSelectionRenderer;
43
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.FCAItemSelectionRenderer;
44 42
import org.txm.chartsengine.core.ChartsEngine;
45 43
import org.txm.chartsengine.jfreechart.core.renderers.XYCardinalSplineRenderer;
46 44
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer;
......
240 238

  
241 239
	        // CA Factorial Map chart
242 240
	    	// FIXME: done now in the chart creator
243
	        if(renderer instanceof FCAItemSelectionRenderer)	{
244
//
245
//	        	((FCAItemSelectionRenderer)renderer).setBaseLinesVisible(false);
246
//	        	renderer.setBaseOutlinePaint(Color.decode("#666666"));
247
//
248
//		    	// Labels position
249
//		    	ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0);
250
//		    	renderer.setBasePositiveItemLabelPosition(position);
251
//		    	renderer.setBaseNegativeItemLabelPosition(position);
252
//
253
//		    	// Zero base lines
254
//				plot.setDomainZeroBaselineVisible(true);
255
//				plot.setRangeZeroBaselineVisible(true);
256
//
257
//		    	// Items colors (Highcharts color codes)
258
//		        Color blue = new Color(47, 126, 216, 90);
259
//		        renderer.setSeriesPaint(0, blue);
260
//
261
//		        Color red = new Color(255, 0, 0, 90);
262
//		        renderer.setSeriesPaint(1, red);
263
//
264
//		        // Legends
265
//		    	if(legendTitle != null)	{
266
//		    		legendTitle.setFrame(new BlockRoundBorder(Color.GRAY));
267
//		    	}
268
	        }
269
	        // Not a CA Factorial Map chart
270
	        else	{
241
//	        if(renderer instanceof FCAItemSelectionRenderer)	{
242
////
243
////	        	((FCAItemSelectionRenderer)renderer).setBaseLinesVisible(false);
244
////	        	renderer.setBaseOutlinePaint(Color.decode("#666666"));
245
////
246
////		    	// Labels position
247
////		    	ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0);
248
////		    	renderer.setBasePositiveItemLabelPosition(position);
249
////		    	renderer.setBaseNegativeItemLabelPosition(position);
250
////
251
////		    	// Zero base lines
252
////				plot.setDomainZeroBaselineVisible(true);
253
////				plot.setRangeZeroBaselineVisible(true);
254
////
255
////		    	// Items colors (Highcharts color codes)
256
////		        Color blue = new Color(47, 126, 216, 90);
257
////		        renderer.setSeriesPaint(0, blue);
258
////
259
////		        Color red = new Color(255, 0, 0, 90);
260
////		        renderer.setSeriesPaint(1, red);
261
////
262
////		        // Legends
263
////		    	if(legendTitle != null)	{
264
////		    		legendTitle.setFrame(new BlockRoundBorder(Color.GRAY));
265
////		    	}
266
//	        }
267
//	        // Not a CA Factorial Map chart
268
//	        else	{
271 269

  
272 270
	        	// Items colors
273 271
	        	this.applySeriesPaint(plot, itemsColorsRenderingMode);
......
321 319
		    	}
322 320

  
323 321

  
324
	        }
322
	     //   }
325 323

  
326 324

  
327 325
	        // Series shapes
......
663 661

  
664 662

  
665 663
 
666
	@Override
667
	public XYLineAndShapeRenderer createFCARenderer() {
668
		return new FCAItemSelectionRenderer();
669
	}
670 664

  
671 665

  
672 666
	@Override
673
	public BarRenderer createCASingularValuesRenderer()	{
674
		return new CASingularValuesItemSelectionRenderer();
675
	}
676

  
677

  
678
	@Override
679 667
	public XYLineAndShapeRenderer createXYLineAndShapeRenderer(boolean linesVisible, boolean shapesVisible) {
680 668
		return new ItemSelectionXYLineAndShapeRenderer(linesVisible, shapesVisible);
681 669
	}
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/renderers/MultipleItemsSelector.java (revision 191)
3 3
 */
4 4
package org.txm.chartsengine.jfreechart.core.renderers;
5 5

  
6
import java.text.Collator;
7 6
import java.util.ArrayList;
8 7
import java.util.HashMap;
9 8
import java.util.Iterator;
......
16 15
import org.jfree.chart.event.RendererChangeEvent;
17 16
import org.jfree.chart.plot.CategoryPlot;
18 17
import org.jfree.chart.plot.XYPlot;
19
import org.jfree.data.xy.XYDataset;
20
import org.txm.ca.core.chartsengine.jfreechart.datasets.FCAXYDataset;
21 18
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer;
22 19

  
23 20
/**
......
282 279
	}
283 280

  
284 281
	
285
	/**
286
	 * Gets a map where the values of the dataset are orderer by X item value and flatten despite of the series.
287
	 * @param dataset
288
	 * @return
289
	 */
290
	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByXValues(XYDataset dataset)	{
291
		HashMap<Object, ArrayList<Integer>> allFlattenValues = new HashMap<Object, ArrayList<Integer>>();
292
		for(int i = 0; i < dataset.getSeriesCount(); i++) {
293
			for(int j = 0; j < dataset.getItemCount(i); j++) {
294
				ArrayList<Integer> itemData = new ArrayList<Integer>(2);
295
				itemData.add(i); // series
296
				itemData.add(j); // item
297
				
298
				// FIXME: tests, navigation clavier sur toutes les courbes en même temps d'une Progression (tri sur la valeur X du dataset, toute séries confondues)
299
//				allFlattenValues.put((int) dataset.getXValue(i, j), itemData);
300 282

  
301

  
302
				// Test FCAXYDataset
303
				
304
				// FIXME: tests, navigation clavier par ordre alphabétique d'une AFC (toute séries confondues)
305
				String label = ((FCAXYDataset)dataset).getLabel(i,  j);
306
				allFlattenValues.put(label, itemData);
307
				
308
				// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
309
				//allFlattenValues.put(dataset.getX(i, j), itemData);
310
				
311
			}
312
		}
313

  
314

  
315
		// FIXME: tests, navigation clavier sur toutes les courbes en même temps d'une Progression
316
	//	TreeMap<Object, ArrayList<Integer>> orderedValues = new TreeMap<Object, ArrayList<Integer>>(allFlattenValues);
317

  
318
		// FIXME: tests, navigation clavier par ordre alphabétique d'une AFC
319
		TreeMap<Object, ArrayList<Integer>> orderedValues = new TreeMap<Object, ArrayList<Integer>>(Collator.getInstance());
320
		orderedValues.putAll(allFlattenValues);
321

  
322
		
323
		// FIXME : comparator tests
324
//		TreeMap<String, Integer> treemap = new TreeMap<String, Integer>(new Comparator<String>() {
325
//		    public int compare(String o1, String o2) {
326
//		        return o1.toLowerCase().compareTo(o2.toLowerCase());
327
//		    }
328
//		});
329
		
330
		
331
		// FIXME: DEbug
332
//		Set cles = orderedValues.keySet();
333
//		System.err.println("MultipleItemsSelector.getItemsAndSeriesOrderedByXValues() size: " + orderedValues.size());
334
//		Iterator<Integer> it = cles.iterator();
335
//		while(it.hasNext())	{
336
//			Object key = it.next();
337
//			ArrayList<Integer> value = orderedValues.get(key);
338
//			System.out.println("MultipleItemsSelector.getItemsAndSeriesOrdererByXValues(): item position = " + key + " series = " + value.get(0) + " item = " + value.get(1));
339
//		}
340

  
341
		return orderedValues;
342
	}
343 283
	
344

  
345
	
346 284
	/**
347
	 * Gets a map where the values of the dataset are ordered according to the specified label arrays, keeping the order of these arrays and flatten but grouped by series.
348
	 * @param dataset
349
	 * @return
350
	 */
351
	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, String[] rowLabels, String[] colLabels)	{
352
		
353
		TreeMap<Object, ArrayList<Integer>> orderedValues = new TreeMap<Object, ArrayList<Integer>>();
354
		
355
		int[] rowIndices = dataset.getOrderedLabelIndices(0, rowLabels);
356
		int[] colIndices = dataset.getOrderedLabelIndices(1, colLabels);
357
		
358
		int i = 0;
359
		for(; i < rowIndices.length; i++) {
360
			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
361
			itemData.add(0); // series
362
			itemData.add(rowIndices[i]); // item
363
			orderedValues.put(i, itemData);
364
		}
365
		for(int j = 0; j < colIndices.length; j++) {
366
			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
367
			itemData.add(1); // series
368
			itemData.add(colIndices[j]); // item
369
			orderedValues.put(j + i, itemData);
370
		}
371
	
372
		return orderedValues;
373
	}
374

  
375
	
376
	/**
377
	 * Gets a map where the values of the dataset are orderer by label and flatten but grouped by series.
378
	 * @param dataset
379
	 * @return
380
	 */
381
	// FIXME: tests
382
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset)	{
383
//		return this.getItemsAndSeriesOrderedByLabels(dataset, false, false);
384
//	}
385
//	
386
	/**
387
	 *  Gets a map where the values of the dataset are orderer by label and flatten but grouped by series.
388
	 * @param dataset
389
	 * @return
390
	 */
391
	// FIXME: tests, became useless ? (since we can give labels order with getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, String[] rowLabels, String[] colLabels)) )
392
//	public TreeMap<Object, ArrayList<Integer>> getItemsAndSeriesOrderedByLabels(FCAXYDataset dataset, boolean rowsReverse, boolean colsReverse)	{
393
//		
394
//		Comparator rowsComparator;
395
//		Comparator colsComparator;
396
//		
397
//		if(rowsReverse)	{
398
//			rowsComparator = Collections.reverseOrder(Collator.getInstance());
399
//		}
400
//		else	{
401
//			rowsComparator = Collator.getInstance();
402
//		}
403
//
404
//		if(colsReverse)	{
405
//			colsComparator = Collections.reverseOrder(Collator.getInstance());
406
//		}
407
//		else	{
408
//			colsComparator = Collator.getInstance();
409
//		}
410
//
411
//		
412
//		TreeMap<Object, ArrayList<Integer>> allFlattenRowsValues = new TreeMap<Object, ArrayList<Integer>>(rowsComparator);
413
//		TreeMap<Object, ArrayList<Integer>> allFlattenColsValues = new TreeMap<Object, ArrayList<Integer>>(colsComparator);
414
//
415
//		// sort the rows by label
416
//		for(int i = 0; i < dataset.getItemCount(0); i++) {
417
//			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
418
//			itemData.add(0); // series
419
//			itemData.add(i); // item
420
//			allFlattenRowsValues.put(((FCAXYDataset)dataset).getLabel(0,  i), itemData);
421
//			
422
//			// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
423
//			//allFlattenRowsValues.put(dataset.getX(0, j), itemData);
424
//		}
425
//		
426
//		
427
//		// sort the cols by label
428
//		for(int i = 0; i < dataset.getItemCount(1); i++) {
429
//			ArrayList<Integer> itemData = new ArrayList<Integer>(2);
430
//			itemData.add(1); // series
431
//			itemData.add(i); // item
432
//			allFlattenColsValues.put(((FCAXYDataset)dataset).getLabel(1,  i), itemData);
433
//			
434
//			// FIXME: tests, navigation clavier par coord X d'une AFC (toute séries confondues)
435
//			//allFlattenColsValues.put(dataset.getX(1, j), itemData);
436
//		}
437
//
438
//		
439
//		
440
//		// FIXME: tests, navigation clavier par ordre alphabétique d'une AFC
441
//		TreeMap<Object, ArrayList<Integer>> orderedValues = new TreeMap<Object, ArrayList<Integer>>();
442
////		if(revertedOrder)	{
443
////			orderedValues = new TreeMap(Collections.reverseOrder());
444
////		}
445
//		
446
//		
447
//		// put the rows order
448
//		int i = 0;
449
//		Set keys = allFlattenRowsValues.keySet();
450
//		Iterator<Integer> it = keys.iterator();
451
//		while(it.hasNext())	{
452
//			Object key = it.next();
453
//			orderedValues.put(i, allFlattenRowsValues.get(key));
454
//			i++;
455
//		}
456
//		// put the cols order
457
//		keys = allFlattenColsValues.keySet();
458
//		it = keys.iterator();
459
//		while(it.hasNext())	{
460
//			Object key = it.next();
461
//			orderedValues.put(i, allFlattenColsValues.get(key));
462
//			i++;
463
//		}
464
//
465
//		
466
//		
467
//		//orderedValues.putAll(allFlattenRowsValues);
468
//
469
//		
470
//		// FIXME : comparator tests
471
////		TreeMap<String, Integer> treemap = new TreeMap<String, Integer>(new Comparator<String>() {
472
////		    public int compare(String o1, String o2) {
473
////		        return o1.toLowerCase().compareTo(o2.toLowerCase());
474
////		    }
475
////		});
476
//		
477
//		
478
//		// FIXME: DEbug
479
////		keys = orderedValues.keySet();
480
////		System.err.println("MultipleItemsSelector.getItemsAndSeriesOrderedByXValues() size: " + orderedValues.size());
481
////		it = keys.iterator();
482
////		while(it.hasNext())	{
483
////			Object key = it.next();
484
////			ArrayList<Integer> value = orderedValues.get(key);
485
////			System.out.println("MultipleItemsSelector.getItemsAndSeriesOrdererByXValues(): item position = " + key + " series = " + value.get(0) + " item = " + value.get(1));
486
////		}
487
//
488
//		return orderedValues;
489
//	}
490
	
491
	/**
492 285
	 * Selects or adds the next item (according to the last previous selected item) in the selection.
493 286
	 * @param extendedSelection
494 287
	 */
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/renderers/MouseOverItemSelector.java (revision 191)
9 9
import org.jfree.chart.event.RendererChangeEvent;
10 10
import org.jfree.chart.plot.SeriesRenderingOrder;
11 11
import org.jfree.chart.plot.XYPlot;
12
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.FCAItemSelectionRenderer;
13 12
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer;
14 13
import org.txm.chartsengine.jfreechart.core.themes.highcharts.defaulttheme.renderers.ItemSelectionXYLineAndShapeRenderer;
15 14

  
......
291 290
		return item;
292 291
	}
293 292
	
294
	/**
295
	 * Changes the CA plot series rendering order according the selected series in item selector.
296
	 * @param renderer
297
	 */
298
	public void setItemDrawnAtLast(FCAItemSelectionRenderer renderer)	{
299
		
300
		if(this.mouseOverSeries != -1) {
301
			
302
			XYPlot plot = (XYPlot) this.renderer.getPlot();
303
			
304
			// FIXME: it swaps only between rows and cols order but we may manage order of item inside same series
305
			// Changing the rendering order
306
			if(this.mouseOverSeries == 0)	{
307
				// Row
308
				plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
309
			}
310
			else	{
311
				// Col
312
				plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
313
			}
314

  
315
			
316
			
317
//			// FIXME : test de tracé d'un background pour les labels des points en passant par une annotation
318
			// exemple de tracé
319
//			this.getPlot().addAnnotation(new XYAnnotation() {
293
//	/**
294
//	 * Changes the CA plot series rendering order according the selected series in item selector.
295
//	 * @param renderer
296
//	 */
297
//	public void setItemDrawnAtLast(FCAItemSelectionRenderer renderer)	{
298
//		
299
//		if(this.mouseOverSeries != -1) {
300
//			
301
//			XYPlot plot = (XYPlot) this.renderer.getPlot();
302
//			
303
//			// FIXME: it swaps only between rows and cols order but we may manage order of item inside same series
304
//			// Changing the rendering order
305
//			if(this.mouseOverSeries == 0)	{
306
//				// Row
307
//				plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
308
//			}
309
//			else	{
310
//				// Col
311
//				plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
312
//			}
320 313
//
321
//				@Override
322
//				public void removeChangeListener(AnnotationChangeListener listener) {
323
//					// TODO Auto-generated method stub
324
//
325
//				}
326
//
327
//				@Override
328
//				public void addChangeListener(AnnotationChangeListener listener) {
329
//					// TODO Auto-generated method stub
330
//
331
//				}
332
//
333
//				@Override
334
//				public void draw(Graphics2D g2, XYPlot plot,
335
//						Rectangle2D dataArea, ValueAxis domainAxis,
336
//						ValueAxis rangeAxis, int rendererIndex,
337
//						PlotRenderingInfo info) {
338
//					g2.setColor(Color.red);
339
//					g2.fillRect(itemSelector.getXCoord(), itemSelector.getYCoord(), 50, 20);
340
//
341
//				}
342
//			});
343
		}
344
		
345
	}
314
//			
315
//			
316
////			// FIXME : test de tracé d'un background pour les labels des points en passant par une annotation
317
//			// exemple de tracé
318
////			this.getPlot().addAnnotation(new XYAnnotation() {
319
////
320
////				@Override
321
////				public void removeChangeListener(AnnotationChangeListener listener) {
322
////					// TODO Auto-generated method stub
323
////
324
////				}
325
////
326
////				@Override
327
////				public void addChangeListener(AnnotationChangeListener listener) {
328
////					// TODO Auto-generated method stub
329
////
330
////				}
331
////
332
////				@Override
333
////				public void draw(Graphics2D g2, XYPlot plot,
334
////						Rectangle2D dataArea, ValueAxis domainAxis,
335
////						ValueAxis rangeAxis, int rendererIndex,
336
////						PlotRenderingInfo info) {
337
////					g2.setColor(Color.red);
338
////					g2.fillRect(itemSelector.getXCoord(), itemSelector.getYCoord(), 50, 20);
339
////
340
////				}
341
////			});
342
//		}
343
//		
344
//	}
346 345

  
347 346
	
348 347
	public void setItemDrawnAtLast(ItemSelectionXYLineAndShapeRenderer itemSelectionXYLineAndShapeRenderer) {

Also available in: Unified diff