Revision 914

tmp/org.txm.chartsengine.graphstream.rcp/build.properties (revision 914)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.chartsengine.graphstream.rcp/plugin.xml (revision 914)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.txm.rcp.swtchartscomponentsprovider">
6
      <SWTChartsComponentsProvider
7
            class="org.txm.chartsengine.graphstream.rcp.GSSWTChartsComponentsProvider"
8
            inputFormat="GraphStream/Java2D"
9
            name="GS SWT Charts Components Provider">
10
      </SWTChartsComponentsProvider>
11
   </extension>
12

  
13
</plugin>
0 14

  
tmp/org.txm.chartsengine.graphstream.rcp/.settings/org.eclipse.jdt.core.prefs (revision 914)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4
org.eclipse.jdt.core.compiler.compliance=1.7
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.7
0 8

  
tmp/org.txm.chartsengine.graphstream.rcp/.classpath (revision 914)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
9
	<classpathentry kind="src" path="src"/>
10
	<classpathentry kind="output" path="bin"/>
11
</classpath>
0 12

  
tmp/org.txm.chartsengine.graphstream.rcp/META-INF/MANIFEST.MF (revision 914)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: GraphStream Charts Engine RCP
4
Bundle-SymbolicName: org.txm.chartsengine.graphstream.rcp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Vendor: Textometrie.org
7
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
8
Require-Bundle: org.txm.chartsengine.graphstream.core;bundle-version="1.0.0";visibility:=reexport,
9
 org.txm.chartsengine.rcp;bundle-version="1.0.0";visibility:=reexport,
10
 org.txm.rcp;bundle-version="0.7.8";visibility:=reexport,
11
 org.txm.cooccurrence.core;bundle-version="1.0.0";visibility:=reexport
12
Export-Package: org.txm.chartsengine.graphstream.rcp,
13
 org.txm.chartsengine.graphstream.rcp.swing,
14
 org.txm.chartsengine.graphstream.rcp.swt
0 15

  
tmp/org.txm.chartsengine.graphstream.rcp/.project (revision 914)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.chartsengine.graphstream.rcp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/swing/GSChartComponent.java (revision 914)
1
/**
2
 * 
3
 */
4
package org.txm.chartsengine.graphstream.rcp.swing;
5

  
6
import java.awt.event.MouseEvent;
7

  
8
import org.graphstream.ui.swingViewer.DefaultView;
9
import org.graphstream.ui.view.Viewer;
10
import org.txm.chartsengine.rcp.IChartComponent;
11
import org.txm.chartsengine.rcp.editors.ChartEditor;
12

  
13
/**
14
 * GraphStream Chart Component.
15
 * 
16
 * @author sjacquot
17
 *
18
 */
