Révision 19

SRC/src/fr/triangle/hyperalign/gui/annot/ButtonColumn.java (revision 19)
1
package fr.triangle.hyperalign.gui.annot;
2

  
3
import java.awt.*;
4
import java.awt.event.*;
5
import javax.swing.*;
6
import javax.swing.border.*;
7
import javax.swing.table.*;
8

  
9
/**
10
 *  The ButtonColumn class provides a renderer and an editor that looks like a
11
 *  JButton. The renderer and editor will then be used for a specified column
12
 *  in the table. The TableModel will contain the String to be displayed on
13
 *  the button.
14
 *
15
 *  The button can be invoked by a mouse click or by pressing the space bar
16
 *  when the cell has focus. Optionally a mnemonic can be set to invoke the
17
 *  button. When the button is invoked the provided Action is invoked. The
18
 *  source of the Action will be the table. The action command will contain
19
 *  the model row number of the button that was clicked.
20
 *
21
 */
22
public class ButtonColumn extends AbstractCellEditor
23
	implements TableCellRenderer, TableCellEditor, ActionListener, MouseListener
24
{
25
	private JTable table;
26
	private Action action;
27
	private int mnemonic;
28
	private Border originalBorder;
29
	private Border focusBorder;
30

  
31
	private JButton renderButton;
32
	private JButton editButton;
33
	private Object editorValue;
34
	private boolean isButtonColumnEditor;
35

  
36
	/**
37
	 *  Create the ButtonColumn to be used as a renderer and editor. The
38
	 *  renderer and editor will automatically be installed on the TableColumn
39
	 *  of the specified column.
40
	 *
41
	 *  @param table the table containing the button renderer/editor
42
	 *  @param action the Action to be invoked when the button is invoked
43
	 *  @param column the column to which the button renderer/editor is added
44
	 */
45
	public ButtonColumn(JTable table, Action action, int column)
46
	{
47
		this.table = table;
48
		this.action = action;
49

  
50
		renderButton = new JButton();
51
		editButton = new JButton();
52
		editButton.setFocusPainted( false );
53
		editButton.addActionListener( this );
54
		originalBorder = editButton.getBorder();
55
		setFocusBorder( new LineBorder(Color.BLUE) );
56

  
57
		TableColumnModel columnModel = table.getColumnModel();
58
		columnModel.getColumn(column).setCellRenderer( this );
59
		columnModel.getColumn(column).setCellEditor( this );
60
		table.addMouseListener( this );
61
	}
62

  
63

  
64
	/**
65
	 *  Get foreground color of the button when the cell has focus
66
	 *
67
	 *  @return the foreground color
68
	 */
69
	public Border getFocusBorder()
70
	{
71
		return focusBorder;
72
	}
73

  
74
	/**
75
	 *  The foreground color of the button when the cell has focus
76
	 *
77
	 *  @param focusBorder the foreground color
78
	 */
79
	public void setFocusBorder(Border focusBorder)
80
	{
81
		this.focusBorder = focusBorder;
82
		editButton.setBorder( focusBorder );
83
	}
84

  
85
	public int getMnemonic()
86
	{
87
		return mnemonic;
88
	}
89

  
90
	/**
91
	 *  The mnemonic to activate the button when the cell has focus
92
	 *
93
	 *  @param mnemonic the mnemonic
94
	 */
95
	public void setMnemonic(int mnemonic)
96
	{
97
		this.mnemonic = mnemonic;
98
		renderButton.setMnemonic(mnemonic);
99
		editButton.setMnemonic(mnemonic);
100
	}
101

  
102
	@Override
103
	public Component getTableCellEditorComponent(
104
		JTable table, Object value, boolean isSelected, int row, int column)
105
	{
106
		if (value == null)
107
		{
108
			editButton.setText( "" );
109
			editButton.setIcon( null );
110
		}
111
		else if (value instanceof Icon)
112
		{
113
			editButton.setText( "" );
114
			editButton.setIcon( (Icon)value );
115
		}
116
		else
117
		{
118
			editButton.setText( value.toString() );
119
			editButton.setIcon( null );
120
		}
121

  
122
		this.editorValue = value;
123
		return editButton;
124
	}
125

  
126
	@Override
127
	public Object getCellEditorValue()
128
	{
129
		return editorValue;
130
	}
131

  
132
//
133
//  Implement TableCellRenderer interface
134
//
135
	public Component getTableCellRendererComponent(
136
		JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
137
	{
138
		if (isSelected)
139
		{
140
			renderButton.setForeground(table.getSelectionForeground());
141
	 		renderButton.setBackground(table.getSelectionBackground());
142
		}
143
		else
144
		{
145
			renderButton.setForeground(table.getForeground());
146
			renderButton.setBackground(UIManager.getColor("Button.background"));
147
		}
148

  
149
		if (hasFocus)
150
		{
151
			renderButton.setBorder( focusBorder );
152
		}
153
		else
154
		{
155
			renderButton.setBorder( originalBorder );
156
		}
157

  
158
//		renderButton.setText( (value == null) ? "" : value.toString() );
159
		if (value == null)
160
		{
161
			renderButton.setText( "" );
162
			renderButton.setIcon( null );
163
		}
164
		else if (value instanceof Icon)
165
		{
166
			renderButton.setText( "" );
167
			renderButton.setIcon( (Icon)value );
168
		}
169
		else
170
		{
171
			renderButton.setText( value.toString() );
172
			renderButton.setIcon( null );
173
		}
174

  
175
		return renderButton;
176
	}
177

  
178
//
179
//  Implement ActionListener interface
180
//
181
	/*
182
	 *	The button has been pressed. Stop editing and invoke the custom Action
183
	 */
184
	public void actionPerformed(ActionEvent e)
185
	{
186
		int row = table.convertRowIndexToModel( table.getEditingRow() );
187
		fireEditingStopped();
188

  
189
		//  Invoke the Action
190

  
191
		ActionEvent event = new ActionEvent(
192
			table,
193
			ActionEvent.ACTION_PERFORMED,
194
			"" + row);
195
		action.actionPerformed(event);
196
	}
197

  
198
//
199
//  Implement MouseListener interface
200
//
201
	/*
202
	 *  When the mouse is pressed the editor is invoked. If you then then drag
203
	 *  the mouse to another cell before releasing it, the editor is still
204
	 *  active. Make sure editing is stopped when the mouse is released.
205
	 */
206
    public void mousePressed(MouseEvent e)
207
    {
208
    	if (table.isEditing()
209
		&&  table.getCellEditor() == this)
210
			isButtonColumnEditor = true;
211
    }
212

  
213
    public void mouseReleased(MouseEvent e)
214
    {
215
    	if (isButtonColumnEditor
216
    	&&  table.isEditing())
217
    		table.getCellEditor().stopCellEditing();
218

  
219
		isButtonColumnEditor = false;
220
    }
221

  
222
    public void mouseClicked(MouseEvent e) {}
223
	public void mouseEntered(MouseEvent e) {}
224
    public void mouseExited(MouseEvent e) {}
225
}
SRC/src/fr/triangle/hyperalign/gui/annot/DictionaryPane.java (revision 19)
40 40
import javax.swing.JScrollPane;
41 41
import javax.swing.JTextField;
42 42

  
43
import fr.triangle.hyperalign.gui.HMManager;
43
import fr.triangle.hyperalign.gui.HMController;
44 44
import fr.triangle.hyperalign.gui.Hypermachiavel;
45 45
import fr.triangle.hyperalign.kernel.DataManager.DictionaryManager;
46 46
import fr.triangle.hyperalign.kernel.DisplayData;
......
70 70
	private String iconPath = "fr/triangle/hyperalign/gui/icons";
71 71
	private DictionaryParameters parameters;
72 72
	private Vector results;
73
	private HMManager manager;
73
	private HMController manager;
74 74
	private DictionaryManager dicoManager;
75 75
	
76 76
	private boolean searchForAllConcepts;
......
125 125
	private JButton addOccsButt;
126 126
	private boolean hasResults = false;
127 127

  
128
	public DictionaryPane(HMManager manager){
128
	public DictionaryPane(HMController manager){
129 129
		this.manager = manager;
130
		this.parameters = manager.getDictionaryParameters();
130
		this.parameters = manager.getDictionaryController().getDictionaryParameters();
131 131
		this.dicoManager = manager.getDataManager().getDictionaryManager();
132 132
		this.results = new Vector();	
133 133
		this.res = HyperalignData.getInstance().getResourceBundle();
......
419 419
			if(parameters.getOption(DictionaryParameters.DICO_EDITINFO)){
420 420
				textField = dicoElement.getName();
421 421
				if(!parameters.getAnnotationType().equals(Dictionary.DICO_OCC)){
422
					nbChildren = ((DictionaryElement) parameters.getAnnotationElement()).children().size()+"";
422
					nbChildren = ((DictionaryElement) parameters.getAnnotationElement()).childrenVect().size()+"";
423 423
					if(parameters.getAnnotationType().equals(Dictionary.DICO_DICO)){
424 424
						///TERMINOLOGY
425 425
						titleChildren = res.getString("I18N_ANNOTPANE_CONCEPTS");
SRC/src/fr/triangle/hyperalign/gui/annot/AnnotationPane.java (revision 19)
17 17
import java.awt.event.WindowEvent;
18 18
import java.beans.PropertyChangeEvent;
19 19
import java.beans.PropertyChangeListener;
20
import java.util.Enumeration;
20 21
import java.util.HashMap;
21 22
import java.util.Iterator;
22 23
import java.util.Observable;
......
39 40
import javax.swing.JScrollPane;
40 41
import javax.swing.JTextField;
41 42

  
42
import fr.triangle.hyperalign.gui.HMManager;
43
import fr.triangle.hyperalign.gui.HMController;
43 44
import fr.triangle.hyperalign.gui.Hypermachiavel;
44 45
import fr.triangle.hyperalign.kernel.DataManager.DictionaryManager;
45 46
import fr.triangle.hyperalign.kernel.DisplayData;
......
73 74
	private String iconPath = "fr/triangle/hyperalign/gui/icons";
74 75
	private AnnotationParameters parameters;
75 76
	private Vector results;
76
	private HMManager manager;
77
	private HMController manager;
77 78
	private TerminologyManager terminoManager;
78 79
	
79 80
	private boolean searchForAllConcepts;
......
139 140
	private JButton addOccsButt;
140 141
	private boolean hasResults = false;
141 142

  
142
	public AnnotationPane(HMManager manager){
143
	public AnnotationPane(HMController manager){
143 144
		this.manager = manager;
144
		this.parameters = manager.getAnnotationParameters();
145
		this.parameters = manager.getAnnotationController().getAnnotationParameters();
145 146
		this.terminoManager = manager.getDataManager().getTerminologyManager();
146 147
		this.results = new Vector();	
147 148
		this.res = HyperalignData.getInstance().getResourceBundle();
......
595 596
			if(parameters.getOption(AnnotationParameters.ANNOTATION_EDITINFO)){
596 597
				textField = terminoElement.getName();
597 598
				if(!parameters.getAnnotationType().equals(Terminology.TERMINOLOGY_OCC)){
598
					nbChildren = ((TerminologyElement) parameters.getAnnotationElement()).children().size()+"";
599
					nbChildren = ((TerminologyElement) parameters.getAnnotationElement()).childrenVect().size()+"";
599 600
					if(parameters.getAnnotationType().equals(Dictionary.DICO_DICO)){
600 601
						///TERMINOLOGY
601 602
						titleChildren = res.getString("I18N_ANNOTPANE_CONCEPTS");
......
1102 1103
		}
1103 1104
		terms.add(termEl);
1104 1105
		nbOccsAdded = terminoManager.addOccurrences(occs, terms); //termEl.getTerminology(), 
1105
		manager.getSearchManager().resetSearchTerminology();
1106
		manager.getSearchController().resetSearchTerminology();
1106 1107
		String message = nbOccsAdded+" "+res.getString("I18N_ANNOTPANE_OCCS_DIALOGMESSAGE");
1107 1108
		return message;
1108 1109
	}
SRC/src/fr/triangle/hyperalign/gui/annot/EquiInfoPane.java (revision 19)
30 30
import fr.triangle.hyperalign.kernel.dico.DictionaryElement;
31 31
import fr.triangle.hyperalign.kernel.termino.TerminologyElement;
32 32

  
33
/**
34
 * OLD CLASS ??
35
 * @author gazelledess
36
 *
37
 */
33 38

  
34 39
public class EquiInfoPane extends JDialog implements ActionListener, MouseListener, PropertyChangeListener, Observer {
35 40
		
......
87 92
			
88 93
			columnNames[0] = res.getString("I18N_EQUIVALENCEINFOPANE_COL0");//Type of Information 
89 94
			columnNames[1] = res.getString("I18N_EQUIVALENCEINFOPANE_COL1");//Nb
90
			
91
				
92
			
93 95
			resultTableModel = new ResultTableModel(columnNames, 4);
94
				
95 96
			resultTableModel.setValueAt(res.getString("I18N_EQUIVALENCEINFOPANE_LINE0"), 0, 0); //Nb occurrences (vocabulary) 
96 97
			resultTableModel.setValueAt(res.getString("I18N_EQUIVALENCEINFOPANE_LINE1"), 1, 0); //Nb occurrences (terminology) 
97 98
			resultTableModel.setValueAt(res.getString("I18N_EQUIVALENCEINFOPANE_LINE2")+" "+source, 2, 0); //Nb occurrences (terminology) in equivalence with Imperio
SRC/src/fr/triangle/hyperalign/gui/annot/EquivalencePane.java (revision 19)
3 3
import java.awt.BorderLayout;
4 4
import java.awt.Color;
5 5
import java.awt.Dimension;
6
import java.awt.Font;
7 6
import java.awt.GridBagConstraints;
8 7
import java.awt.GridBagLayout;
9 8
import java.awt.GridLayout;
......
14 13
import java.awt.event.KeyEvent;
15 14
import java.awt.event.MouseEvent;
16 15
import java.awt.event.MouseListener;
16
import java.net.URL;
17 17
import java.util.HashMap;
18 18
import java.util.Iterator;
19 19
import java.util.Observable;
......
35 35
import javax.swing.JPopupMenu;
36 36
import javax.swing.JRadioButton;
37 37
import javax.swing.JScrollPane;
38
import javax.swing.JSplitPane;
38 39
import javax.swing.JTabbedPane;
39 40
import javax.swing.JTable;
40 41
import javax.swing.JTextField;
42
import javax.swing.JToolBar;
41 43
import javax.swing.KeyStroke;
42 44
import javax.swing.SwingConstants;
43 45
import javax.swing.SwingUtilities;
......
51 53
import org.jfree.chart.plot.PiePlot;
52 54
import org.jfree.data.general.DefaultPieDataset;
53 55

  
54
import fr.triangle.hyperalign.gui.HMManager;
56
import fr.triangle.hyperalign.gui.HMController;
55 57
import fr.triangle.hyperalign.gui.Hypermachiavel;
56 58
import fr.triangle.hyperalign.gui.concord.ResultTableModel;
57 59
import fr.triangle.hyperalign.gui.graph.EquivalenceGraph;
......
87 89
	private String iconPath = "fr/triangle/hyperalign/gui/icons";
88 90
	//private HashMap<HyperalignText, OccurrenceSet> elements; //key = text name ; value = 
89 91

  
92
	private JButton addSeeCommentButton;
93
	private JButton addButton;
94
	private JButton removeButton;
95
	private JButton okButton;
96
	private JButton deleteButton;
97
	private JButton cancelButton;
98
	private HyperalignText currentText;
90 99
	private JTable listEquiTable;
100
	private JScrollPane scrollEquiTable;
91 101
	private EquivalenceElement equiEl;
92 102
	private EquivalenceManager tradManager;
93
	private HMManager manager;
103
	private HMController manager;
104
	private Vector<ConceptEquivalenceElement> equisForTerminoEls;
94 105

  
95 106
	private Dictionary sourceLang;
96 107
	private Dictionary targetLang;
97
	private String type = "";
108
	//private String type = "";
98 109
	private DictionaryElement sourceElement;
110
	private ConceptEquivalenceElement sourceTerminoElement;
99 111
	private Vector<ConceptEquivalenceElement> conceptEquivalenceElements;
100 112

  
101
	private Vector <HyperalignText> authorsSelected;
102
	
103
	private JLabel labelOccSource;
113
	private JComboBox labelOccSource;
104 114
	private JButton searchButton;
105 115
	private JButton showOccButton;
116
	private JButton showOccAuthorButton;
106 117
	private JButton exportButton;
118
	private JButton infoButton;
107 119
	private JButton graphButton;
108 120
	private JComboBox boxLang;
109 121
	private JComboBox levelBox;
122
	private JComboBox boxAuthor;
110 123
	private JComboBox boxWidth;
124
	private HyperalignText selectedAuthor;
111 125

  
112
	private String level;
113 126
	private String [] columnNames ;
114 127
	private JTable listResultTable;
115 128
	private TableRowSorter<ResultTableModel> sorter;
116 129
	private ResultTableModel resultTableModel;
117 130
	private JScrollPane scrollResult;
118

  
131
	private JScrollPane scrollPieChart;
132
	
133
	private ResultTableModel resultTableNoTranslation;
134
	private JTable listNoTranslationTable;
135
	private JScrollPane scrollNoTranslation;
136
	
119 137
	private String [] columnNamesAuthor ;
120 138
	private JTable listResultTableAuthor;
121 139
	private ResultTableModel resultTableModelAuthor;
122 140
	private JScrollPane scrollResultAuthor;
123 141
	
124
	private JPanel conceptPanel;
125
	private JPanel conceptByAuthorPanel;
126
	private JScrollPane scrollResultPie;
127
	
128 142
	private JScrollPane scrollResultAuthorPie;
129
	
130
	private JTabbedPane tabPaneTable;
131
	private JTabbedPane tabPanePieChart;
132

  
133 143
	private JTabbedPane tabPane;
134
	private HashMap<ConceptEquivalenceElement,Object> selectedEquivalences;
144
	private JTabbedPane tabPaneForGraphView;
145
	private JTabbedPane tabPaneForTableView;
146
	private JTabbedPane tabPaneForPieChartView;
147
	private HashMap<ConceptEquivalenceElement,Vector<Object>> selectedEquivalences;
135 148
	private Vector<EquivalenceElement> selectedTargetEquivalences;
136 149
	private String neighbourhoodWidth = "1";
137 150
	private int nbOccSourceInEqui;
138 151

  
152
	private JTextField commentField;
139 153
	private EquivalenceGraph graph;
154
	private EquivalenceGraph graphByAuthor;
140 155
	private boolean withSizes = false;
141 156
	private JCheckBox graphSizeBox;
142 157
	private int editEquivalence;
143
	private JComboBox authorGraphBox;
144 158
	private HyperalignText author;
145
	private boolean exportOcc;
159
	private String level;
160
	private HyperalignText selectedText;
161
	private String export;
146 162
	public final static String EXPORT_AUTHOR = "exportAuthor";
147 163
	public final static String EXPORT_OCC = "exportOccurrences";
148

  
149
	public EquivalencePane(HMManager manager){
164
	public final static String EXPORT_IMAGE = "exportImageGraphe";
165
	public HashMap<JCheckBox, HyperalignText> checkboxForTexts ;
166
	public Vector<HyperalignText> selectedAuthors;
167
	
168
	private HashMap<DictionaryElement, HashMap<HyperalignText, Integer>> equivalencesByAuthor;
169
	private Vector<HyperalignText> textsForTargetLang ;
170
	
171
	public EquivalencePane(HMController manager){
150 172
		this.res = HyperalignData.getInstance().getResourceBundle();
151 173
		this.manager = manager;
152 174
		tradManager = manager.getDataManager().getEquivalenceManager();
......
157 179

  
158 180
	public void initGui(boolean reinit){
159 181
		editEquivalence = tradManager.getEditingEquivalence();
182
		if(reinit){
183
			this.removeAll();
184
		}
160 185
		switch (editEquivalence){
161 186
		case EquivalenceManager.EQUIVALENCE_OCCURRENCE :
162
			AnnotEquiPane annotEqui = new AnnotEquiPane(manager);
163
			this.add(annotEqui,BorderLayout.CENTER);
187
			AnnotEquiPane annotEqui  = new AnnotEquiPane(manager);
188
			
189
			this.add(annotEqui, BorderLayout.CENTER);
164 190
			break;
165 191
		case EquivalenceManager.EQUIVALENCE_CONCEPT :
166 192
			initTable(reinit);
......
171 197

  
172 198

  
173 199
	
174

  
175 200
	
176 201

  
202

  
177 203
	private void initTable(boolean reinit){
178 204
		this.targetLang = tradManager.getTargetLangForGraph();
179 205
		this.sourceLang = tradManager.getSourceLangForGraph();
180 206
		this.sourceElement = tradManager.getSourceElement();
207
		
181 208
		String name = "";
182 209
		if(sourceElement!=null){
183 210
			name = sourceElement.getName();
184 211
		}else {
185 212
			name = tradManager.getSourceString();
186 213
		}
214
		this.sourceTerminoElement = new ConceptEquivalenceElement(name, "CEQS");
187 215
		if(sourceElement==null){
188
			System.out.println("AnnotEquiPane.initTable() ---- NOT TERMINO ELEMENT TO TAKE IN CONSIDERATION !");
216
			System.out.println("EquivalencePane.initTable() ---- NOT TERMINO ELEMENT TO TAKE IN CONSIDERATION !");
189 217
		}else {
190
			System.out.println("AnnotEquiPane.initTable() ---- for "+sourceElement+" in LANG [TARGET="+targetLang+"]-[SOURCE="+sourceLang+"]");
218
			System.out.println("EquivalencePane.initTable() ---- for "+sourceElement+" in LANG [TARGET="+targetLang+"]-[SOURCE="+sourceLang+"]");
191 219
		}
192 220

  
193 221

  
......
201 229
		}
202 230
	}
203 231

  
232
	private JToolBar initTriPanel(Dictionary[] targetLangs){
233
		JToolBar triPanel = new JToolBar();
234
		
235
		///LABEL 
236
		JPanel aboutSourcePanel = new JPanel();
237
		JLabel aboutSource;
238
		int nbOccSource = 0;
239
		System.out.println("EquivalencePane.initTriPanel() - SOURCE ELEMENT (type = "+sourceElement.getReference()+")");
240
		if(sourceElement.getReference().equals(Dictionary.DICO_LEMME)){
241
			Vector<DictionaryElement> lemmesInEquivalence = tradManager.getLemmesInEquivalence(sourceLang);
242
			System.out.println("EquivalencePane.initTriPanel() - HOW MANY LEMMES IN EQUIVALENCE ? "+lemmesInEquivalence.size());
243
			if (lemmesInEquivalence.size()>0){
244
				labelOccSource = new JComboBox(lemmesInEquivalence);
245
				labelOccSource.setPreferredSize(new Dimension(80,20));
246
				labelOccSource.setSelectedItem(sourceElement);
247
				
248
				nbOccSource = sourceLang.getOccurrencesForLemme(sourceElement).size();
249
				aboutSourcePanel.add(labelOccSource);
250
			}
251
			aboutSource = new JLabel(nbOccSource+" "+res.getString("I18N_EQUIVALENCEPANE_LABEL_2"));		
252
			
253
		}else {
254
			aboutSource = new JLabel(sourceElement.getName());
255
		}
256
		aboutSourcePanel.add(aboutSource);
257
		triPanel.add(aboutSourcePanel);
258
		
259
		Object[] authorsText = new Object[textsForTargetLang.size()+1];
260
		for(int i = 0 ; i < textsForTargetLang.size() ; ++i) {
261
			authorsText[i] = textsForTargetLang.get(i);
262
		}
263
		
264
		//Choix dans le graphe des �quivalences
265
		authorsText[textsForTargetLang.size()] = res.getString("I18N_EQUIVALENCEPANE_LABEL_ALLAUTHORS_GRAPH");
266
		boxAuthor = new JComboBox(authorsText);
267
		boxAuthor.setPreferredSize(new Dimension(100,25));
268
		if(selectedAuthor!=null){
269
			boxAuthor.setSelectedItem(selectedAuthor);
270
		}else {
271
			boxAuthor.setSelectedItem(res.getString("I18N_EQUIVALENCEPANE_LABEL_ALLAUTHORS_GRAPH"));
272
		}
273
		boxAuthor.addActionListener(new ActionListener(){
274
			public void actionPerformed(ActionEvent ae){	
275
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
276
				if(o.toString().equals(res.getString("I18N_EQUIVALENCEPANE_LABEL_ALLAUTHORS_GRAPH"))){
277
					selectedAuthor = null;
278
					selectedAuthors = null;
279
				}else {
280
					selectedAuthor = (HyperalignText) o;	
281
					selectedAuthors = new Vector<HyperalignText>();
282
					selectedAuthors.add(selectedAuthor);
283
				}
284
				boxAuthor.setSelectedItem(o);
285
				tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, false, selectedAuthors);
286
				initGuiWithTable();
287
			}
288
		});
289
		triPanel.add(boxAuthor);
290
		
291
		boxLang = new JComboBox(targetLangs);
292
		boxLang.setPreferredSize(new Dimension(100,25));
293
		if(targetLang!=null){
294
			boxLang.setSelectedItem(targetLang);
295
		}
296
		boxLang.addActionListener(new ActionListener(){
297
			public void actionPerformed(ActionEvent ae){	
298
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
299
				targetLang = (Dictionary)o;	
300
				boxLang.setSelectedItem(o);
301
				initTable(true); 
302
			}
303
		});
304
		triPanel.add(boxLang);
305
	
306
		/*String [] levels = {Dictionary.DICO_LEMME, Dictionary.DICO_FORM, Dictionary.DICO_OCC};
307
		levelBox = new JComboBox(levels);
308
		levelBox.setPreferredSize(new Dimension(100,25));
309
		levelBox.addActionListener(new ActionListener(){
310
			public void actionPerformed(ActionEvent ae){	
311
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
312
				level = (String)o;	
313
				levelBox.setSelectedItem(o);
314
				//initTable(true); 
315
				System.out.println("EquivalencePane - levelBox - TO DO !!!!!!!!!!!!!!!!!!!");
316
			}
317
		});
318
		triPanel.add(levelBox);*/
319
	
320
		String [] widths = {"1","2","3","4","5","6","7","8","9","10","infinite"};
321
		boxWidth = new JComboBox(widths);
322
		boxWidth.setPreferredSize(new Dimension(100,25));
323
		boxWidth.setSelectedItem(neighbourhoodWidth);
324
	
325
		boxWidth.addActionListener(new ActionListener(){
326
			public void actionPerformed(ActionEvent ae){	
327
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
328
				neighbourhoodWidth = (String)o;	
329
				boxWidth.setSelectedItem(o);
330
				initGuiWithTable();
331
			}
332
		});
333
		triPanel.add(boxWidth);
334
	
335
		graphSizeBox = new JCheckBox(res.getString("I18N_EQUIVALENCEPANE_GRAPHSIZE_OPTION"));
336
		graphSizeBox.setSelected(withSizes);
337
		graphSizeBox.addItemListener(this);
338
		triPanel.add(graphSizeBox);
339
	
340
		
341
		ImageIcon graphButt = ImageConfigure.createImageIcon(iconPath+"/Graph.gif");
342
		graphButton = new JButton(graphButt);
343
		graphButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_GRAPH"));
344
		triPanel.add(graphButton);
345
	
346
		/*
347
		 ///SHOW EQUIVALENCE BUTTON
348
		ImageIcon displayButt = ImageConfigure.createImageIcon(iconPath+"/Column.gif");
349
		showOccButton = new JButton(displayButt);
350
		showOccButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_SEARCHOCC"));
351
		triPanel.add(showOccButton);
352
	
353
		///SHOW EQUIVALENCE AUTHOR BUTTON
354
		ImageIcon displayAuthorButt = ImageConfigure.createImageIcon(iconPath+"/ColumnAuthor.gif");
355
		showOccAuthorButton = new JButton(displayButt);
356
		showOccAuthorButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_SEARCHOCCAUTHOR"));
357
		triPanel.add(showOccAuthorButton);
358
	
359
		///SEARCH BUTTON
360
		ImageIcon searchButt = ImageConfigure.createImageIcon(iconPath+"/Search.gif");
361
		searchButton = new JButton(searchButt);
362
		searchButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_DOUBLESEARCH"));
363
		triPanel.add(searchButton);
364
	
365
		///EXPORT BUTTON
366
		ImageIcon exportButt = ImageConfigure.createImageIcon(iconPath+"/Save.gif");
367
		exportButton = new JButton(exportButt);
368
		exportButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_EXPORT"));
369
		triPanel.add(exportButton);
370
	
371
		
372
		//ACTIONS ---------
373
		showOccButton.addActionListener(new ActionListener(){
374
			public void actionPerformed(ActionEvent e) {
375
				showEquivalences();
376
			}
377
		});
378
		
379
		showOccAuthorButton.addActionListener(new ActionListener(){
380
			public void actionPerformed(ActionEvent e) {
381
				showEquivalencesByAuthor();
382
			}
383
		});
384
	
385
		searchButton.addActionListener(new ActionListener(){
386
			public void actionPerformed(ActionEvent e) {
387
				searchForEquivalences();
388
			}
389
		});
390
	
391
		exportButton.addActionListener(new ActionListener(){
392
			public void actionPerformed(ActionEvent e) {
393
				export();
394
			}
395
		});
396
	
397
		infoButton.addActionListener(new ActionListener(){
398
			public void actionPerformed(ActionEvent e) {
399
				ResultTableModel tableModel = prepareTableByAuthor();
400
				EquiTextPane textPane = new EquiTextPane(tableModel);
401
				textPane.setLocationRelativeTo(Hyperalign.getInstance());
402
				textPane.setAlwaysOnTop(true);
403
			}
404
		});*/
405
	
406
		graphButton.addActionListener(new ActionListener(){
407
			public void actionPerformed(ActionEvent e) {
408
				showGraphByAuthor();
409
			}
410
		});
411
	
412
	
413
		return triPanel;
414
	}
415

  
416

  
417

  
204 418
	private void initGuiWithTable(){
419
		
205 420
		//at first, we must select a target lang to get the table of target equivalences
206 421
		HashMap<Dictionary, Vector<HyperalignText>> langs = tradManager.getDictionaryAndTextForEquivalences();
207 422
		Set<Dictionary> langKeys = langs.keySet();
......
217 432
			}
218 433
		}
219 434

  
435
		textsForTargetLang = langs.get(targetLang);
220 436
		/////////////////// BUILD INFO for TABLE ////////////////
221 437
		if(targetLang!=null){
222 438
			DictionaryElement el = null;
223 439

  
224 440
			if(neighbourhoodWidth.equals("infinite")){
225 441
				el = sourceLang.getRoot();
226
				tradManager.buildInfoForGraph(el, targetLang, neighbourhoodWidth, false, null);				
442
				tradManager.buildInfoForGraph(el, targetLang, neighbourhoodWidth, false, selectedAuthors);				
227 443
				manager.reinitHyperalignPane(Hypermachiavel.EQUIGRAPH_TAB, true, true);
228 444
			}else {
229 445
				el = sourceElement;
230
				tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, false, null);
446
				tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, false, selectedAuthors);
231 447
			}
232 448
			conceptEquivalenceElements = tradManager.buildConceptEquivalenceElements(el, targetLang);
233 449
		}
234 450
		//////////////////////////////////////////////////////
235

  
451
		equivalencesByAuthor = tradManager.showEquivalencesByAuthor(conceptEquivalenceElements, targetLang);
452
		
236 453
		this.removeAll();	
237 454

  
238 455
		//PARAM PANEL 	
239
		JPanel panelParams = initTriPanel(targetLangs);	
456
		JToolBar panelParams = initTriPanel(targetLangs);	
240 457
		this.setLayout(new BorderLayout());
241 458
		this.add(panelParams, BorderLayout.NORTH);
242 459

  
243 460
		/////////////////////////////////////////////
244
		//GRAPHS, TABLES or PIE CHARTS		
461
		//JPanel graphPanel = new JPanel();
462
		//graphPanel.setLayout(new GridLayout(1,2));
463

  
464
		tradManager.setGraphSizeOption(withSizes);
245 465
		tabPane = new JTabbedPane();
246 466
		
247
		///// GRAPHS 
248
		tradManager.setGraphSizeOption(withSizes);
467
		tabPaneForGraphView = buildGraphView();
468
		tabPane.add(res.getString("I18N_EQUIVALENCEPANE_TAB_GRAPH"), tabPaneForGraphView);
469
		tabPaneForTableView = buildTableView();
470
		tabPane.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TABLE"), tabPaneForTableView);
471
		tabPaneForPieChartView = buildPieChartView();
472
		tabPane.add(res.getString("I18N_EQUIVALENCEPANE_TAB_PIECHART"), tabPaneForPieChartView);
473
		
474
	
475
		//JSplitPane splitVerticalPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, graph, tabPane);
476
		//splitVerticalPane.setOneTouchExpandable(true);
477
		//splitVerticalPane.setDividerLocation(500);
478
		//this.add(splitVerticalPane,BorderLayout.CENTER);
479
		this.add(tabPane, BorderLayout.CENTER);
480
	}
481

  
482
	private JTabbedPane buildGraphView(){
483
		tabPaneForGraphView = new JTabbedPane();
249 484
		graph = new EquivalenceGraph(manager, tradManager.getCurrentGraphUrls(), tradManager.getGraphAllConceptOption(), withSizes);
485
		tabPaneForGraphView.add(res.getString("I18N_EQUIVALENCEPANE_GRAPH_ALL"), graph);
486
		
487
		//Graph By Author
488
		Vector<HyperalignText> selectionOfAuthors = new Vector<HyperalignText>();
489
		if(textsForTargetLang.size()>4){
490
			for(int i = 0 ; i < 4 ; ++i) {
491
				HyperalignText text = textsForTargetLang.get(i);
492
				selectionOfAuthors.add(text);
493
			}
494
		}else {
495
			selectionOfAuthors = textsForTargetLang;
496
		}
497
		System.out.println("EquivalencePane.buildGraphView ----- Graphe avec "+selectionOfAuthors.size()+" auteurs");
498
		tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, true, selectionOfAuthors);
499
		URL[] urlsEquivalence = tradManager.getCurrentGraphUrls(); 
500
		boolean withSizes = tradManager.getGraphSizeOption();
501
		boolean withAllConcepts = tradManager.getGraphAllConceptOption();
502
		graphByAuthor = new EquivalenceGraph(manager, urlsEquivalence, withAllConcepts, withSizes);
503
		tabPaneForGraphView.add(res.getString("I18N_EQUIVALENCEPANE_GRAPH_BYAUTHOR"), graphByAuthor);
504
		
505
		return tabPaneForGraphView;
506
	}
250 507
	
508
	private JTabbedPane buildTableView(){
509
		tabPaneForTableView = new JTabbedPane();
510
		initConceptTable();
511
		tabPaneForTableView.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE1"), scrollResult);
251 512
		
252
		///// TABLES Tabbedpane
253
		tabPaneTable = new JTabbedPane();
513
		initConceptByAuthorTable();
514
		tabPaneForTableView.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE2"), scrollResultAuthor);
254 515
		
255
		initConceptTablePie();//initConceptTable();
256
		tabPaneTable.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE1"), conceptPanel);//scrollResult
257

  
258
		initConceptByAuthorTablePie();//initConceptByAuthorTable();
259
		tabPaneTable.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE2"), conceptByAuthorPanel);//scrollResultAuthor
260
		tabPaneTable.setSelectedComponent(conceptPanel);
261

  
262
		///// PIE CHARTS Tabbedpane
263
		tabPanePieChart = new JTabbedPane();
264
		buildConceptPieChart();
265
		tabPanePieChart.add("Concept cibles", scrollResultPie);
266

  
267
		buildConceptByAuthorPieChart();
268
		tabPanePieChart.add("Concept cibles par auteur", scrollResultAuthorPie);
269

  
270
		tabPane.add("Graphes", graph);
271
		tabPane.add("Tableaux-Camemberts", tabPaneTable);
272
		tabPane.add("Camemberts", tabPanePieChart);
273
		tabPane.setSelectedComponent(graph);
516
		//"Absences de traduction"
517
		initMissingEquivalencesTable();
518
		tabPaneForTableView.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE3"), scrollNoTranslation);
519
		tabPaneForTableView.setSelectedComponent(scrollResult);
274 520
		
275
		this.add(tabPane,BorderLayout.CENTER);
521
		return tabPaneForTableView;
276 522
	}
277

  
278
	private void buildConceptPieChart(){
279
		if( conceptEquivalenceElements.size()>0) {
280
			DefaultPieDataset dataset = new DefaultPieDataset();
281

  
282
			ConceptEquivalenceElement conceptEquiEl = conceptEquivalenceElements.get(0);
283
			HashMap<Object, Vector<OccurrenceSet>> occsByConcept = conceptEquiEl.getOccurrences();
284
			Set keys = occsByConcept.keySet();
285
			Iterator itC = keys.iterator();
286
			while(itC.hasNext()){
287
				Object obj = itC.next();
288

  
289
				if(obj instanceof DictionaryElement){
290
					DictionaryElement element = (DictionaryElement) obj;
291
					dataset.setValue(element.getName(), occsByConcept.get(obj).size());
292
				}else {
293
					String element = (String) obj;
294
					dataset.setValue(element, occsByConcept.get(obj).size());
295
				}				
296
			}
297

  
298
			JFreeChart conceptChart = ChartFactory.createPieChart(
299
					conceptEquiEl.getName(),  // chart title
300
					dataset,             // data
301
					true,               // include legend
302
					true,
303
					false
304
					);
305

  
306
			PiePlot plot = (PiePlot) conceptChart.getPlot();
307
			plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
308
			plot.setNoDataMessage("No data available");
309
			plot.setCircular(false);
310
			plot.setLabelGap(0.02);
311
			JPanel conceptChartPanel =   new ChartPanel(conceptChart);
312
			scrollResultPie = new JScrollPane(conceptChartPanel);
313
			scrollResultPie.setPreferredSize(new Dimension(400,400));	
314
		}
523
	
524
	private JTabbedPane buildPieChartView(){
525
		tabPaneForPieChartView = new JTabbedPane();
526
		initConceptPieChart();
527
		tabPaneForPieChartView.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE1"), scrollPieChart);
528
		initConceptByAuthorPieChart();
529
		tabPaneForPieChartView.add(res.getString("I18N_EQUIVALENCEPANE_TAB_TITLE2"), scrollResultAuthorPie);
530
	
531
		return tabPaneForPieChartView;
315 532
	}
316

  
317
	private void buildConceptByAuthorPieChart(){
318
		JPanel conceptByAuthorChartPanel = new JPanel();
533
	
534
	private void initMissingEquivalencesTable(){
535
		Vector<HyperalignText> texts = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
536
		columnNames = new String[2];
537
		columnNames[0] = "Text";
538
		columnNames[1] = "Nb absence";
319 539
		
320
		if(conceptEquivalenceElements.size()>0){
321
			ConceptEquivalenceElement conceptEquiEl = conceptEquivalenceElements.get(0);
322

  
323
			HashMap<DictionaryElement, HashMap<HyperalignText, Integer>> equivalencesByAuthor = tradManager.showEquivalencesByAuthor(conceptEquivalenceElements, targetLang);
324
			Vector<HyperalignText> textsForTargetLang = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
325
			HashMap<HyperalignText, DefaultPieDataset> piePerText = new HashMap<HyperalignText, DefaultPieDataset>();
326
			for(HyperalignText t : textsForTargetLang){
327
				if(author!=null){
328
					if(t== author){
329
						DefaultPieDataset dataset = new DefaultPieDataset();
330
						piePerText.put(t, dataset);
331
					}
332
				}else{
333
					DefaultPieDataset dataset = new DefaultPieDataset();
334
					piePerText.put(t, dataset);
335
				}
336

  
337
			}
338

  
339
			Set<DictionaryElement> keys = equivalencesByAuthor.keySet();
340
			Iterator<DictionaryElement> it = keys.iterator();
341
			while (it.hasNext()) {
342
				DictionaryElement conceptTarget = it.next();
343
				HashMap<HyperalignText, Integer> nbByAuthor = equivalencesByAuthor.get(conceptTarget);
344
				for(int j = 0 ; j < textsForTargetLang.size(); ++j){
345
					
346
					HyperalignText text = textsForTargetLang.get(j);
347
					if(author!=null){
348
						if(text== author){
349
							DefaultPieDataset dataset = piePerText.get(text);
350
							Integer nb = nbByAuthor.get(text);
351
							dataset.setValue(conceptTarget.getName(), nb);
352
							
353
						}
354
					}else {
355
						DefaultPieDataset dataset = piePerText.get(text);
356
						Integer nb = nbByAuthor.get(text);
357
						dataset.setValue(conceptTarget.getName(), nb);
358
					}
359
					
360
				}
361
			}
362

  
363
			if(author==null){
364
				conceptByAuthorChartPanel.setLayout(new GridLayout(2,2));
365
			}
366
				
367
			for(HyperalignText t : piePerText.keySet()){
368
				DefaultPieDataset dataset = piePerText.get(t);
369
				JFreeChart conceptChart = ChartFactory.createPieChart(t.getName(), dataset, true, true, false);
370
				PiePlot plot = (PiePlot) conceptChart.getPlot();
371
				plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
372
				plot.setNoDataMessage("No data available");
373
				plot.setCircular(false);
374
				plot.setLabelGap(0.02);
375
				
376
				JPanel panel =   new ChartPanel(conceptChart);
377
				conceptByAuthorChartPanel.add(panel);
378
			}	
379

  
540
		resultTableNoTranslation = new ResultTableModel(columnNames, texts.size());	
541
		int i = 0;
542
		int nbNoEquivalence = 0;
543
		for(HyperalignText t : texts){
544
			resultTableNoTranslation.setValueAt(t.getName(),i,0);
545
			nbNoEquivalence = tradManager.findMissingEquivalences(sourceElement, t);
546
			resultTableNoTranslation.setValueAt(nbNoEquivalence,i,1);
547
			++i;
380 548
		}
381
		scrollResultAuthorPie = new JScrollPane(conceptByAuthorChartPanel);
382
		//scrollResultAuthorPie.setPreferredSize(new Dimension(400,400));	
549
		
550
		//findMissingEquivalences();
551
		//Boucle sur toutes les occurrences du concept source, dans le fichier des �quivalences, voir les fois o� celles-ci ne sont pas traduites 
552
		//Une colonne avec le nombre manquant (non traduction) par auteur
553
		//Introduire ce r�sultat dans PieChart par auteur (pour une meilleur repr�sentativit�)
554
		sorter = new TableRowSorter<ResultTableModel>(resultTableNoTranslation);
555
		listNoTranslationTable = new JTable(resultTableNoTranslation);
556
		listNoTranslationTable.setRowSorter(sorter);
557
		listNoTranslationTable.addMouseListener(this);
558
		scrollNoTranslation = new JScrollPane(listNoTranslationTable);
559
		scrollNoTranslation.setPreferredSize(new Dimension(400,400));	
383 560
	}
384

  
385

  
386
private void initConceptTablePie(){
387
	conceptPanel = new JPanel();
388
	conceptPanel.setLayout(new GridLayout(1,2));
389
	buildConceptTable();
390
	buildConceptPieChart();
391
	conceptPanel.add(scrollResult);
392
	conceptPanel.add(scrollResultPie);
393 561
	
394
}
395

  
396
private void initConceptByAuthorTablePie(){
397
	conceptByAuthorPanel = new JPanel();
398
	conceptByAuthorPanel.setLayout(new GridLayout(1,2));
399
	buildConceptByAuthorTable();
400
	buildConceptByAuthorPieChart();
401
	conceptByAuthorPanel.add(scrollResultAuthor);
402
	conceptByAuthorPanel.add(scrollResultAuthorPie);
403
	
404
}
405
	private void buildConceptTable(){
406
		
562
	private void initConceptTable(){
407 563
		columnNames = new String[3];	
408 564
		columnNames[0] = res.getString("I18N_EQUIVALENCEPANE_CONCEPTSOURCE");
409 565
		columnNames[1] = res.getString("I18N_EQUIVALENCEPANE_CONCEPTTARGET")+" ("+targetLang+")";
......
416 572
		}
417 573

  
418 574
		resultTableModel = new ResultTableModel(columnNames, nbLines);	
419

  
575
		
420 576
		int index = 0;
421 577
		for (int i = 0; i < conceptEquivalenceElements.size(); i++) {
422 578
			ConceptEquivalenceElement conceptEquiEl = conceptEquivalenceElements.get(i);
......
439 595

  
440 596
		}
441 597

  
442
		System.out.println("Equivalence.initGuiWithTable() = nb TABLE RESULTS #"+resultTableModel.getRowCount()+" for element -> "+sourceElement);
598
		System.out.println("EquivalencePane.initGuiWithTable() = nb TABLE RESULTS #"+resultTableModel.getRowCount()+" for element -> "+sourceElement);
443 599
		sorter = new TableRowSorter<ResultTableModel>(resultTableModel);
444 600
		listResultTable = new JTable(resultTableModel);
445 601
		listResultTable.setRowSorter(sorter);
446 602
		listResultTable.addMouseListener(this);
447 603
		scrollResult = new JScrollPane(listResultTable);
448
		//scrollResult.setPreferredSize(new Dimension(400,400));	
604
		scrollResult.setPreferredSize(new Dimension(400,400));	
605
	}
606
	
607
	private void initConceptByAuthorTable(){
449 608
		
450
	}
451

  
452
	private void buildConceptByAuthorTable(){
453
		HashMap<DictionaryElement, HashMap<HyperalignText, Integer>> equivalencesByAuthor = tradManager.showEquivalencesByAuthor(conceptEquivalenceElements, targetLang);
454
		Vector<HyperalignText> textsForTargetLang = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
455

  
456 609
		//COLUMNS ////////////////////
457 610
		columnNamesAuthor = new String[textsForTargetLang.size()+1];
458 611
		columnNamesAuthor[0] = res.getString("I18N_EQUIVALENCEPANE_CONCEPTTARGET");
......
461 614
			columnNamesAuthor[j+1] = text.getName();
462 615
		}
463 616
		//////////////////
464

  
617
	
465 618
		int nbLines = equivalencesByAuthor.size();
466 619
		resultTableModelAuthor = new ResultTableModel(columnNamesAuthor, nbLines);	
467

  
620
	
468 621
		//System.out.println("NB LINES ? "+nbLines);
469 622
		Set<DictionaryElement> keys = equivalencesByAuthor.keySet();
470 623
		Iterator<DictionaryElement> it = keys.iterator();
......
486 639
				}
487 640
			}
488 641
		}
489

  
642
	
490 643
		listResultTableAuthor = new JTable(resultTableModelAuthor);
491 644
		listResultTableAuthor.addMouseListener(this);
492 645
		scrollResultAuthor = new JScrollPane(listResultTableAuthor);
493 646
		scrollResultAuthor.setPreferredSize(new Dimension(400,400));	
494 647
	}
495 648

  
496
	private JPanel initTriPanel(Dictionary[] targetLangs){
497
		JPanel triPanel = new JPanel();
498 649

  
499
		//Choix dans le graphe des ?quivalences
500
		Vector<HyperalignText> textsForTargetLang = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
501
		authorGraphBox = new JComboBox(textsForTargetLang);
502
		authorGraphBox.setPreferredSize(new Dimension(100,25));
503
		if(author!=null){
504
			authorGraphBox.setSelectedItem(author);
505
		}
506
		authorGraphBox.addActionListener(new ActionListener(){
507
			public void actionPerformed(ActionEvent ae){	
508
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
509
				author = (HyperalignText)o;	
510
				authorGraphBox.setSelectedItem(o);
511
				initGuiWithTable();
512
			}
513
		});
514
		triPanel.add(authorGraphBox);
515 650

  
516
		///LABEL about the Equivalences
517
		labelOccSource = new JLabel();
518
		System.out.println("AnnotEquiPane.initTriPanel() - LABEL OCC SOURCE type = "+type);
519
		if(type.equals(Dictionary.DICO_LEMME)){
520
			int nbOccSource = sourceLang.getOccurrencesForLemme(sourceElement).size();
521
			//int nbOccSourceInEqui = tradManager.getCurrentEquivalenceElements().size();
522
			labelOccSource = new JLabel(/*nbOccSourceInEqui+" "+*/res.getString("I18N_EQUIVALENCEPANE_LABEL_1")+" "+
523
					sourceElement.getName()+" / "+nbOccSource+" "+res.getString("I18N_EQUIVALENCEPANE_LABEL_2"));
524
			System.out.println("   -   "+res.getString("I18N_EQUIVALENCEPANE_LABEL_1")+" "+
525
					sourceElement.getName()+" / "+nbOccSource+" "+res.getString("I18N_EQUIVALENCEPANE_LABEL_2"));
526
		}
527
		triPanel.add(labelOccSource);
528

  
529
		boxLang = new JComboBox(targetLangs);
530
		boxLang.setPreferredSize(new Dimension(100,25));
531
		if(targetLang!=null){
532
			boxLang.setSelectedItem(targetLang);
533
		}
534
		boxLang.addActionListener(new ActionListener(){
535
			public void actionPerformed(ActionEvent ae){	
536
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
537
				targetLang = (Dictionary)o;	
538
				boxLang.setSelectedItem(o);
539
				initTable(true); 
651
	private void initConceptByAuthorPieChart(){
652
		JPanel conceptByAuthorChartPanel = new JPanel();
653
		
654
		if(conceptEquivalenceElements.size()>0){
655
			ConceptEquivalenceElement conceptEquiEl = conceptEquivalenceElements.get(0);
656
			
657
			HashMap<HyperalignText, DefaultPieDataset> piePerText = new HashMap<HyperalignText, DefaultPieDataset>();
658
			for(HyperalignText t : textsForTargetLang){
659
				if(author!=null){
660
					if(t== author){
661
						DefaultPieDataset dataset = new DefaultPieDataset();
662
						piePerText.put(t, dataset);
663
	                   }	
664
				}else{
665
					DefaultPieDataset dataset = new DefaultPieDataset();
666
					piePerText.put(t, dataset);
667
				}
668
	        }
669
	
670
			Set<DictionaryElement> keys = equivalencesByAuthor.keySet();
671
			Iterator<DictionaryElement> it = keys.iterator();
672
			while (it.hasNext()) {
673
				DictionaryElement conceptTarget = it.next();
674
				HashMap<HyperalignText, Integer> nbByAuthor = equivalencesByAuthor.get(conceptTarget);
675
				for(int j = 0 ; j < textsForTargetLang.size(); ++j){
676
					
677
					HyperalignText text = textsForTargetLang.get(j);
678
					if(author!=null){
679
						if(text== author){
680
							DefaultPieDataset dataset = piePerText.get(text);
681
							Integer nb = nbByAuthor.get(text);
682
							dataset.setValue(conceptTarget.getName()+" : "+nb, nb);
683
						}	
684
					}else {
685
						DefaultPieDataset dataset = piePerText.get(text);
686
						Integer nb = nbByAuthor.get(text);
687
						dataset.setValue(conceptTarget.getName()+" : "+nb, nb);
688
					}
689
				}
690
				for(int j = 0 ; j < textsForTargetLang.size(); ++j){
691
					HyperalignText text = textsForTargetLang.get(j);
692
					DefaultPieDataset dataset = piePerText.get(text);
693
					int nbNoEquivalence = tradManager.findMissingEquivalences(sourceElement, text);
694
					dataset.setValue("No Translation : "+nbNoEquivalence, nbNoEquivalence);
695
				}
540 696
			}
541
		});
542
		triPanel.add(boxLang);
543

  
544
		String [] levels = {Dictionary.DICO_LEMME, Dictionary.DICO_FORM, Dictionary.DICO_OCC};
545
		levelBox = new JComboBox(levels);
546
		levelBox.setPreferredSize(new Dimension(100,25));
547
		levelBox.addActionListener(new ActionListener(){
548
			public void actionPerformed(ActionEvent ae){	
549
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
550
				level = (String)o;	
551
				levelBox.setSelectedItem(o);
552
				//initTable(true); 
553
				System.out.println("AnnotEquiPane - levelBox - TO DO !!!!!!!!!!!!!!!!!!!");
697
	
698
			if(author==null){
699
				conceptByAuthorChartPanel.setLayout(new GridLayout(2,2));
554 700
			}
555
		});
556
		triPanel.add(levelBox);
701
	
702
			for(HyperalignText t : piePerText.keySet()){
703
				DefaultPieDataset dataset = piePerText.get(t);
704
				JFreeChart conceptChart = ChartFactory.createPieChart(t.getName(), dataset, true, true, false);
705
				JPanel panel =   new ChartPanel(conceptChart);
706
				//DEFAULT_WIDTH and DEFAULT_HEIGHT: 680 x 420.
707
				panel.setPreferredSize(new Dimension(200,200));
708
				conceptByAuthorChartPanel.add(panel);
709
			}	
710
	
711
		}
712
		scrollResultAuthorPie = new JScrollPane(conceptByAuthorChartPanel);
713
		//scrollResultAuthorPie.setPreferredSize(new Dimension(400,400));
714
	}
557 715

  
558
		String [] widths = {"1","2","3","4","5","6","7","8","9","10","infinite"};
559
		boxWidth = new JComboBox(widths);
560
		boxWidth.setPreferredSize(new Dimension(100,25));
561
		boxWidth.setSelectedItem(neighbourhoodWidth);
562 716

  
563
		boxWidth.addActionListener(new ActionListener(){
564
			public void actionPerformed(ActionEvent ae){	
565
				Object o = ((JComboBox)ae.getSource()).getSelectedItem();
566
				neighbourhoodWidth = (String)o;	
567
				boxWidth.setSelectedItem(o);
568
				initGuiWithTable();
569
			}
570
		});
571
		triPanel.add(boxWidth);
572 717

  
573
		graphSizeBox = new JCheckBox(res.getString("I18N_EQUIVALENCEPANE_GRAPHSIZE_OPTION"));
574
		graphSizeBox.setSelected(withSizes);
575
		graphSizeBox.addItemListener(this);
576
		triPanel.add(graphSizeBox);
577

  
578
		///SHOW EQUIVALENCE BUTTON
579
		ImageIcon displayButt = ImageConfigure.createImageIcon(iconPath+"/Column.gif");
580
		showOccButton = new JButton(displayButt);
581
		showOccButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_SEARCHOCC"));
582
		triPanel.add(showOccButton);
583

  
584
		///SHOW EQUIVALENCE AUTHOR BUTTON
585
		/*ImageIcon displayAuthorButt = ImageConfigure.createImageIcon(iconPath+"/ColumnAuthor.gif");
586
		showOccAuthorButton = new JButton(displayButt);
587
		showOccAuthorButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_SEARCHOCCAUTHOR"));
588
		triPanel.add(showOccAuthorButton);*/
589

  
590
		///SEARCH BUTTON
591
		ImageIcon searchButt = ImageConfigure.createImageIcon(iconPath+"/Search.gif");
592
		searchButton = new JButton(searchButt);
593
		searchButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_DOUBLESEARCH"));
594
		triPanel.add(searchButton);
595

  
596
		///EXPORT BUTTON
597
		ImageIcon exportButt = ImageConfigure.createImageIcon(iconPath+"/Save.gif");
598
		exportButton = new JButton(exportButt);
599
		exportButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_EXPORT"));
600
		triPanel.add(exportButton);
601

  
602
		ImageIcon graphButt = ImageConfigure.createImageIcon(iconPath+"/Graph.gif");
603
		graphButton = new JButton(graphButt);
604
		graphButton.setToolTipText(res.getString("I18N_EQUIVALENCEPANE_GRAPH"));
605
		triPanel.add(graphButton);
606

  
607
		//ACTIONS ---------
608
		showOccButton.addActionListener(new ActionListener(){
609
			public void actionPerformed(ActionEvent e) {
610
				showEquivalences();
718
	private void initConceptPieChart(){	
719
		JPanel panelPieChart = new JPanel();
720
		DefaultPieDataset pieDataset = new DefaultPieDataset(); 
721
		DefaultPieDataset pieDataset2 = new DefaultPieDataset(); 
722
		Vector<ChartPanel> cPanels = new Vector<ChartPanel>();
723
		
724
		if(conceptEquivalenceElements.size()>=1){
725
			ConceptEquivalenceElement conceptEquiEl = conceptEquivalenceElements.get(0);
726
			int sizeConceptSource = conceptEquiEl.getOccurrences().size();
727
			JFreeChart pieChart = ChartFactory.createPieChart(conceptEquiEl.getName()+" - All ("+sizeConceptSource+" occs)", pieDataset, true, true, true); 
728
			ChartPanel cPanel = new ChartPanel(pieChart); 
729
			cPanels.add(cPanel);
730
			if(selectedAuthors != null){//When it is all the texts 		
731
				JFreeChart pieChart2 = ChartFactory.createPieChart(conceptEquiEl.getName()+" - "+selectedAuthors.get(0).getName(), pieDataset2, true, true, true); 	
732
				cPanel = new ChartPanel(pieChart2); 
733
				cPanels.add(cPanel);
611 734
			}
612
		});
613

  
614
		/*showOccAuthorButton.addActionListener(new ActionListener(){
615
			public void actionPerformed(ActionEvent e) {
616
				showEquivalencesByAuthor();
735
			
736
			HashMap<Object, Vector<OccurrenceSet>> occsByConcept = conceptEquiEl.getOccurrences();
737
			Set keys = occsByConcept.keySet();
738
			Iterator itC = keys.iterator();
739
			while(itC.hasNext()){
740
				Object obj = itC.next();
741
				int sizeConceptTarget = occsByConcept.get(obj).size();
742
				System.out.println("EquivalencePane.initConceptPieChart() - sizeConceptTarget = "+sizeConceptTarget);
743
				if(obj instanceof DictionaryElement){
744
					DictionaryElement element = (DictionaryElement) obj;
745
					if(sizeConceptTarget > 0 ){
746
						pieDataset.setValue(element.getName()+" : "+sizeConceptTarget, new Integer(sizeConceptTarget)); 
747
					}
748
				}else {
749
					String element = (String) obj;
750
					if(sizeConceptTarget > 0 ){
751
						pieDataset.setValue(element+" : "+sizeConceptTarget, new Integer(sizeConceptTarget)); 
752
					}
753
				}
617 754
			}
618
		});*/
619

  
620
		searchButton.addActionListener(new ActionListener(){
621
			public void actionPerformed(ActionEvent e) {
622
				searchForEquivalences();
755
			int nbNoEquivalence = 0;
756
			for(HyperalignText textForTarget : textsForTargetLang){
757
				 nbNoEquivalence += tradManager.findMissingEquivalences(sourceElement, textForTarget);
758
				pieDataset.setValue("No Translation : "+nbNoEquivalence, nbNoEquivalence);
623 759
			}
624
		});
625

  
626
		exportButton.addActionListener(new ActionListener(){
627
			public void actionPerformed(ActionEvent e) {
628
				export();
760
			if(selectedAuthors != null){
761
				Set<DictionaryElement> keys2 = equivalencesByAuthor.keySet();
762
				Iterator<DictionaryElement> it = keys2.iterator();
763
				while (it.hasNext()) {
764
					DictionaryElement conceptTarget = it.next();
765
					HashMap<HyperalignText, Integer> nbByAuthor = equivalencesByAuthor.get(conceptTarget);
766
					for(int j = 0 ; j < textsForTargetLang.size(); ++j){
767
						HyperalignText text = textsForTargetLang.get(j);
768
						if(selectedAuthors.get(0) == text){
769
								Integer nb = nbByAuthor.get(text);
770
								pieDataset2.setValue(conceptTarget.getName()+" : "+nb, nb);
771
						}
772
					}
773
				}
774
				nbNoEquivalence = tradManager.findMissingEquivalences(sourceElement, selectedAuthors.get(0));
775
				pieDataset2.setValue("No Translation : "+nbNoEquivalence, nbNoEquivalence);
629 776
			}
630
		});
631

  
632
		/*infoButton.addActionListener(new ActionListener(){
633
			public void actionPerformed(ActionEvent e) {
634
				ResultTableModel tableModel = prepareTableByAuthor();
635
				EquiTextPane textPane = new EquiTextPane(tableModel);
636
				textPane.setLocationRelativeTo(Hyperalign.getInstance());
637
				textPane.setAlwaysOnTop(true);
638
			}
639
		});*/
640

  
641
		graphButton.addActionListener(new ActionListener(){
642
			public void actionPerformed(ActionEvent e) {
643
				showGraphByAuthor();
644
			}
645
		});
646

  
647

  
648
		return triPanel;
777
			
778
			
779
		}
780
		panelPieChart.setLayout(new GridLayout(1,cPanels.size()));
781
		for(ChartPanel cPanel : cPanels){
782
			 panelPieChart.add(cPanel);
783
			 cPanel.setPreferredSize(new Dimension(400,400/cPanels.size()));
784
		}
785
	    scrollPieChart = new JScrollPane(panelPieChart);
786
	    scrollPieChart.setPreferredSize(new Dimension(400,400));	
649 787
	}
650

  
651

  
652
	private void delete(){
653
		//int n2 = JOptionPane.showConfirmDialog(this, "Voulez-vous gardez les annotations même lors de la suppression de l'équivalence", "Information sur les annotations", JOptionPane.YES_NO_OPTION);  
654
		//if(n2==JOptionPane.NO_OPTION){
655
		tradManager.deleteEquivalence(equiEl, false);	
656
		//}
657
		//if(n2==JOptionPane.YES_OPTION){
658
		//	tradManager.deleteEquivalence(equiEl, true);	
659
		//}
660
		manager.reinitHyperalignPane(true, HyperalignData.DATA_EQUIVALENCE, true);
661
	}
662

  
788
	
663 789
	private void export(){
664 790
		JRadioButton exportOccButton = new JRadioButton(res.getString("I18N_EQUIVALENCEPANE_EXPORT_CHOICE_1"));
665 791
		exportOccButton.setActionCommand(EquivalencePane.EXPORT_OCC);
......
668 794
		JRadioButton exportAuthButton = new JRadioButton(res.getString("I18N_EQUIVALENCEPANE_EXPORT_CHOICE_2"));
669 795
		exportAuthButton.setActionCommand(EquivalencePane.EXPORT_AUTHOR);
670 796

  
797
		JRadioButton exportImageButton = new JRadioButton(res.getString("I18N_EQUIVALENCEPANE_EXPORT_CHOICE_3"));
798
		exportImageButton.setActionCommand(EquivalencePane.EXPORT_IMAGE);
799

  
671 800
		//Group the radio buttons.
672 801
		ButtonGroup group = new ButtonGroup();
673 802
		group.add(exportOccButton);
674 803
		group.add(exportAuthButton);
804
		group.add(exportImageButton);
675 805

  
676 806
		//Register a listener for the radio buttons.
677 807
		exportOccButton.addActionListener(this);
678 808
		exportAuthButton.addActionListener(this);
809
		exportImageButton.addActionListener(this);
679 810

  
680 811
		String message = res.getString("I18N_EQUIVALENCEPANE_EXPORT_MESSAGE");  
681
		Object[] params = {message, exportOccButton, exportAuthButton};  
812
		Object[] params = {message, exportOccButton, exportAuthButton, exportImageButton};  
682 813
		int n = JOptionPane.showConfirmDialog(this, params, res.getString("I18N_EQUIVALENCEPANE_EXPORT_TITLE"), JOptionPane.YES_NO_OPTION);  
683

  
684
		if(exportOcc){
685
			exportEquivalences();
686
		}else {
687
			exportEquivalencesByAuthor();
814
		if(n==0) {
815
			if(export.equals(EquivalencePane.EXPORT_AUTHOR)){
816
				exportEquivalencesByAuthor();
817
			}
818
			if(export.equals(EquivalencePane.EXPORT_OCC)){
819
				exportEquivalences();
820
			}
821
			if(export.equals(EquivalencePane.EXPORT_IMAGE)){
822
				exportImage();
823
			}
824
			
688 825
		}
826
		
689 827
	}
690 828

  
691 829
	/*
692 830
	 * Sort equivalence elements by text (author) 
693 831
	 */
832
	
694 833

  
695

  
696 834
	private void showGraphByAuthor(){
697
		Vector <HyperalignText> authors = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
698
		//authorOptionDialog(authors);
699
		authorsSelected = authors;
700
		tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, true, authorsSelected);
701
		manager.reinitHyperalignPane(Hypermachiavel.EQUIGRAPH_TAB, true, true);
835
		//faire une s�lection
836
		if(selectedAuthor==null){
837
			Vector<HyperalignText> textsForTargetLang = tradManager.getDictionaryAndTextForEquivalences().get(targetLang);
838
			JPanel checkPanel = new JPanel(new GridLayout(0, 1));
839
			checkboxForTexts = new HashMap<JCheckBox,HyperalignText>();
840
			selectedAuthors = new Vector<HyperalignText>();
841
	        for(HyperalignText text : textsForTargetLang){
842
				JCheckBox check = new JCheckBox(text.getName());
843
				check.setSelected(true);
844
				check.addItemListener(this);
845
				checkPanel.add(check);
846
				checkboxForTexts.put(check, text);
847
				selectedAuthors.add(text);
848
			}
849
	        
850
	        //JLabel message = new JLabel("message");
851
			Object[] params = {/*message,*/ checkPanel};
852
			int confirm = JOptionPane.showConfirmDialog(this, params, res.getString("I18N_HYPERMACHIAVEL_CONFIRMEDIT_SELECTEDAUTHORS_GRAPH"), JOptionPane.YES_NO_OPTION);  
853
			if (confirm == JOptionPane.YES_OPTION) {
854
				tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, true, selectedAuthors);
855
				manager.reinitHyperalignPane(Hypermachiavel.EQUIGRAPH_TAB, true, true);
856
			}
857
		}else {
858
			tradManager.buildInfoForGraph(sourceElement, targetLang, neighbourhoodWidth, true, selectedAuthors);
859
			manager.reinitHyperalignPane(Hypermachiavel.EQUIGRAPH_TAB, true, true);
860
		}
861
		
702 862
	}
703 863

  
704
	private void authorOptionDialog(Vector <HyperalignText> authors){
705
		JLabel message = new JLabel("Choisir 4 textes parmi la liste");
706
		
707
		Object[] params = new Object[authors.size()+1];
708
		params[0] = message;
709
		int i = 1;
710
		for(HyperalignText t : authors){
711
			JCheckBox checkbox = new JCheckBox(t.getName());
712
			params[i] = checkbox;
713
			++i;
714
		} 
715
		int n = JOptionPane.showConfirmDialog(this, params, "Choisir les textes de l'affichage", JOptionPane.YES_NO_OPTION);  
716
	}
864
	
717 865
	/*private HashMap<DictionaryElement, HashMap<HyperalignText, Integer>> showEquivalencesByAuthor(){
718 866
		HashMap<DictionaryElement, HashMap<HyperalignText, Integer>> equivalencesByAuthor = new HashMap<DictionaryElement, HashMap<HyperalignText,Integer>>();
719 867
		if(conceptEquivalenceElements!=null){
......
735 883
					}else {
736 884
						String element = (String) obj;
737 885
					}
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff