Révision 905

tmp/org.txm.cooccurrence.chartsengine/src/org/txm/cooccurrence/functions/CooccurrenceGraph.java (revision 905)
1
package org.txm.cooccurrence.functions;
2
/**
3
 * 
4
 */
5

  
6

  
7
import java.io.File;
8

  
9
import org.txm.chartsengine.core.results.ChartResult;
10
import org.txm.core.results.TXMParameters;
11
import org.txm.core.results.TXMResult;
12

  
13
/**
14
 * @author sjacquot
15
 *
16
 */
17
public class CooccurrenceGraph extends ChartResult {
18

  
19
	/**
20
	 * @param parent
21
	 */
22
	public CooccurrenceGraph(TXMResult parent) {
23
		super(parent);
24
		// TODO Auto-generated constructor stub
25
	}
26

  
27
	/**
28
	 * @param uuid
29
	 */
30
	public CooccurrenceGraph(String uuid) {
31
		super(uuid);
32
		// TODO Auto-generated constructor stub
33
	}
34

  
35
	/**
36
	 * @param uuid
37
	 * @param parent
38
	 */
39
	public CooccurrenceGraph(String uuid, TXMResult parent) {
40
		super(uuid, parent);
41
		// TODO Auto-generated constructor stub
42
	}
43

  
44
	/* (non-Javadoc)
45
	 * @see org.txm.core.results.TXMResult#saveParameters()
46
	 */
47
	@Override
48
	public boolean saveParameters() throws Exception {
49
		// TODO Auto-generated method stub
50
		return true;
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see org.txm.core.results.TXMResult#loadParameters()
55
	 */
56
	@Override
57
	public boolean loadParameters() throws Exception {
58
		// TODO Auto-generated method stub
59
		return true;
60
	}
61

  
62
	/* (non-Javadoc)
63
	 * @see org.txm.core.results.TXMResult#setParameters(org.txm.core.results.TXMParameters)
64
	 */
65
	@Override
66
	public boolean setParameters(TXMParameters parameters) throws Exception {
67
		// TODO Auto-generated method stub
68
		return true;
69
	}
70

  
71
	/* (non-Javadoc)
72
	 * @see org.txm.core.results.TXMResult#getName()
73
	 */
74
	@Override
75
	public String getName() {
76
		// TODO Auto-generated method stub
77
		return "graph";
78
	}
79

  
80
	/* (non-Javadoc)
81
	 * @see org.txm.core.results.TXMResult#getSimpleName()
82
	 */
83
	@Override
84
	public String getSimpleName() {
85
		// TODO Auto-generated method stub
86
		return "graph";
87
	}
88

  
89
	/* (non-Javadoc)
90
	 * @see org.txm.core.results.TXMResult#getDetails()
91
	 */
92
	@Override
93
	public String getDetails() {
94
		// TODO Auto-generated method stub
95
		return "graph";
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see org.txm.core.results.TXMResult#clean()
100
	 */
101
	@Override
102
	public void clean() {
103
		// TODO Auto-generated method stub
104

  
105
	}
106

  
107
	/* (non-Javadoc)
108
	 * @see org.txm.core.results.TXMResult#canCompute()
109
	 */
110
	@Override
111
	public boolean canCompute() throws Exception {
112
		// TODO Auto-generated method stub
113
		return true;
114
	}
115

  
116
	/* (non-Javadoc)
117
	 * @see org.txm.core.results.TXMResult#_compute()
118
	 */
119
	@Override
120
	protected boolean _compute() throws Exception {
121
		// TODO Auto-generated method stub
122
		return true;
123
	}
124

  
125
	/* (non-Javadoc)
126
	 * @see org.txm.core.results.TXMResult#toTxt(java.io.File, java.lang.String, java.lang.String, java.lang.String)
127
	 */
128
	@Override
129
	public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
130
		// TODO Auto-generated method stub
131
		return false;
132
	}
133

  
134
}
0 135

  
tmp/org.txm.cooccurrence.chartsengine/src/org/txm/cooccurrence/editors/CooccurrenceGraphEditor.java (revision 905)
1
package org.txm.cooccurrence.editors;
2

  
3
import org.txm.chartsengine.rcp.editors.ChartEditor;
4
import org.txm.cooccurrence.functions.CooccurrenceGraph;
5

  
6
/**
7
 * Cooccurrence graph chart editor.
8
 * 
9
 * @author sjacquot
10
 *
11
 */
12
public class CooccurrenceGraphEditor extends ChartEditor<CooccurrenceGraph> {
13

  
14

  
15
	@Override
16
	public void updateEditorFromChart(boolean update) {
17
		// nothing to do
18
	}
19

  
20
	@Override
21
	public void __createPartControl() {
22
		// TODO Auto-generated method stub
23
		
24
	}
25
	
26
	
27
}
0 28

  
tmp/org.txm.cooccurrence.chartsengine/src/org/txm/cooccurrence/chartsengine/CooccurrenceGSChartCreator.java (revision 905)
1
package org.txm.cooccurrence.chartsengine;
2
/**
3
 * 
4
 */
5

  
6

  
7
import java.awt.Color;
8
import java.util.ArrayList;
9

  
10
import org.graphstream.graph.Graph;
11
import org.graphstream.graph.Node;
12
import org.graphstream.graph.implementations.SingleGraph;
13
import org.txm.chartsengine.core.results.ChartResult;
14
import org.txm.chartsengine.graphstream.core.GSChartCreator;
15
import org.txm.cooccurrence.core.functions.Cooccurrence;
16
import org.txm.cooccurrence.functions.CooccurrenceGraph;
17

  
18
/**
19
 * Cooccurrence graph chart creator.
20
 * 
21
 * @author sjacquot
22
 *
23
 */
24
public class CooccurrenceGSChartCreator extends GSChartCreator {
25

  
26
	/**
27
	 * 
28
	 */
29
	public CooccurrenceGSChartCreator() {
30
		// TODO Auto-generated constructor stub
31
	}
32

  
33
	/* (non-Javadoc)
34
	 * @see org.txm.chartsengine.core.ChartCreator#createChart(org.txm.chartsengine.core.results.ChartResult)
35
	 */
36
	@Override
37
	public Object createChart(ChartResult result) {
38

  
39
		   String styleSheet =
40
	                "node {" +
41
	                "	fill-mode: dyn-plain;" + 
42
	                "   fill-color: grey;" +
43
	                "	size-mode: dyn-size;" + 
44
	            	"	size: 5px;" + 
45
//	                "   size: 30px, 30px;" +
46
//	                "   text-size: 12px;" +
47
//	                "   shape: freeplane;" +
48
//	      //          "   size-mode: fit;" +
49
//	                "   fill-mode: none;" +
50
//	                "   stroke-mode: plain;" +
51
	                "}" +
52
	                "edge {" +
53
	                "   shape: cubic-curve;" +
54

  
55

  
56

  
57
//	                "   stroke-mode: plain;" +
58
	                
59
	                "}" +
60
	                /*"node.marked {" +
61
	                "   fill-color: red;" +
62
	                "}" +*/
63
	                
64
	                "node.titre {" +
65
	                "   size: 55px, 45px;" +
66
	                "   fill-color: blue;" +
67
	                "   text-color: red;" +
68
	                "   shape: diamond;" +
69
	                "}" +
70

  
71
	                "node.axe {" +
72
	                "   fill-color: blue;" +
73
	                "   text-color: blue;" +
74
	                "   shape: box;" +
75
	                "}" +
76
	                /*
77
	                "node.mot {" +
78
	                "   fill-color: green;" +
79
	                "   text-color: green;" +
80
	                "}" +*/
81
	                "node.auteur {" +
82
	                "   fill-color: red;" +
83
	                "   text-color: gray;" +
84
	                "   shape: diamond;" +
85
	                "}";
86
		
87
		
88
		Cooccurrence cooccurrence = (Cooccurrence) result.getParent();
89
		//Graph graph = (Graph) result.getChart();
90
		
91
		Graph graph = new SingleGraph(cooccurrence.getSimpleName());
92
		graph.addAttribute("ui.stylesheet", styleSheet);
93

  
94
		
95
//		graph.clear();
96
//		graph.clearSinks();
97
//	  	
98
//		Generator gen = new DorogovtsevMendesGenerator();
99
//    	gen.addSink(graph);
100
//    	gen.begin();
101
//    	for(int i=0; i<500; i++) {
102
//    	    gen.nextEvents();
103
//    	}
104
//    	gen.end();
105

  
106
		//graph.addAttribute("ui.stylesheet", styleSheet);
107
		//System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); // Pour les fonctionnalités avancées des CSS
108

  
109
		int maxSize = 20;
110
		
111
		// add query node
112
		Node rootNode = graph.addNode(cooccurrence.getQuery().getQueryString());
113
		rootNode.addAttribute("ui.size", 5);
114
		rootNode.addAttribute("ui.color", Color.RED);
115
		
116
		// add cooccurrents nodes
117
		for (int i = 0; i < cooccurrence.getLines().size(); i++) {
118
			
119
			Node n2 = graph.addNode(cooccurrence.getLines().get(i).occ);
120
			n2.addAttribute("ui.size", cooccurrence.getLines().get(i).freq / 5);
121
			
122
			graph.addEdge(String.valueOf(i), rootNode, n2);
123

  
124
		}
125
		
126
//		graph.addNode("A");
127
//		graph.addNode("B");
128
//		graph.addNode("C");
129
//		graph.addEdge("AB", "A", "B");
130
//		graph.addEdge("BC", "B", "C");
131
//		graph.addEdge("CA", "C", "A");
132

  
133
		// set text labels
134
        for (Node n : graph) {
135
        	n.setAttribute("ui.label", n.getId());
136
        }
137
	
138

  
139
		// FIXME: tests (opening a Frame with the graph but be careful, closing the Frame closes the entire RCP app)
140
    	//graph.display();
141
		
142
		return graph;
143
	}
144

  
145
	/* (non-Javadoc)
146
	 * @see org.txm.chartsengine.core.ChartCreator#getResultDataClass()
147
	 */
148
	@Override
149
	public Class getResultDataClass() {
150
		return CooccurrenceGraph.class;
151
	}
152

  
153
	/* (non-Javadoc)
154
	 * @see org.txm.chartsengine.core.ChartCreator#getSeriesShapesColors(java.lang.Object)
155
	 */
156
	@Override
157
	public ArrayList<Color> getSeriesShapesColors(Object chart) {
158
		// TODO Auto-generated method stub
159
		return null;
160
	}
161

  
162
}
0 163

  
tmp/org.txm.cooccurrence.chartsengine/src/org/txm/cooccurrence/handlers/ComputeCooccurrenceGraph.java (revision 905)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.cooccurrence.handlers;
29

  
30
import org.eclipse.core.commands.ExecutionEvent;
31
import org.eclipse.core.commands.ExecutionException;
32
import org.txm.chartsengine.rcp.editors.ChartEditor;
33
import org.txm.cooccurrence.core.functions.Cooccurrence;
34
import org.txm.cooccurrence.functions.CooccurrenceGraph;
35
import org.txm.rcp.handlers.BaseAbstractHandler;
36

  
37

  
38
/**
39
 * Opens a cooccurrence graph editor.
40
 * Computes the result if it contains all required parameters.
41
 * 
42
 * @author mdecorde
43
 * @author sjacquot
44
 * 
45
 */
46
public class ComputeCooccurrenceGraph extends BaseAbstractHandler {
47

  
48

  
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
51
	 */
52
	@Override
53
	public Object execute(ExecutionEvent event) throws ExecutionException {
54
		
55
		if (!this.checkCorpusEngine())	{
56
			return false;
57
		}
58
		
59
		if(!this.checkStatsEngine()) {
60
			return false;
61
		}
62

  
63
		
64
		Object selection = this.getCorporaViewSelectedObject(event);
65
		CooccurrenceGraph coocGraph = null;
66
		
67
		// Creating from Cooccurrence
68
		if (selection instanceof Cooccurrence) {
69
			coocGraph = new CooccurrenceGraph((Cooccurrence) selection);
70
				
71
		}
72
		// Reopening from existing result
73
		else if(selection instanceof CooccurrenceGraph)	{
74
			coocGraph = (CooccurrenceGraph) selection;
75
		}
76
		// Error
77
		else	{
78
			return super.logCanNotCompute(selection);
79
		}
80
		
81
		ChartEditor.openEditor(coocGraph);
82

  
83
		return null;
84
	}
85
	
86
}
0 87

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

  
tmp/org.txm.cooccurrence.chartsengine/plugin.xml (revision 905)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.commands">
6
      <command
7
            defaultHandler="org.txm.cooccurrence.handlers.ComputeCooccurrenceGraph"
8
            id="org.txm.cooccurrence.handlers.ComputeCooccurrenceGraph"
9
            name="Compute Cooccurrence Graph"
10
            returnTypeId="org.txm.cooccurrence.functions.CooccurrenceGraph">
11
      </command>
12
   </extension>
13

  
14
   <extension
15
         point="org.txm.chartsengine.chartcreator">
16
      <ChartCreator
17
            class="org.txm.cooccurrence.chartsengine.CooccurrenceGSChartCreator"
18
            fileNamePrefix="cooc">
19
      </ChartCreator>
20
   </extension>
21
   <extension
22
         point="org.eclipse.ui.menus">
23
      <menuContribution
24
            allPopups="false"
25
            locationURI="popup:org.txm.rcp.views.corpora.CorporaView">
26
         <command
27
               commandId="org.txm.cooccurrence.handlers.ComputeCooccurrenceGraph"
28
               style="push">
29
            <visibleWhen
30
                  checkEnabled="false">
31
               <or>
32
                  <reference
33
                        definitionId="OneCooccurrenceSelected">
34
                  </reference>
35
               </or>
36
            </visibleWhen>
37
         </command>
38
      </menuContribution>
39
   </extension>
40
   <extension
41
         point="org.eclipse.ui.editors">
42
      <editor
43
            class="org.txm.cooccurrence.editors.CooccurrenceGraphEditor"
44
            default="false"
45
            id="org.txm.cooccurrence.functions.CooccurrenceGraph"
46
            name="Cooccurrence Graph Editor">
47
      </editor>
48
   </extension>
49

  
50

  
51
</plugin>
0 52

  
tmp/org.txm.cooccurrence.chartsengine/.settings/org.eclipse.jdt.core.prefs (revision 905)
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.cooccurrence.chartsengine/.classpath (revision 905)
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.cooccurrence.chartsengine/META-INF/MANIFEST.MF (revision 905)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Cooccurrence Graphs
4
Bundle-SymbolicName: org.txm.cooccurrence.chartsengine;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.cooccurrence.core;bundle-version="1.0.0";visibility:=reexport,
10
 org.txm.cooccurrence.rcp;bundle-version="1.0.0";visibility:=reexport,
11
 org.txm.chartsengine.rcp;bundle-version="1.0.0";visibility:=reexport
12
Export-Package: org.txm.cooccurrence.chartsengine,
13
 org.txm.cooccurrence.editors,
14
 org.txm.cooccurrence.functions,
15
 org.txm.cooccurrence.handlers
0 16

  
tmp/org.txm.cooccurrence.chartsengine/.project (revision 905)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.cooccurrence.chartsengine</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

  

Formats disponibles : Unified diff