19
public class GSChartComponent extends DefaultView implements IChartComponent {
20

  
21

  
22
	protected double zoomFactor = 0.1;
23
	
24
	
25
	/**
26
	 * 
27
	 * @param viewer
28
	 */
29
	public GSChartComponent(Viewer viewer) {
30
		super(viewer, Viewer.DEFAULT_VIEW_ID, Viewer.newGraphRenderer());
31
	}
32

  
33
	
34
	public void reinit(Viewer viewer)	{
35
		if(this.viewer != null)	{
36
			this.viewer.close();
37
		}
38
		this.viewer = viewer;
39
		this.graph = viewer.getGraphicGraph();
40
		this.renderer = Viewer.newGraphRenderer();
41

  
42
		setOpaque(false);
43
		setDoubleBuffered(true);
44
		setMouseManager(null);
45
		setShortcutManager(null);
46
		this.renderer.open(this.graph, this);
47
	}
48
	
49
	/* (non-Javadoc)
50
	 * @see org.txm.chartsengine.rcp.IChartComponent#zoom(double, double, boolean)
51
	 */
52
	@Override
53
	public void zoom(double x, double y, boolean zoomIn) {
54
		double percent = zoomFactor;
55
		if(zoomIn)	{
56
			percent = -percent;
57
		}
58
		this.getCamera().setViewPercent(this.getCamera().getViewPercent() + percent);
59
	}
60

  
61
	/* (non-Javadoc)
62
	 * @see org.txm.chartsengine.rcp.IChartComponent#resetView()
63
	 */
64
	@Override
65
	public void resetView() {
66
		this.getCamera().setViewPercent(1);
67
	}
68

  
69
	/* (non-Javadoc)
70
	 * @see org.txm.chartsengine.rcp.IChartComponent#pan(double, double, double, double, double)
71
	 */
72
	@Override
73
	public void pan(double srcX, double srcY, double dstX, double dstY, double panFactor) {
74
		// TODO Auto-generated method stub
75

  
76
	}
77

  
78
	/* (non-Javadoc)
79
	 * @see org.txm.chartsengine.rcp.IChartComponent#getChartEditor()
80
	 */
81
	@Override
82
	public ChartEditor getChartEditor() {
83
		// TODO Auto-generated method stub
84
		return null;
85
	}
86

  
87
	/* (non-Javadoc)
88
	 * @see org.txm.chartsengine.rcp.IChartComponent#setChartEditor(org.txm.chartsengine.rcp.editors.ChartEditor)
89
	 */
90
	@Override
91
	public void setChartEditor(ChartEditor editor) {
92
		// TODO Auto-generated method stub
93

  
94
	}
95

  
96
	/* (non-Javadoc)
97
	 * @see org.txm.chartsengine.rcp.IChartComponent#updateMouseOverItem(java.awt.event.MouseEvent)
98
	 */
99
	@Override
100
	public void updateMouseOverItem(MouseEvent event) {
101
		// TODO Auto-generated method stub
102

  
103
	}
104

  
105
	/* (non-Javadoc)
106
	 * @see org.txm.chartsengine.rcp.IChartComponent#squareOff()
107
	 */
108
	@Override
109
	public void squareOff() {
110
		// TODO Auto-generated method stub
111

  
112
	}
113

  
114
	/* (non-Javadoc)
115
	 * @see org.txm.chartsengine.rcp.IChartComponent#setSquareOffEnabled(boolean)
116
	 */
117
	@Override
118
	public void setSquareOffEnabled(boolean enabled) {
119
		// TODO Auto-generated method stub
120

  
121
	}
122

  
123
	
124
	public Viewer getViewer()	{
125
		return this.viewer;
126
	}
127

  
128
	
129
}
0 130

  
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/GSSWTChartsComponentsProvider.java (revision 914)
1
/**
2
 * 
3
 */
4
package org.txm.chartsengine.graphstream.rcp;
5

  
6
import java.io.File;
7
import java.util.ArrayList;
8
import java.util.Properties;
9

  
10
import org.eclipse.swt.widgets.Composite;
11
import org.graphstream.graph.Graph;
12
import org.graphstream.graph.implementations.SingleGraph;
13
import org.graphstream.ui.view.Viewer;
14
import org.txm.chartsengine.core.ChartsEngine;
15
import org.txm.chartsengine.graphstream.rcp.swing.GSChartComponent;
16
import org.txm.chartsengine.graphstream.rcp.swt.GSComposite;
17
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
18
import org.txm.chartsengine.rcp.editors.ChartEditor;
19
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
20
import org.txm.chartsengine.rcp.swt.ChartComposite;
21

  
22
/**
23
 * @author sjacquot
24
 *
25
 */
