Revision 2396

tmp/org.txm.ca.rcp/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.ahc.rcp/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/handlers/ComputeAHC.java (revision 2396)
62 62
 * 
63 63
 */
64 64
public class ComputeAHC extends BaseAbstractHandler {
65

  
66

  
65
	
66
	
67 67
	@Override
68 68
	public AHC execute(ExecutionEvent event) throws ExecutionException {
69

  
69
		
70 70
		if (!this.checkStatsEngine()) {
71 71
			return null;
72 72
		}
73

  
73
		
74 74
		Object selection = this.getCorporaViewSelectedObject(event);
75 75
		AHC ahc = null;
76

  
76
		
77 77
		final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
78 78
		try {
79 79
			// reopening an existing result
80 80
			if (selection instanceof AHC) {
81 81
				ahc = (AHC) selection;
82
			} else if (selection instanceof CA) { // Creating
83

  
82
			}
83
			else if (selection instanceof CA) { // Creating
84
				
84 85
				CA ca = (CA) selection;
85 86
				ahc = new AHC(ca);
86
			} else if (selection instanceof PartitionIndex) { // Creating from Partition Index
87

  
88
				PartitionIndex index = (PartitionIndex)selection;
87
			}
88
			else if (selection instanceof PartitionIndex) { // Creating from Partition Index
89
				
90
				PartitionIndex index = (PartitionIndex) selection;
89 91
				LexicalTable lexicalTable = new LexicalTable(index);
90 92
				lexicalTable.setVisible(false);
91 93
				CA ca = new CA(lexicalTable);
92 94
				ca.setVisible(false);
93 95
				ahc = new AHC(ca);
94
			} else if (selection instanceof LexicalTable) { // Creating from Lexical Table
95

  
96
			}
97
			else if (selection instanceof LexicalTable) { // Creating from Lexical Table
98
				
96 99
				LexicalTable lexicalTable = (LexicalTable) selection;
97 100
				CA ca = new CA(lexicalTable);
98 101
				ca.setVisible(false);
99 102
				ahc = new AHC(ca);
100
			} else if (selection instanceof Partition) { // Creating from Partition
101

  
102
				Partition partition = (Partition)selection;
103
			}
104
			else if (selection instanceof Partition) { // Creating from Partition
105
				
106
				Partition partition = (Partition) selection;
103 107
				if (partition.getPartsCount() < 4) {
104 108
					MessageDialog d = new MessageDialog(window.getShell(), TXMCoreMessages.error_error2, null,
105
							NLS.bind(AHCUIMessages.error_canNotComputeAHCWith, partition.getPartsCount()), 0, new String[] { TXMCoreMessages.common_ok}, 0);
109
							NLS.bind(AHCUIMessages.error_canNotComputeAHCWith, partition.getPartsCount()), 0, new String[] { TXMCoreMessages.common_ok }, 0);
106 110
					d.open();
107 111
					return null;
108 112
				}
109

  
110

  
113
				
114
				
111 115
				LexicalTable lexicalTable = new LexicalTable(partition); // use the CAPreferencePage Fmin
112 116
				lexicalTable.setVisible(false);
113 117
				CA ca = new CA(lexicalTable);
114 118
				ca.setVisible(false);
115 119
				ahc = new AHC(ca);
116

  
120
				
117 121
			}
118

  
122
			
119 123
			ChartEditor.openEditor(ahc);
120
		} catch (Exception e) {
124
		}
125
		catch (Exception e) {
121 126
			Log.severe("Failed to build the AHC for selection " + selection + ": " + e);
122 127
			Log.printStackTrace(e);
123 128
			return null;
124
		} 
129
		}
125 130
		return ahc;
126 131
	}
127
}
132
}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/preferences/AHCPreferencePage.java (revision 2396)
48 48
 * @author sjacquot
49 49
 */
50 50
public class AHCPreferencePage extends TXMPreferencePage {
51

  
52

  
53

  
51
	
52
	
53
	
54 54
	@Override
55 55
	public void createFieldEditors() {
56

  
56
		
57 57
		IntegerFieldEditor nClusters = new IntegerFieldEditor(AHCPreferences.N_CLUSTERS, AHCUIMessages.numberOfClusters, getFieldEditorParent());
58 58
		addField(nClusters);
59

  
60
		String list[] = AHC.getMethods(); 
59
		
60
		String list[] = AHC.getMethods();
61 61
		String methods[][] = new String[list.length][2];
62
		for(int i = 0 ; i < list.length ; i++)
62
		for (int i = 0; i < list.length; i++)
63 63
			methods[i][0] = methods[i][1] = list[i];
64
				
64
		
65 65
		ComboFieldEditor method = new ComboFieldEditor(AHCPreferences.METHOD, AHCUIMessages.method, methods, getFieldEditorParent());
66 66
		addField(method);
67

  
68
		list = AHC.getMetrics(); 
67
		
68
		list = AHC.getMetrics();
69 69
		String metrics[][] = new String[list.length][2];
70
		for(int i = 0 ; i < list.length ; i++)
70
		for (int i = 0; i < list.length; i++)
71 71
			metrics[i][0] = metrics[i][1] = list[i];
72 72
		
73 73
		ComboFieldEditor metric = new ComboFieldEditor(AHCPreferences.METRIC, AHCUIMessages.common_metric, metrics, getFieldEditorParent());
......
76 76
		
77 77
		// Charts
78 78
		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(getFieldEditorParent());
79

  
80
		String[][] labelAndValues = {{"2D", "true"}, {"3D", "false"}}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
79
		
80
		String[][] labelAndValues = { { "2D", "true" }, { "3D", "false" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
81 81
		RadioGroupFieldEditor default2D3Ddisplay = new RadioGroupFieldEditor(AHCPreferences.RENDERING_2D, AHCUIMessages.displayChartsIn2D, 2, labelAndValues, chartsTab);
82 82
		addField(default2D3Ddisplay);
83 83
		
......
85 85
		// other shared preferences
86 86
		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
87 87
	}
88

  
88
	
89 89
	@Override
90 90
	public void init(IWorkbench workbench) {
91 91
		this.setPreferenceStore(new TXMPreferenceStore(AHCPreferences.getInstance().getPreferencesNodeQualifier()));
92
		//setDescription("AHC");
92
		// setDescription("AHC");
93 93
		this.setTitle(AHCCoreMessages.RESULT_TYPE);
94 94
		this.setImageDescriptor(AHCAdapterFactory.ICON);
95 95
	}
96

  
97
}
96
	
97
}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/adapters/AHCAdapterFactory.java (revision 2396)
11 11

  
12 12
/**
13 13
 * A factory for creating Adapter objects.
14
 *  
14
 * 
15 15
 * @author mdecorde
16 16
 * @author sjacquot
17 17
 */
18 18
public class AHCAdapterFactory extends TXMResultAdapterFactory {
19

  
20 19
	
21
	public static final ImageDescriptor ICON =
22
			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(AHCAdapterFactory.class).getSymbolicName(),
23
					"platform:/plugin/"+ FrameworkUtil.getBundle(AHCAdapterFactory.class).getSymbolicName() + "/icons/cah.png"); //$NON-NLS-1$
24 20
	
21
	public static final ImageDescriptor ICON = AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(AHCAdapterFactory.class).getSymbolicName(),
22
			"platform:/plugin/" + FrameworkUtil.getBundle(AHCAdapterFactory.class).getSymbolicName() + "/icons/cah.png"); //$NON-NLS-1$