26
public class GSSWTChartsComponentsProvider extends SWTChartsComponentsProvider {
27

  
28
	/**
29
	 * @param chartsEngine
30
	 * @param mouseBindingProperties
31
	 * @param keyboardBindingProperties
32
	 */
33
	public GSSWTChartsComponentsProvider(ChartsEngine chartsEngine, Properties mouseBindingProperties, Properties keyboardBindingProperties) {
34
		super(chartsEngine, mouseBindingProperties, keyboardBindingProperties);
35
		// TODO Auto-generated constructor stub
36
	}
37

  
38
	/**
39
	 * @param chartsEngine
40
	 */
41
	public GSSWTChartsComponentsProvider(ChartsEngine chartsEngine) {
42
		super(chartsEngine);
43
		// TODO Auto-generated constructor stub
44
	}
45

  
46
	/**
47
	 * 
48
	 */
49
	public GSSWTChartsComponentsProvider() {
50
		super();
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see org.txm.chartsengine.rcp.SWTChartsComponentsProvider#createChartContainer(org.txm.chartsengine.core.ChartsEngine, org.txm.chartsengine.rcp.editors.ChartEditorInput)
55
	 */
56
	@Override
57
	protected boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
58
		if (!chartEditorInput.getResult().isChartDirty()) {
59
			
60
			//System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); // Pour les fonctionnalités avancées des CSS
61
			
62
	
63
			// creating a dummy graph (the viewer can not have a null graph)
64
			Graph graph = new SingleGraph("dummy"); //$NON-NLS-1$
65
			
66
			// FIXME: tests
67
//			Generator gen = new DorogovtsevMendesGenerator();
68
//	    	gen.addSink(graph);
69
//	    	gen.begin();
70
//	    	for(int i=0; i<500; i++) {
71
//	    	    gen.nextEvents();
72
//	    	}
73
//	    	gen.end();
74
//	    	
75
//	        for (Node node : graph) {
76
//	        	node.addAttribute("ui.label", node.getId());
77
//	            //node.setAttribute("ui.size", 5);
78
////	    		node.addAttribute("ui.style", "fill-color: 0.5; size: 5px;");
79
//	        }
80
//			
81
//	        //graph.display();
82
          
83
			//Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
84
			Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
85
			viewer.enableAutoLayout();
86
			//graph.display();
87
			GSChartComponent chartComponent = new GSChartComponent(viewer);
88
			viewer.addView(chartComponent);
89
			chartEditorInput.setChartContainer(chartComponent);
90
			
91
			// sets and updates the local preferences node qualifier from the result data
92
			chartEditorInput.syncLocalPreferencesNode();
93
			
94
			return true;
95
		}
96
		return false;
97
	}
98

  
99
	@Override
100
	public ChartComposite createComposite(ChartEditor chartEditor, Composite parent) {
101
		return new GSComposite(chartEditor, parent);
102
	}
103

  
104

  
105
	@Override
106
	public ArrayList<String> getEditorSupportedExportFileFormats()	{
107
		return this.chartsEngine.getSupportedOutputFileFormats();
108
	}
109

  
110

  
111
	@Override
112
	public ArrayList<String> getChartsEngineSupportedExportFileFormats() {
113
		return this.chartsEngine.getSupportedOutputFileFormats();
114
	}
115

  
116

  
117
	@Override
118
	public File exportView(ChartEditor chartEditor, File file, String fileFormat) {
119
		// FIXME: not yet implemented
120
		System.err.println("GSSWTChartsComponentsProvider.exportView(): not yet implemented.");
121
		return null;
122
	}
123

  
124
}
0 125

  
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/swt/GSComposite.java (revision 914)
1
/**
2
 * 
3
 */
4
package org.txm.chartsengine.graphstream.rcp.swt;
5

  
6
import org.eclipse.swt.SWT;
7
import org.eclipse.swt.widgets.Composite;
8
import org.graphstream.graph.Graph;
9
import org.graphstream.ui.swingViewer.DefaultView;
10
import org.graphstream.ui.view.Viewer;
11
import org.txm.chartsengine.core.results.ChartResult;
12
import org.txm.chartsengine.graphstream.rcp.swing.GSChartComponent;
13
import org.txm.chartsengine.rcp.editors.ChartEditor;
14
import org.txm.chartsengine.rcp.swt.SwingChartComposite;
15

  
16
/**
17
 * GraphStream chart composite.
18
 * @author sjacquot
19
 *
20
 */
21
public class GSComposite extends SwingChartComposite {
22

  
23
	/**
24
	 * @param chartEditor
25
	 * @param parent
26
	 * @param style
27
	 */
28
	public GSComposite(ChartEditor<ChartResult> chartEditor, Composite parent) {
29
		super(chartEditor, parent, SWT.EMBEDDED);
30
		// TODO Auto-generated constructor stub
31
		
32
		
33
		
34
//   	 JPanel pane1 = new JPanel();
35
//	 Viewer v = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
36
//	 v.a
37
	 
38
//     v.enableAutoLayout();
39
//     ViewPanel view = v.addDefaultView(false);
40
//     pane1.setLayout(new BorderLayout());
41
//      pane1.add(view,BorderLayout.CENTER);
42
	}
43

  
44
	@Override
45
	public void loadChart(Object data) {
46
		Graph graph = (Graph) data;
47
		
48
//		System.err.println("GSComposite.loadChart(): " + graph.getId());
49
//		
50
//		if(graph.getId().equals("dummy"))	{
51
		
52
		 //Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
53
		Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
54
		 viewer.enableAutoLayout();
55
////		 //v.enableXYZfeedback(true);
56
		//viewer.removeView(Viewer.DEFAULT_VIEW_ID);
57
		viewer.addView(((DefaultView) this.chartComponent));
58
		
59
		((GSChartComponent) this.chartComponent).reinit(viewer);
60

  
61
//		}
62
		// FIXME: tests (opening a Frame with the graph but be careful, closing the Frame closes the entire RCP app)
63
		//graph.display();
64
	}
65

  
66
	@Override
67
	public void clearChartItemsSelection() {
68
		// TODO Auto-generated method stub
69

  
70
	}
71

  
72
	@Override
73
	public Object getChart() {
74
		return ((GSChartComponent) this.chartComponent).getViewer().getGraphicGraph();
75
	}
76

  
77
}
0 78

  

Also available in: Unified diff