23
	
25 24
	/**
26 25
	 * Gets the adapter.
27 26
	 *
......
32 31
	 */
33 32
	@Override
34 33
	public Object getAdapter(Object adaptableObject, Class adapterType) {
35
		if(this.canAdapt(adapterType) && adaptableObject instanceof AHC)	{
34
		if (this.canAdapt(adapterType) && adaptableObject instanceof AHC) {
36 35
			return new TXMResultAdapter() {
36
				
37 37
				@Override
38 38
				public ImageDescriptor getImageDescriptor(Object object) {
39 39
					return ICON;
......
42 42
		}
43 43
		return null;
44 44
	}
45

  
46

  
45
	
46
	
47 47
}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/messages/AHCUIMessages.java (revision 2396)
15 15
	
16 16
	private static final String BUNDLE_NAME = "org.txm.ahc.rcp.messages.messages"; //$NON-NLS-1$
17 17
	
18
	public static String displayChartsIn2D; 
19
	public static String numberOfClusters; 
20
	public static String method; 
18
	public static String displayChartsIn2D;
19
	
20
	public static String numberOfClusters;
21
	
22
	public static String method;
23
	
21 24
	public static String common_metric;
22 25
	
23
	public static String computingClassificationWithP0; 
26
	public static String computingClassificationWithP0;
24 27
	
25
	public static String computeColumns; 
26
	public static String computeRows; 
28
	public static String computeColumns;
27 29
	
28
	public static String numberOfClustersColon; 
30
	public static String computeRows;
29 31
	
32
	public static String numberOfClustersColon;
33
	
30 34
	public static String error_canNotComputeAHCWith;
31 35
	
32 36
	static {
33 37
		Utf8NLS.initializeMessages(BUNDLE_NAME, AHCUIMessages.class);
34 38
	}
35

  
36 39
	
40
	
37 41
}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/editors/AHCEditor.java (revision 2396)
32 32
 *
33 33
 */
34 34
public class AHCEditor extends ChartEditor<AHC> {
35

  
36

  
35
	
36
	
37 37
	/**
38 38
	 * Rows computing button.
39 39
	 */
40 40
	protected ToolItem rowsComputing;
41

  
41
	
42 42
	/**
43 43
	 * Unit property.
44 44
	 */
45
	@Parameter(key=TXMPreferences.UNIT_PROPERTY)
45
	@Parameter(key = TXMPreferences.UNIT_PROPERTY)
46 46
	protected PropertiesComboViewer unitPropertyComboViewer;
47

  
47
	
48 48
	/**
49 49
	 * Minimum frequency filtering spinner.
50 50
	 */
51
	@Parameter(key=TXMPreferences.F_MIN)
51
	@Parameter(key = TXMPreferences.F_MIN)
52 52
	protected Spinner fMinSpinner;
53

  
53
	
54 54
	/**
55 55
	 * Maximum number of lines filtering.
56 56
	 */
57
	@Parameter(key=TXMPreferences.V_MAX)
57
	@Parameter(key = TXMPreferences.V_MAX)
58 58
	protected Spinner vMaxSpinner;
59

  
60

  
59
	
60
	
61 61
	/**
62 62
	 * The metric (euclidean, manhattan).
63 63
	 */
64
	@Parameter(key=AHCPreferences.METRIC)
64
	@Parameter(key = AHCPreferences.METRIC)
65 65
	protected String metric;
66

  
66
	
67 67
	/**
68 68
	 * The method (METHODS <- c("average", "single", "complete", "ward", "weighted", "flexible")).
69 69
	 */
70
	@Parameter(key=AHCPreferences.METHOD)
70
	@Parameter(key = AHCPreferences.METHOD)
71 71
	protected String method;
72

  
72
	
73 73
	/**
74 74
	 * The number of clusters.
75 75
	 */
76
	@Parameter(key=AHCPreferences.N_CLUSTERS)
76
	@Parameter(key = AHCPreferences.N_CLUSTERS)
77 77
	protected Spinner numberOfClusters;
78

  
78
	
79 79
	/**
80 80
	 * To compute the columns or the rows.
81 81
	 */
82
	@Parameter(key=AHCPreferences.COLUMNS_COMPUTING)
82
	@Parameter(key = AHCPreferences.COLUMNS_COMPUTING)
83 83
	protected ToolItem columnsComputing;
84

  
84
	
85 85
	/**
86 86
	 * To render in 2D or 3D.
87 87
	 */
88
	@Parameter(key=AHCPreferences.RENDERING_2D)
88
	@Parameter(key = AHCPreferences.RENDERING_2D)
89 89
	protected Button rendering2D;
90

  
91

  
90
	
91
	
92 92
	@Override
93 93
	public void __createPartControl() throws Exception {
94

  
94
		
95 95
		GLComposite mainParametersArea = this.getMainParametersComposite();
96 96
		mainParametersArea.getLayout().numColumns = 4;
97 97
		// parent parameters
98
		if (!this.getResult().getParent().isVisible() // CA parent parent is not visible  
99
				&& !(this.getResult().getParent().getParent().getParent() instanceof PartitionIndex))	{ // and its 2x parent is not a PartitionIndex
98
		if (!this.getResult().getParent().isVisible() // CA parent parent is not visible
99
				&& !(this.getResult().getParent().getParent().getParent() instanceof PartitionIndex)) { // and its 2x parent is not a PartitionIndex
100 100
			// unit property
101 101
			new Label(mainParametersArea, SWT.NONE).setText(TXMCoreMessages.common_property);
102 102
			this.unitPropertyComboViewer = new PropertiesComboViewer(mainParametersArea, this, false,
103 103
					CQPCorpus.getFirstParentCorpus(this.getResult()).getOrderedProperties(),
104 104
					this.getResult().getUnitProperty(), false);
105 105
		}
106

  
106
		
107 107
		// Extend the chart editor tool bar
108 108
		new ToolItem(this.chartToolBar, SWT.SEPARATOR);
109

  
110

  
109
		
110
		
111 111
		// Computing listeners
112 112
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true);
113
		//ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
114

  
113
		// ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
114
		
115 115
		// Number of clusters
116 116
		LabeledSpinner clusters = new LabeledSpinner(mainParametersArea, this, AHCUIMessages.numberOfClustersColon);
117 117
		this.numberOfClusters = clusters.getSpinner();
118 118
		this.numberOfClusters.setMinimum(2);
119 119
		
120
//		CLabel clustersLabel = new CLabel(this.chartToolBar, SWT.CENTER);
121
//		clustersLabel.setText(AHCUIMessages.numberOfClustersColon);
122
//		this.chartToolBar.addControl(clustersLabel);
123
//
124
//		this.numberOfClusters = new Spinner(this.chartToolBar, SWT.BORDER);
125
//		this.numberOfClusters.setMinimum(2);
126
//		this.numberOfClusters.setIncrement(1);
127
//		this.chartToolBar.addControl(this.numberOfClusters);
128
//		this.numberOfClusters.addKeyListener(computeKeyListener);
129
//		this.numberOfClusters.addModifyListener(computeKeyListener);
120
		// CLabel clustersLabel = new CLabel(this.chartToolBar, SWT.CENTER);
121
		// clustersLabel.setText(AHCUIMessages.numberOfClustersColon);
122
		// this.chartToolBar.addControl(clustersLabel);
123
		//
124
		// this.numberOfClusters = new Spinner(this.chartToolBar, SWT.BORDER);
125
		// this.numberOfClusters.setMinimum(2);
126
		// this.numberOfClusters.setIncrement(1);
127
		// this.chartToolBar.addControl(this.numberOfClusters);
128
		// this.numberOfClusters.addKeyListener(computeKeyListener);
129
		// this.numberOfClusters.addModifyListener(computeKeyListener);
130 130
		
131

  
131
		
132 132
		// Columns
133 133
		this.columnsComputing = new ToolItem(this.chartToolBar, SWT.RADIO);
134 134
		this.columnsComputing.setToolTipText(AHCUIMessages.computeColumns);
135 135
		this.columnsComputing.setImage(IImageKeys.getImage(AHCEditor.class, "icons/compute_columns.png")); //$NON-NLS-1$
136 136
		this.columnsComputing.addSelectionListener(computeSelectionListener);
137

  
137
		
138 138
		// Rows
139 139
		this.rowsComputing = new ToolItem(this.chartToolBar, SWT.RADIO);
140 140
		this.rowsComputing.setToolTipText(AHCUIMessages.computeRows);
141 141
		this.rowsComputing.setImage(IImageKeys.getImage(AHCEditor.class, "icons/compute_rows.png")); //$NON-NLS-1$
142

  
143

  
142
		
143
		
144 144
		// 2D/3D rendering
145 145
		this.rendering2D = new Button(this.chartToolBar, SWT.CHECK);
146 146
		this.rendering2D.setText("2D");//$NON-NLS-1$
147 147
		this.chartToolBar.addControl(this.rendering2D);
148 148
		this.rendering2D.addSelectionListener(computeSelectionListener);
149

  
149
		
150 150
		// FIXME: temporary fix, later must enable the font, rendering mode, etc. in R calls
151 151
		// disable all component of the rendering tool bar
152 152
		this.advancedChartToolBar.setEnabled(false);
153

  
154
		if (!this.getResult().getParent().isVisible() // CA parent parent is not visible  
155
				&& !(this.getResult().getParent().getParent().getParent() instanceof PartitionIndex))	{ // and its 2x parent is not a PartitionIndex
153
		
154
		if (!this.getResult().getParent().isVisible() // CA parent parent is not visible
155
				&& !(this.getResult().getParent().getParent().getParent() instanceof PartitionIndex)) { // and its 2x parent is not a PartitionIndex
156 156
			ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), SWT.NONE, this, true, false);
157 157
			this.fMinSpinner = thresholdsGroup.getFMinSpinner();
158 158
			this.vMaxSpinner = thresholdsGroup.getVMaxSpinner();
159 159
			this.vMaxSpinner.setMinimum(1);
160 160
		}
161 161
	}
162

  
163

  
162
	
163
	
164 164
	@Override
165 165
	public void updateEditorFromChart(boolean update) {
166 166
		AHC ahc = this.getResult();
167

  
168
		// Update the maximum value of the number of clusters spinner according to the new AHC configuration 
167
		
168
		// Update the maximum value of the number of clusters spinner according to the new AHC configuration
169 169
		this.numberOfClusters.setMaximum(ahc.getMaxClustersCount());
170

  
170
		
171 171
		// Updates the current value of the number of clusters spinner
172 172
		this.numberOfClusters.setSelection(ahc.getNumberOfClusters());
173

  
173
		
174 174
		this.rowsComputing.setSelection(!ahc.isColumnsComputing());
175 175
	}
176

  
177
}
176
	
177
}
tmp/org.txm.chartsengine.core/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/GSSWTChartsComponentsProvider.java (revision 2396)
18 18
 *
19 19
 */
20 20
public class GSSWTChartsComponentsProvider extends SWTChartsComponentsProvider {
21

  
21
	
22 22
	/**
23
	 * Default constructor. 
23
	 * Default constructor.
24 24
	 */
25 25
	public GSSWTChartsComponentsProvider() {
26 26
		super();
27 27
	}
28

  
28
	
29 29
	@Override
30 30
	public ChartComposite createComposite(ChartEditor chartEditor, Composite parent) {
31 31
		return new GSComposite(chartEditor, parent);
32 32
	}
33

  
33
	
34 34
	@Override
35 35
	public ArrayList<String> getChartsEngineSupportedExportFileFormats() {
36 36
		return this.chartsEngine.getSupportedOutputFileFormats();
37 37
	}
38

  
39

  
38
	
39
	
40 40
}
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/swt/GSComposite.java (revision 2396)
25 25
 *
26 26
 */
27 27
public class GSComposite extends SwingChartComposite {
28

  
28
	
29 29
	/**
30 30
	 * @param chartEditor
31 31
	 * @param parent
......
37 37
		
38 38
		
39 39
		
40
//   	 JPanel pane1 = new JPanel();
41
//	 Viewer v = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
42
//	 v.a
43
	 
44
//     v.enableAutoLayout();
45
//     ViewPanel view = v.addDefaultView(false);
46
//     pane1.setLayout(new BorderLayout());
47
//      pane1.add(view,BorderLayout.CENTER);
40
		// JPanel pane1 = new JPanel();
41
		// Viewer v = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
42
		// v.a
43
		
44
		// v.enableAutoLayout();
45
		// ViewPanel view = v.addDefaultView(false);
46
		// pane1.setLayout(new BorderLayout());
47
		// pane1.add(view,BorderLayout.CENTER);
48 48
	}
49

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

  
67
//		}
66
		
67
		// }
68 68
		// FIXME: tests (opening a Frame with the graph but be careful, closing the Frame closes the entire RCP app)
69
		//graph.display();
69
		// graph.display();
70 70
	}
71

  
71
	
72 72
	@Override
73 73
	public void clearChartItemsSelection() {
74 74
		// TODO Auto-generated method stub
75

  
75
		
76 76
	}
77

  
77
	
78 78
	@Override
79 79
	protected IChartComponent _createChartComponent() {
80
			
81
			//System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); // Pour les fonctionnalités avancées des CSS
80
		
81
		// System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); // Pour les fonctionnalités avancées des CSS
82
		
83
		// creating a dummy graph (the viewer can not have a null graph)
84
		Graph graph = new SingleGraph("dummy"); //$NON-NLS-1$
85
		
86
		// FIXME: tests
87
		// Generator gen = new DorogovtsevMendesGenerator();
88
		// gen.addSink(graph);
89
		// gen.begin();
90
		// for(int i=0; i<500; i++) {
91
		// gen.nextEvents();
92
		// }
93
		// gen.end();
94
		//
95
		// for (Node node : graph) {
96
		// node.addAttribute("ui.label", node.getId());
97
		// //node.setAttribute("ui.size", 5);
98
		//// node.addAttribute("ui.style", "fill-color: 0.5; size: 5px;");
99
		// }
100
		//
101
		// //graph.display();
102
		
103
		// Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
104
		Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
105
		viewer.enableAutoLayout();
106
		// graph.display();
107
		GSChartComponent chartComponent = new GSChartComponent(viewer);
108
		viewer.addView(chartComponent);
109
		
110
		return chartComponent;
111
	}
82 112
	
83
			// creating a dummy graph (the viewer can not have a null graph)
84
			Graph graph = new SingleGraph("dummy"); //$NON-NLS-1$
85
			
86
			// FIXME: tests
87
//			Generator gen = new DorogovtsevMendesGenerator();
88
//	    	gen.addSink(graph);
89
//	    	gen.begin();
90
//	    	for(int i=0; i<500; i++) {
91
//	    	    gen.nextEvents();
92
//	    	}
93
//	    	gen.end();
94
//	    	
95
//	        for (Node node : graph) {
96
//	        	node.addAttribute("ui.label", node.getId());
97
//	            //node.setAttribute("ui.size", 5);
98
////	    		node.addAttribute("ui.style", "fill-color: 0.5; size: 5px;");
99
//	        }
100
//			
101
//	        //graph.display();
102
          
103
			//Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);
104
			Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
105
			viewer.enableAutoLayout();
106
			//graph.display();
107
			GSChartComponent chartComponent = new GSChartComponent(viewer);
108
			viewer.addView(chartComponent);
109
			
110
			return chartComponent;
111
	}
112

  
113 113
	@Override
114 114
	public File exportView(File file, String fileFormat) {
115 115
		System.out.println("GSComposite.exportView(): not yet implemented.");
......
117 117
	}
118 118
	
119 119
	@Override
120
	public ArrayList<String> getEditorSupportedExportFileFormats()	{
120
	public ArrayList<String> getEditorSupportedExportFileFormats() {
121 121
		return this.getChartsEngine().getSupportedOutputFileFormats();
122 122
	}
123

  
123
	
124 124
	@Override
125 125
	public void initEventsListeners() {
126 126
		// TODO Auto-generated method stub
127 127
		
128 128
	}
129

  
130 129
	
131

  
130
	
131
	
132 132
}
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/swing/GSChartComponent.java (revision 2396)
17 17
 *
18 18
 */
19 19
public class GSChartComponent extends DefaultView implements IChartComponent {
20

  
21

  
20
	
21
	
22 22
	protected double zoomFactor = 0.1;
23 23
	
24 24
	
......
29 29
	public GSChartComponent(Viewer viewer) {
30 30
		super(viewer, Viewer.DEFAULT_VIEW_ID, Viewer.newGraphRenderer());
31 31
	}
32

  
32
	
33 33
	/**
34 34
	 * 
35 35
	 * @param viewer
36 36
	 */
37
	public void reinit(Viewer viewer)	{
38
		if(this.viewer != null)	{
37
	public void reinit(Viewer viewer) {
38
		if (this.viewer != null) {
39 39
			this.viewer.close();
40 40
		}
41 41
		this.viewer = viewer;
42 42
		this.graph = viewer.getGraphicGraph();
43 43
		this.renderer = Viewer.newGraphRenderer();
44

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

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

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

  
81
		
79 82
	}
80

  
81
	/* (non-Javadoc)
83
	
84
	/*
85
	 * (non-Javadoc)
82 86
	 * @see org.txm.chartsengine.rcp.IChartComponent#getChartEditor()
83 87
	 */
84 88
	@Override
......
86 90
		// TODO Auto-generated method stub
87 91
		return null;
88 92
	}
89

  
90
	/* (non-Javadoc)
93
	
94
	/*
95
	 * (non-Javadoc)
91 96
	 * @see org.txm.chartsengine.rcp.IChartComponent#setChartEditor(org.txm.chartsengine.rcp.editors.ChartEditor)
92 97
	 */
93 98
	@Override
94 99
	public void setChartEditor(ChartEditor editor) {
95 100
		// TODO Auto-generated method stub
96

  
101
		
97 102
	}
98

  
99
	/* (non-Javadoc)
103
	
104
	/*
105
	 * (non-Javadoc)
100 106
	 * @see org.txm.chartsengine.rcp.IChartComponent#updateMouseOverItem(java.awt.event.MouseEvent)
101 107
	 */
102 108
	@Override
103 109
	public void updateMouseOverItem(MouseEvent event) {
104 110
		// TODO Auto-generated method stub
105

  
111
		
106 112
	}
107

  
108
	/* (non-Javadoc)
113
	
114
	/*
115
	 * (non-Javadoc)
109 116
	 * @see org.txm.chartsengine.rcp.IChartComponent#squareOff()
110 117
	 */
111 118
	@Override
112 119
	public void squareOff() {
113 120
		// TODO Auto-generated method stub
114

  
121
		
115 122
	}
116

  
117
//	/* (non-Javadoc)
118
//	 * @see org.txm.chartsengine.rcp.IChartComponent#setSquareOffEnabled(boolean)
119
//	 */
120
//	@Override
121
//	public void setSquareOffEnabled(boolean enabled) {
122
//		// TODO Auto-generated method stub
123
//
124
//	}
125

  
126 123
	
127
	public Viewer getViewer()	{
124
	// /* (non-Javadoc)
125
	// * @see org.txm.chartsengine.rcp.IChartComponent#setSquareOffEnabled(boolean)
126
	// */
127
	// @Override
128
	// public void setSquareOffEnabled(boolean enabled) {
129
	// // TODO Auto-generated method stub
130
	//
131
	// }
132
	
133
	
134
	public Viewer getViewer() {
128 135
		return this.viewer;
129 136
	}
130

  
131 137
	
138
	
132 139
}
tmp/org.txm.chartsengine.graphstream.rcp/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.chartsengine.graphstream.core/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.backtomedia.rcp/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry exported="true" kind="lib" path="vlcj-2.4.1/jna-3.5.2.jar"/>
4
	  <classpathentry exported="true" kind="lib" path="vlcj-2.4.1/platform-3.5.2.jar"/>
5
	  <classpathentry exported="true" kind="lib" path="vlcj-2.4.1/vlcj-2.4.1.jar"/>
6
	  <classpathentry kind="lib" path="opal-0.9.5.2.jar"/>
7
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8
	  <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
9
		    <accessrules>
10
			      <accessrule kind="accessible" pattern="**"/>
11
		    </accessrules>
12
	  </classpathentry>
13
	  <classpathentry kind="src" path="src"/>
14
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry exported="true" kind="lib"
4
		path="vlcj-2.4.1/jna-3.5.2.jar" />
5
	<classpathentry exported="true" kind="lib"
6
		path="vlcj-2.4.1/platform-3.5.2.jar" />
7
	<classpathentry exported="true" kind="lib"
8
		path="vlcj-2.4.1/vlcj-2.4.1.jar" />
9
	<classpathentry kind="lib" path="opal-0.9.5.2.jar" />
10
	<classpathentry kind="con"
11
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
12
	<classpathentry kind="con"
13
		path="org.eclipse.pde.core.requiredPlugins">
14
		<accessrules>
15
			<accessrule kind="accessible" pattern="**" />
16
		</accessrules>
17
	</classpathentry>
18
	<classpathentry kind="src" path="src" />
19
	<classpathentry kind="output" path="bin" />
15 20
</classpath>
tmp/org.txm.chartsengine.r.rcp/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
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"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
11 13
</classpath>
tmp/org.txm.annotation.core/.classpath (revision 2396)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3
	  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	  <classpathentry exported="true"
5
                   kind="con"
6
                   path="org.eclipse.pde.core.requiredPlugins">
7
		    <accessrules>
8
			      <accessrule kind="accessible" pattern="**"/>
9
		    </accessrules>
10
	  </classpathentry>
11
	  <classpathentry kind="src" path="src"/>
12
	  <classpathentry kind="output" path="bin"/>
3
	<classpathentry kind="con"
4
		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
5
	<classpathentry exported="true" kind="con"
6
		path="org.eclipse.pde.core.requiredPlugins">
7
		<accessrules>
8
			<accessrule kind="accessible" pattern="**" />
9
		</accessrules>
10
	</classpathentry>
11
	<classpathentry kind="src" path="src" />
12
	<classpathentry kind="output" path="bin" />
13 13
</classpath>
tmp/org.txm.annotation.core/src/org/txm/annotation/core/Activator.java (revision 2396)
4 4
import org.osgi.framework.BundleContext;
5 5

  
6 6
public class Activator implements BundleActivator {
7

  
7
	
8 8
	@Override
9 9
	public void start(BundleContext context) throws Exception {
10 10
		// TODO Auto-generated method stub
11

  
11
		
12 12
	}
13

  
13
	
14 14
	@Override
15 15
	public void stop(BundleContext context) throws Exception {
16 16
		// TODO Auto-generated method stub
17

  
17
		
18 18
	}
19 19
}
tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEnginesManager.java (revision 2396)
22 22
			
23 23
			// lazy mode
24 24
			
25
//			AnnotationEngine se = (AnnotationEngine)e;
26
//			if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
27
//			try {
28
//				se.start(monitor);
29
//			} catch (Exception ex) {
30
//				System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
31
//			}
25
			// AnnotationEngine se = (AnnotationEngine)e;
26
			// if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
27
			// try {
28
			// se.start(monitor);
29
			// } catch (Exception ex) {
30
			// System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
31
			// }
32 32
		}
33 33
		return true;
34 34
	}
35

  
35
	
36 36
	@Override
37 37
	public boolean stopEngines() {
38 38
		for (AnnotationEngine e : values()) {
39
			//System.out.println(e);
40
			AnnotationEngine se = (AnnotationEngine)e;
41
			Log.fine("Stoping "+ se.getName()+" annotation engine.");
39
			// System.out.println(e);
40
			AnnotationEngine se = (AnnotationEngine) e;
41
			Log.fine("Stoping " + se.getName() + " annotation engine.");
42 42
			try {
43 43
				se.stop();
44
			} catch (Exception ex) {
45
				Log.severe("Error: failed to stop annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
46 44
			}
45
			catch (Exception ex) {
46
				Log.severe("Error: failed to stop annotation engine: " + se.getName() + ": " + ex.getLocalizedMessage());
47
			}
47 48
		}
48 49
		return true;
49 50
	}
50

  
51
	
51 52
	@Override
52 53
	public EngineType getEnginesType() {
53 54
		return EngineType.ANNOTATION;
54 55
	}
55

  
56
	
56 57
	@Override
57 58
	public boolean fetchEngines() {
58 59
		
59 60
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationEngine.EXTENSION_POINT_ID);
60
		//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
61
		// System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
61 62
		for (int i = 0; i < contributions.length; i++) {
62 63
			try {
63
				AnnotationEngine e = (AnnotationEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
64
				AnnotationEngine e = (AnnotationEngine) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
64 65
				if (e.initialize()) {
65 66
					put(e.getName(), e);
66
				} else {
67
					System.out.println("Fail to initialize "+e.getName()+" annotation engine.");
68 67
				}
69
			} catch(Exception e) {
70
				System.out.println("Error: fail instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
68
				else {
69
					System.out.println("Fail to initialize " + e.getName() + " annotation engine.");
70
				}
71
			}
72
			catch (Exception e) {
73
				System.out.println("Error: fail instanciate " + contributions[i].getName() + ": " + e.getLocalizedMessage());
71 74
				e.printStackTrace();
72
			} 
75
			}
73 76
		}
74 77
		
75 78
		return size() > 0;
tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngine.java (revision 2396)
8 8
import org.txm.utils.ConsoleProgressBar;
9 9

  
10 10
public abstract class AnnotationEngine implements Engine {
11

  
11
	
12 12
	public static final String EXTENSION_POINT_ID = AnnotationEngine.class.getCanonicalName();
13

  
13
	
14 14
	@Override
15 15
	public abstract String getName();
16 16
	
......
46 46
			}
47 47
		});
48 48
		if (files == null || files.length == 0) {
49
			System.out.println("Error: no suitable file to process in "+xmlFilesDirectory);
49
			System.out.println("Error: no suitable file to process in " + xmlFilesDirectory);
50 50
			return false;
51 51
		}
52 52
		boolean ret = true;
tmp/org.txm.annotation.core/src/org/txm/annotation/core/preferences/AnnotationPreferences.java (revision 2396)
6 6

  
7 7
/**
8 8
 * Preferences initializer and manager.
9
 * 
9 10
 * @author mdecorde
10 11
 * @author sjacquot
11 12
 *
12 13
 */
13 14
public class AnnotationPreferences extends TXMPreferences {
14

  
15 15
	
16

  
16
	
17
	
17 18
	/**
18 19
	 * Gets the instance.
20
	 * 
19 21
	 * @return the instance
20 22
	 */
21
	public static TXMPreferences getInstance()	{
23
	public static TXMPreferences getInstance() {
22 24
		if (!TXMPreferences.instances.containsKey(AnnotationPreferences.class)) {
23 25
			new AnnotationPreferences();
24 26
		}
25 27
		return TXMPreferences.instances.get(AnnotationPreferences.class);
26 28
	}
27

  
28 29
	
30
	
29 31
	@Override
30 32
	public void initializeDefaultPreferences() {
31 33
		super.initializeDefaultPreferences();
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotation.java (revision 2396)
1 1
package org.txm.annotation.kr.core;
2 2

  
3 3
public class CQPAnnotation extends Annotation {
4

  
4
	
5 5
	public CQPAnnotation(String id, String str, int p, int p2) {
6 6
		super(id, str, p, p2);
7 7
	}
8

  
8
	
9 9
	private static final long serialVersionUID = -3539813867449634393L;
10

  
10
	
11 11
}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/preferences/KRAnnotationPreferences.java (revision 2396)
5 5

  
6 6
/**
7 7
 * Preferences initializer and manager.
8
 * 
8 9
 * @author mdecorde
9 10
 * @author sjacquot
10 11
 *
11 12
 */
12 13
public class KRAnnotationPreferences extends TXMPreferences {
13

  
14
	
14 15
	public static final String UPDATE_EDITION = "udpate_edition";
16
	
15 17
	public static final String PRESERVE_ANNOTATIONS = "reset_temporary_annotations_when leaving_txm";
16 18
	
17 19
	/**
18 20
	 * Gets the instance.
21
	 * 
19 22
	 * @return the instance
20 23
	 */
21
	public static TXMPreferences getInstance()	{
24
	public static TXMPreferences getInstance() {
22 25
		if (!TXMPreferences.instances.containsKey(KRAnnotationPreferences.class)) {
23 26
			new KRAnnotationPreferences();
24 27
		}
......
32 35
		preferences.putBoolean(UPDATE_EDITION, true);
33 36
		preferences.putBoolean(PRESERVE_ANNOTATIONS, true);
34 37
	}
35
}
38
}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/storage/temporary/TemporaryAnnotationManager.java (revision 2396)
25 25
import org.txm.utils.logger.Log;
26 26

  
27 27
public class TemporaryAnnotationManager {
28

  
28
	
29 29
	/**
30 30
	 * 
31 31
	 * @param clazz persistence.xml location depends on the classloader
......
33 33
	 * @return
34 34
	 */
35 35
	public static HashMap<String, Object> getInitialisationProperties(Class clazz, MainCorpus corpus) {
36
		File path = new File(corpus.getProjectDirectory(), "temporary_annotations/"+corpus.getID()+"/db");
36
		File path = new File(corpus.getProjectDirectory(), "temporary_annotations/" + corpus.getID() + "/db");
37 37
		path.getParentFile().mkdirs();
38 38
		
39 39
		HashMap<String, Object> properties = new HashMap<String, Object>();
40
		//System.out.println("CLASSLOADER: "+Toolbox.class.getClassLoader());
40
		// System.out.println("CLASSLOADER: "+Toolbox.class.getClassLoader());
41 41
		properties.put(PersistenceUnitProperties.CLASSLOADER, clazz.getClassLoader());
42 42
		properties.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
43 43
		
44
		String urlProperty = "jdbc:hsqldb:file:"+path+";shutdown=true;hsqldb.write_delay=false;hsqldb.lock_file=false;";
44
		String urlProperty = "jdbc:hsqldb:file:" + path + ";shutdown=true;hsqldb.write_delay=false;hsqldb.lock_file=false;";
45 45
		if (Log.getLevel().intValue() < Level.INFO.intValue()) {
46 46
			urlProperty += "";
47
		} else {
47
		}
48
		else {
48 49
			urlProperty += "hsqldb.applog=0;hsqldb.sqllog=0";
49 50
		}
50 51
		properties.put("javax.persistence.jdbc.url", urlProperty);
......
52 53
		properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, "database");
53 54
		if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.PRESERVE_ANNOTATIONS)) {
54 55
			properties.put(PersistenceUnitProperties.DDL_GENERATION, "drop-and-create-tables"); // drop-and-create-tables to reset all
55
		} else {
56
		}
57
		else {
56 58
			properties.put(PersistenceUnitProperties.DDL_GENERATION, "create-or-extend-tables"); // create&update table if needed, drop-and-create-tables to reset all
57 59
		}
58 60
		
59 61
		if (Log.getLevel().intValue() < Level.INFO.intValue()) {
60 62
			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "INFO");
61 63
			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "true");
62
		} else {
64
		}
65
		else {
63 66
			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "OFF");
64 67
			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "false");
65 68
		}
66 69
		
67 70
		return properties;
68 71
	}
72
	
69 73
	private EntityManager em;
70

  
74
	
71 75
	private MainCorpus corpus;
72 76
	
73 77
	public TemporaryAnnotationManager(MainCorpus corpus) {
74 78
		this.corpus = corpus;
75 79
		em = initTemporaryAnnotationDatabase();
76 80
	}
77

  
81
	
78 82
	public TemporaryAnnotationManager(MainCorpus corpus, HashMap<String, Object> properties) {
79 83
		this.corpus = corpus;
80 84
		em = initTemporaryAnnotationDatabase(properties);
81 85
	}
82 86
	
83
	public void checkData() throws Exception{
87
	public void checkData() throws Exception {
84 88
		List<Annotation> annots = getAnnotations();
85
		System.out.println("ID \t Type \t Val \t startPos \t startEnd \t Text "); 
89
		System.out.println("ID \t Type \t Val \t startPos \t startEnd \t Text ");
86 90
		System.out.println("----------------------------------------------------");
87
		for (Annotation an : annots){
88
			System.out.print("\t "+ an.getPK().getRefType());
89
			System.out.print("\t "+ an.getValue());
90
			System.out.print("\t "+ an.getPK().getStartPosition());
91
			System.out.print("\t "+ an.getPK().getEndPosition()+"\n");
91
		for (Annotation an : annots) {
92
			System.out.print("\t " + an.getPK().getRefType());
93
			System.out.print("\t " + an.getValue());
94
			System.out.print("\t " + an.getPK().getStartPosition());
95
			System.out.print("\t " + an.getPK().getEndPosition() + "\n");
92 96
		}
93 97
	}
94

  
98
	
95 99
	public void close() {
96 100
		if (em != null) {
97 101
			em.close();
98 102
		}
99 103
	}
100

  
101 104
	
105
	
102 106
	public List<Annotation> createAnnotation(AnnotationType type, TypedValue value, int startPos, int endPos) throws Exception {
103 107
		em.getTransaction().begin();
104 108
		List<Annotation> a = createAnnotationNoCommit(type, value, startPos, endPos);
105 109
		em.getTransaction().commit();
106 110
		return a;
107 111
	}
108

  
112
	
109 113
	/**
110 114
	 * update or create an annotation BUT em.getTransaction().begin(); and em.getTransaction().commit();
111 115
	 * must be called before and after !!
......
118 122
	 * @return overlapping annotations
119 123
	 * @throws Exception
120 124
	 */
121
	public List<Annotation> createAnnotationNoCommit(AnnotationType type, TypedValue value, int startPos, int endPos) throws Exception{
125
	public List<Annotation> createAnnotationNoCommit(AnnotationType type, TypedValue value, int startPos, int endPos) throws Exception {
122 126
		AnnotationPK pkannot = new AnnotationPK(startPos, endPos, type.getId());
123 127
		Annotation annot = em.find(Annotation.class, pkannot);
124 128
		List<Annotation> overlapingAnnotations = new ArrayList<Annotation>();
125 129
		if (annot == null) { // create annotation
126

  
130
			
127 131
			if (type.getEffect().equals(AnnotationEffect.SEGMENT)) {
128
				//check if it does not already exist, with either one of the positions (overlaps)
129
				//isOverlapAnnots = isOverlapAnnotationCritical(refType, refVal, startPos, endPos);
132
				// check if it does not already exist, with either one of the positions (overlaps)
133
				// isOverlapAnnots = isOverlapAnnotationCritical(refType, refVal, startPos, endPos);
130 134
				ArrayList<Match> matches = new ArrayList<Match>();
131 135
				matches.add(new Match2P(startPos, endPos));
132 136
				overlapingAnnotations = getAnnotations(null, matches, null, false, true); // getAll annotation ovelapping with startPos-endPos
133
				for (int i = 0 ; i < overlapingAnnotations.size() ; i++) { // parse overlapping annotations to remove wrapping annotation with different type and annotation with same type and same position 
137
				for (int i = 0; i < overlapingAnnotations.size(); i++) { // parse overlapping annotations to remove wrapping annotation with different type and annotation with same type and same
138
																		 // position
134 139
					annot = overlapingAnnotations.get(i);
135 140
					if (annot.getType().equals(type.getId())) {
136 141
						if (annot.getStart() == startPos && annot.getEnd() == endPos) {
137 142
							overlapingAnnotations.remove(i);
138 143
							i--;
139 144
						}
140
					} else {
141
						//System.out.println("Pas le même TYPE !!!!! DONC on exige que seuls  INNER et OUTTER overlaps sont admis");
145
					}
146
					else {
147
						// System.out.println("Pas le même TYPE !!!!! DONC on exige que seuls INNER et OUTTER overlaps sont admis");
142 148
						if ((annot.getStart() <= startPos && endPos <= annot.getEnd() ||
143 149
								(startPos <= annot.getStart() && annot.getEnd() <= endPos))) {
144
							/*System.out.println("Taille du tableau annotations AVANT : "+overlapingAnnotations.size());
145
							System.out.println(annot.getStart()+" <= " +startPos+" && "+endPos+" <= "+annot.getEnd()+" OU ");
146
							System.out.println(startPos+" <= " +annot.getStart()+" && "+annot.getEnd()+" <= "+endPos);*/
150
							/*
151
							 * System.out.println("Taille du tableau annotations AVANT : "+overlapingAnnotations.size());
152
							 * System.out.println(annot.getStart()+" <= " +startPos+" && "+endPos+" <= "+annot.getEnd()+" OU ");
153
							 * System.out.println(startPos+" <= " +annot.getStart()+" && "+annot.getEnd()+" <= "+endPos);
154
							 */
147 155
							overlapingAnnotations.remove(i);
148
							//System.out.println("Taille du tableau annotations APRES : "+overlapingAnnotations.size());
156
							// System.out.println("Taille du tableau annotations APRES : "+overlapingAnnotations.size());
149 157
							i--;
150
						}else {
151
							//System.out.println(annot.getStart()+"-"+annot.getEnd()+" // "+startPos+"-"+endPos);
158
						}
159
						else {
160
							// System.out.println(annot.getStart()+"-"+annot.getEnd()+" // "+startPos+"-"+endPos);
152 161
							
153 162
						}
154 163
					}
155 164
				}
156
			} else {
165
			}
166
			else {
157 167
				// no need to check collision
158 168
			}
159

  
169
			
160 170
			if (overlapingAnnotations.size() > 0) { // don't create the annotation
161
//				for (Annotation overlapAnnot : overlapingAnnotations) {
162
//					System.out.println("---Overlap with : "+overlapAnnot.toString());
163
//				}
164
			} else { // we can create the annotation \o/
171
				// for (Annotation overlapAnnot : overlapingAnnotations) {
172
				// System.out.println("---Overlap with : "+overlapAnnot.toString());
173
				// }
174
			}
175
			else { // we can create the annotation \o/
165 176
				annot = new Annotation(type.getId(), value.getId(), startPos, endPos);
166 177
				
167 178
				em.persist(annot);
168 179
				
169
				//System.out.println("--- Create : "+annot.toString());
170
			}	
171
		} else { // update annotation
172
			//UPDATE 
173
			//System.out.println("--- Update annot : "+annot.toString()+" ----- ");
180
				// System.out.println("--- Create : "+annot.toString());
181
			}
182
		}
183
		else { // update annotation
184
			// UPDATE
185
			// System.out.println("--- Update annot : "+annot.toString()+" ----- ");
174 186
			annot.setReferentielVal(value.getId());
175 187
		}
176 188
		return overlapingAnnotations;
177 189
	}
178

  
190
	
179 191
	/**
180 192
	 * 
181 193
	 * @param refType
......
184 196
	 * @return
185 197
	 * @throws Exception
186 198
	 */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff