Statistics
| Revision:

root / trunk / extensions / extSymbology / src / org / gvsig / symbology / gui / layerproperties / GeneralLabeling.java @ 20905

History | View | Annotate | Download (18.9 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.symbology.gui.layerproperties;
42

    
43
import java.awt.BorderLayout;
44
import java.awt.Component;
45
import java.awt.Dimension;
46
import java.awt.FlowLayout;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
49
import java.awt.event.MouseAdapter;
50
import java.awt.event.MouseEvent;
51
import java.util.ArrayList;
52
import java.util.Hashtable;
53
import java.util.Iterator;
54
import java.util.TreeSet;
55

    
56
import javax.swing.BorderFactory;
57
import javax.swing.JCheckBox;
58
import javax.swing.JComponent;
59
import javax.swing.JLabel;
60
import javax.swing.JOptionPane;
61
import javax.swing.JPanel;
62
import javax.swing.JScrollPane;
63

    
64
import org.gvsig.gui.beans.controls.dnd.JDnDList;
65
import org.gvsig.gui.beans.controls.dnd.JDnDListModel;
66
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
67
import org.gvsig.gui.beans.swing.JBlank;
68
import org.gvsig.gui.beans.swing.JButton;
69
import org.gvsig.symbology.fmap.labeling.ExtendedLabelingFactory;
70
import org.gvsig.symbology.fmap.labeling.GeneralLabelingStrategy;
71
import org.gvsig.symbology.fmap.labeling.LabelClassComparatorByPriority;
72
import org.gvsig.symbology.gui.styling.LabelClassRenderingProperties;
73

    
74
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
75
import com.iver.andami.PluginServices;
76
import com.iver.andami.messages.NotificationManager;
77
import com.iver.cit.gvsig.fmap.layers.FLayer;
78
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
79
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
80
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingMethod;
81
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy;
82
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints;
83
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IZoomConstraints;
84
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass;
85
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelingFactory;
86
import com.iver.cit.gvsig.project.documents.view.legend.gui.ILabelingStrategyPanel;
87
import com.iver.utiles.swing.JComboBox;
88

    
89
public class GeneralLabeling extends JPanel implements ILabelingStrategyPanel, ActionListener {
90
        private static final long serialVersionUID = 8864709758980903351L;
91
        private static Hashtable<String, Class<? extends ILabelingMethod>> methods 
92
                = new Hashtable<String, Class<? extends ILabelingMethod>>();
93
        private static int newClassSuffix = 0;
94
        private JButton btnVisualization;
95
        private JButton btnRenameClass;
96
        private JButton btnSQLQuery;
97
        private JButton btnDelClass;
98
        private JButton btnAddClass;
99
        private JButton btnPlacement;
100
        private JComboBoxLabelingMethod cmbMethod;
101
        private GridBagLayoutPanel classesPanel;
102
        private JComboBox cmbClasses;
103
        private IPlacementConstraints placementConstraints;
104
        private IZoomConstraints zoomConstraints;
105
        private long minScaleView = -1, maxScaleView = -1;
106
        private boolean noEvent;
107
        private JCheckBox chkLabel;
108
        private JCheckBox chkTextOnly;
109
        private FLyrVect layer;
110
        private String[] fieldNames;
111
        private JDnDList lstClassPriorities;
112
        private JCheckBox chkDefinePriorities;
113
        private JScrollPane scrlPan;
114
        private LabelClassRenderingProperties labelClassRenderingProperties;
115
        private JCheckBox chkAllowLabelOverlapping;
116
        
117
        public GeneralLabeling() {
118
                initialize();
119
        }
120
        
121
        private void initialize() {
122
                setLayout(new BorderLayout());
123
                GridBagLayoutPanel left = new GridBagLayoutPanel();
124
                JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,0));
125
                aux.add(new JLabel(PluginServices.getText(this, "method")+":"));
126
                aux.add(getCmbMethod());
127
                aux.setPreferredSize(new Dimension(605, 40));
128
                left.addComponent(aux);
129

    
130

    
131
                classesPanel = new GridBagLayoutPanel();
132
                aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,0));
133
                aux.add(new JLabel(PluginServices.getText(this, "class")+":"));
134
                aux.add(getCmbClasses());
135
                aux.add(getChkLabelFeatures());
136
                aux.setPreferredSize(new Dimension(602, 40));
137
                classesPanel.addComponent(aux);
138

    
139
                aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
140
                aux.add(getBtnAddClass());
141
                aux.add(getBtnDelClass());
142
                aux.add(getBtnRenameClass());
143
                aux.add(getBtnSQLQuery());
144
                aux.setPreferredSize(new Dimension(602, 30));
145
                classesPanel.addComponent(aux);
146
                classesPanel.setBorder(BorderFactory.createTitledBorder(
147
                                null, PluginServices.getText(this, "classes")));
148
                left.addComponent(classesPanel);
149

    
150

    
151
                left.addComponent(labelClassRenderingProperties = new LabelClassRenderingProperties());
152
                aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
153
                aux.setBorder(BorderFactory.createTitledBorder(
154
                                null, PluginServices.getText(this, "options")));
155
                aux.add(getBtnVisualization());
156
                
157
                aux.add(getBtnPlacement());
158
                aux.add(getChkAllowLabelOverlapping());
159
                aux.setPreferredSize(new Dimension(612, 60));
160
                
161
                left.addComponent(aux);        
162
                
163
                add(left, BorderLayout.CENTER);
164
                
165
                JPanel right = new JPanel(new BorderLayout(15, 15));
166
                aux = new JPanel(new BorderLayout(15, 15));
167
                aux.add(getChkDefinePriorities(), BorderLayout.NORTH);
168
                aux.add(getScrlClassPriorities(), BorderLayout.CENTER);
169
                right.add(new JBlank(10, 10), BorderLayout.NORTH);
170
                right.add(aux, BorderLayout.CENTER);
171
                right.add(new JBlank(10, 10), BorderLayout.SOUTH);
172
                right.add(new JBlank(10, 10), BorderLayout.EAST);
173
                add(right, BorderLayout.EAST);
174
        }
175

    
176
        
177
        private JCheckBox getChkAllowLabelOverlapping() {
178
                if (chkAllowLabelOverlapping == null) {
179
                        chkAllowLabelOverlapping = new JCheckBox(PluginServices.getText(this, "allow_label_overlapping"));
180
                        
181
                }
182

    
183
                return chkAllowLabelOverlapping;
184
        }
185

    
186
        private Component getScrlClassPriorities() {
187
                if (scrlPan == null) {
188
                        scrlPan = new JScrollPane();
189
                        scrlPan.setViewportView(getLstClassPriorities());
190
                        scrlPan.setPreferredSize(new Dimension(180, 300));
191
                }
192
                return scrlPan;
193
        }
194

    
195
        private JCheckBox getChkDefinePriorities() {
196
                if (chkDefinePriorities == null) {
197
                        chkDefinePriorities = new JCheckBox(PluginServices.getText(this, "label_priority"));
198
                        chkDefinePriorities.addActionListener(this);
199
                        chkDefinePriorities.setName("CHK_DEFINE_PRIORITIES");
200
                }
201
                return chkDefinePriorities;
202
        }
203

    
204
        private JDnDList getLstClassPriorities() {
205
                if (lstClassPriorities == null) {
206
                        lstClassPriorities = new JDnDList();
207
                        lstClassPriorities.setName("CLASS_PRIORITY_LIST");
208
                        lstClassPriorities.addMouseListener(new MouseAdapter() {
209
                                @Override
210
                                public void mouseReleased(MouseEvent e) {
211
                                        JDnDListModel m = (JDnDListModel) lstClassPriorities.getModel();
212
                                        for (int i = 0; i < m.getSize(); i++) {
213
                                                ((LabelClass) m.getElementAt(i)).setPriority(i);
214
                                        }
215
                                }
216
                        });
217
                        
218
                }
219
                return lstClassPriorities;
220
        }
221

    
222
        private void refreshControls() {
223
                // classes combo box
224
                refreshClasses();
225
                
226
                // fires an event from the methods combo box
227
                actionPerformed(new ActionEvent(getCmbMethod(), 0, null));
228
        }
229
        
230
        private JButton getBtnVisualization() {
231
                if (btnVisualization == null) {
232
                        btnVisualization = new JButton(
233
                                        PluginServices.getText(this, "visualization")+"...");
234
                        btnVisualization.setName("BTNVISUALIZATION");
235
                        btnVisualization.addActionListener(this);
236
                }
237
                return btnVisualization;
238
        }
239

    
240
        private JButton getBtnPlacement() {
241
                if (btnPlacement == null) {
242
                        btnPlacement = new JButton(
243
                                        PluginServices.getText(this, "placement")+"...");
244
                        btnPlacement.setName("BTNPLACEMENT");
245
                        btnPlacement.addActionListener(this);
246
                }
247
                return btnPlacement;
248
        }
249

    
250
        private JComboBox getCmbMethod() {
251
                if (cmbMethod == null) {
252
                        Iterator<String> it = methods.keySet().iterator();
253
                        ArrayList<MethodItem> aux = new ArrayList<MethodItem>();
254
                        while (it.hasNext()) {
255
                                String name = it.next();
256

    
257
                                Class<? extends ILabelingMethod> methodClass = (Class<? extends ILabelingMethod>) methods.get(name);
258
                                ILabelingMethod method;
259
                                try {
260
                                        method = (ILabelingMethod) methodClass.newInstance();
261
                                        MethodItem newItem = new MethodItem(name, method);
262
                                        aux.add(newItem);
263

    
264
                                } catch (InstantiationException e) {
265
                                        NotificationManager.addError("Trying to instantiate an interface" +
266
                                                        " or abstract class + "+methodClass.getName(), e);
267
                                } catch (IllegalAccessException e) {
268
                                        NotificationManager.addError("IllegalAccessException: does " +
269
                                                        methodClass.getName()        + " class have an anonymous" +
270
                                                        " constructor?", e);
271
                                }
272

    
273
                        }
274
                        cmbMethod = new JComboBoxLabelingMethod(aux.toArray(new MethodItem[0]));
275
                        cmbMethod.setSize(new Dimension(300, 22));
276
                        cmbMethod.setName("CMBMETHOD");
277
                        cmbMethod.addActionListener(this);
278
                }
279
                return cmbMethod;
280
        }
281

    
282
        private JButton getBtnSQLQuery() {
283
                if (btnSQLQuery == null) {
284
                        btnSQLQuery = new JButton(PluginServices.getText(this, "SQL_query"));
285
                        btnSQLQuery.setName("BTNSQLQUERY");
286
                        btnSQLQuery.addActionListener(this);
287
                }
288
                return btnSQLQuery;
289
        }
290

    
291
        private JButton getBtnRenameClass() {
292
                if (btnRenameClass == null) {
293
                        btnRenameClass = new JButton(PluginServices.getText(this, "remane_class"));
294
                        btnRenameClass.setName("BTNRENAMECLASS");
295
                        btnRenameClass.addActionListener(this);
296
                }
297
                return btnRenameClass;
298
        }
299

    
300
        private JButton getBtnDelClass() {
301
                if (btnDelClass == null) {
302
                        btnDelClass = new JButton(PluginServices.getText(this, "delete_class"));
303
                        btnDelClass.setName("BTNDELCLASS");
304
                        btnDelClass.addActionListener(this);
305
                }
306
                return btnDelClass;
307
        }
308

    
309
        private JButton getBtnAddClass() {
310
                if (btnAddClass == null) {
311
                        btnAddClass = new JButton(PluginServices.getText(this, "add_class"));
312
                        btnAddClass.setName("BTNADDCLASS");
313
                        btnAddClass.addActionListener(this);
314
                }
315
                return btnAddClass;
316
        }
317

    
318
        private JCheckBox getChkLabelFeatures() {
319
                if (chkLabel == null) {
320
                        chkLabel = new JCheckBox();
321
                        chkLabel.setText(PluginServices.getText(this, "label_features_in_this_class"));
322
                        chkLabel.setName("CHKLABEL");
323
                        chkLabel.addActionListener(this);
324
                }
325
                return chkLabel;
326
        }
327

    
328
        private JComboBox getCmbClasses() {
329
                if (cmbClasses == null) {
330
                        cmbClasses = new JComboBox();
331
                        cmbClasses.setPreferredSize(new Dimension(150, 20));
332
                        cmbClasses.setName("CMBCLASSES");
333
                        cmbClasses.addActionListener(this);
334
                }
335
                return cmbClasses;
336
        }
337

    
338
        public ILabelingStrategy getLabelingStrategy() {
339
                ILabelingStrategy st = ExtendedLabelingFactory.
340
                                                createStrategy((FLayer) layer,
341
                                                                getMethod(),
342
                                                                getPlacementConstraints(),
343
                                                                getZoomConstraints());
344
                if (st instanceof GeneralLabelingStrategy) {
345
                        GeneralLabelingStrategy gStr = (GeneralLabelingStrategy) st;
346
                        gStr.setAllowOverlapping(getChkAllowLabelOverlapping().isSelected());
347
                        gStr.setMinScaleView(minScaleView);
348
                        gStr.setMaxScaleView(maxScaleView);
349
                }
350
                return st;
351
        }
352

    
353
        public void setModel(FLayer layer, ILabelingStrategy str) {
354
                if (layer instanceof FLyrVect) {
355
                        this.layer = (FLyrVect) layer;
356
                        FLyrVect lv = (FLyrVect) layer;
357
                        try {
358
                                fieldNames = lv.getRecordset().getFieldNames();
359
                                labelClassRenderingProperties.setFieldNames(fieldNames);
360
                                if (str instanceof GeneralLabelingStrategy) {
361
                                        try {
362
                                                GeneralLabelingStrategy gStr = (GeneralLabelingStrategy) LabelingFactory.createStrategyFromXML(str.getXMLEntity(), layer.cloneLayer());
363
                                                setMethod(str.getLabelingMethod());
364
                                                placementConstraints = str.getPlacementConstraints();
365
                                                getChkAllowLabelOverlapping().setSelected(gStr.isAllowingOverlap());
366
                                                minScaleView = gStr.getMinScaleView();
367
                                                maxScaleView = gStr.getMaxScaleView();
368

    
369
                                        } catch (ReadDriverException e) {
370
                                                NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e);
371
                                        } catch (Exception e) {
372
                                                NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e);
373
                                        }
374
                                }
375

    
376
                                refreshControls();
377
                                labelClassRenderingProperties.setModel(getActiveClass());
378
                                
379
                        } catch (ReadDriverException e) {
380
                                NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e);
381
                        }
382
                }
383
        }
384

    
385

    
386
        public static void addLabelingMethod(String name, Class<? extends ILabelingMethod> iLabelingMethodClass) {
387
                methods.put(name, iLabelingMethodClass);
388
        }
389

    
390
        private void setMethod(ILabelingMethod labelingMethod) {
391
                getCmbMethod().setSelectedItem(new MethodItem(null, labelingMethod));
392
        }
393

    
394
        private ILabelingMethod getMethod() {
395
                return ((MethodItem) getCmbMethod().getSelectedItem()).method;
396
        }
397
        
398
        private void refreshClasses() {
399
                // label classes
400
                getCmbClasses().removeAllItems();
401
                LabelClass[] lClasses = getMethod().getLabelClasses();
402
                for (int i = 0; i < lClasses.length; i++) {
403
                        getCmbClasses().addItem(lClasses[i]);
404
                        
405
                }
406

    
407
                labelClassRenderingProperties.setModel(
408
                                (LabelClass) getCmbClasses().getSelectedItem());
409
                // expressions combo box
410
//                refreshCmbExpressions();
411
                
412
                // panel priorities
413
                refreshPnlPriorities();
414
                
415
        }
416

    
417
        private void refreshPnlPriorities() {
418
                TreeSet<LabelClass> ts = new TreeSet<LabelClass>(new LabelClassComparatorByPriority());
419
                
420
                LabelClass[] lClasses = getMethod().getLabelClasses();
421
                for (int i = 0; i < lClasses.length; i++) {
422
                        ts.add(lClasses[i]);
423
                }
424
                
425
                // refresh label priority panel
426
                getChkDefinePriorities().setSelected(getMethod().definesPriorities());
427
                JDnDListModel m = new JDnDListModel();
428
                for (LabelClass labelClass : ts) {
429
                        m.addElement(labelClass);
430
                }
431
                getLstClassPriorities().setModel(m);
432

    
433
        }
434
        
435
        private LabelClass getActiveClass() {
436
                return (LabelClass) getCmbClasses().getSelectedItem();
437
        }
438

    
439
        private IZoomConstraints getZoomConstraints() {
440
                return zoomConstraints;
441
        }
442

    
443
        private IPlacementConstraints getPlacementConstraints() {
444
                return placementConstraints;
445
        }
446

    
447
        public void actionPerformed(ActionEvent e) {
448
                if (noEvent) return;
449
                JComponent c = (JComponent)e.getSource();
450

    
451
                if (c.equals(btnAddClass)) {
452
                        LabelClass newClass = new LabelClass();
453
                        newClass.setName(PluginServices.getText(this, "labeling")+String.valueOf(++newClassSuffix));
454
                        getMethod().addLabelClass(newClass);
455
                        refreshClasses();
456
                        getCmbClasses().setSelectedItem(newClass);
457
                } else if (c.equals(btnDelClass)) {
458
                        LabelClass clazz = getActiveClass();
459
                        getMethod().deleteLabelClass(clazz);
460
                        refreshClasses();
461
                } else if (c.equals(btnRenameClass)) {
462
                        LabelClass clazz = getActiveClass();
463
                        String newName = JOptionPane.showInputDialog(
464
                                        PluginServices.getText(this, "enter_new_name"));
465
                        if (newName != null)
466
                                getMethod().renameLabelClass(clazz, newName);
467
                        refreshClasses();
468
                } else if (c.equals(btnSQLQuery)) {
469
                        LabelClass clazz = getActiveClass();
470
                        String query = clazz.getSQLQuery();
471
                        query = JOptionPane.showInputDialog(null,
472
                                          "select from "+layer.getName()+" where ",
473
                                          "SQL query",
474
                                          JOptionPane.QUESTION_MESSAGE);
475
                        if (!query.equals("")) {
476
                                clazz.setSQLQuery(query);
477
                        }
478
                        
479
                } else  if (c.equals(chkLabel)) {
480
                        LabelClass lc = (LabelClass) getCmbClasses().getSelectedItem();
481
                        if (lc == null)
482
                                lc = getMethod().getDefaultLabelClass();
483
                        lc.setVisible(chkLabel.isSelected());
484
                } else if (c.equals(chkTextOnly)) {
485

    
486
                } else if (c.equals(cmbClasses)) {
487
                        // refresh expressions
488
//                        LabelClass lc = (LabelClass) cmbClasses.getSelectedItem();
489
//                        if (lc != null && lc.getLabelExpression() != null && !getExpressions().contains(lc.getLabelExpression())) {
490
//                                getExpressions().add(0, lc.getLabelExpression());
491
//                        }
492
//                        refreshCmbExpressions();
493
                } else if (c.equals(btnPlacement)) {
494

    
495
                        try {
496
                                IPlacementProperties pp = PlacementProperties.createPlacementProperties(
497
                                                getPlacementConstraints(),
498
                                                ((FLyrVect) layer).getShapeType());
499
                                PluginServices.getMDIManager().addWindow(pp);
500
                                placementConstraints = pp.getPlacementConstraints();
501
                        } catch (ClassCastException ccEx) {
502
                                NotificationManager.addError("Placement constraints not prepared for:"
503
                                                +layer.getClass().getName(),
504
                                                ccEx);
505
                        } catch (ReadDriverException dEx) {
506
                                NotificationManager.addWarning("Should be unreachable code", dEx);
507
                                NotificationManager.addError(PluginServices.getText(this, "usupported_layer_type"), dEx);
508
                        }
509

    
510
                } else if (c.equals(btnVisualization)) {
511
                        LabelScaleRange lsr = new LabelScaleRange(minScaleView, maxScaleView);
512
                        PluginServices.getMDIManager().addWindow(lsr);
513
                        minScaleView = lsr.getMinScale();
514
                        maxScaleView = lsr.getMaxScale();
515
                } else if (c.equals(cmbMethod)) {
516
                        // disable components in class panel
517
                        // multiple class or not enables or disables the class panel
518
                        setComponentEnabled(classesPanel, getMethod().allowsMultipleClass());
519
                        refreshClasses();
520
                        
521
                } else if (c.equals(chkDefinePriorities)) {
522
                        getMethod().setDefinesPriorities(chkDefinePriorities.isSelected());
523
                        refreshPnlPriorities();
524
                } 
525
        }
526

    
527
        private void setComponentEnabled(Component c, boolean b) {
528
                if (c instanceof JComponent) {
529
                        JComponent c1 = (JComponent) c;
530
                        for (int i = 0; i < c1.getComponentCount(); i++) {
531
                                setComponentEnabled(c1.getComponent(i), b);
532
                        }
533
                }
534
                c.setEnabled(b);
535
        }
536

    
537
        public String getLabelingStrategyName() {
538
                return PluginServices.getText(this, "user_defined_labels");
539
        }
540

    
541
        public Class getLabelingStrategyClass() {
542
                return GeneralLabelingStrategy.class;
543
        }
544
        
545
        private class JComboBoxLabelingMethod extends JComboBox {
546
                private static final long serialVersionUID = 5935267402200698145L;
547

    
548
                public JComboBoxLabelingMethod(MethodItem[] items) {
549
                        super(items);
550
                }
551
                
552
                @Override
553
                public void setSelectedItem(Object anObject) {
554
                        if (anObject instanceof MethodItem) {
555
                                MethodItem methodItem = (MethodItem) anObject;
556
                                for (int i = 0; i < getItemCount(); i++) {
557
                                        MethodItem aux = (MethodItem) getItemAt(i);
558
                                        if (aux.equals(methodItem)) {
559
                                                aux.method=methodItem.method;
560
                                        }
561
                                }
562
                                super.setSelectedItem(methodItem);
563
//                                ((MethodItem) super.getSelectedItem()).method = methodItem.method;
564
                        }
565
                }
566
        }
567
        private class MethodItem {
568
                private String name;
569
                private ILabelingMethod method;
570

    
571
                private MethodItem(String name, ILabelingMethod method) {
572
                        this.name = name;
573
                        this.method = method;
574
                }
575

    
576
                public String toString() {
577
                        return name;
578
                }
579
                
580
                @Override
581
                public boolean equals(Object obj) {
582
                        if (obj != null && obj instanceof MethodItem) {
583
                                MethodItem methodItem = (MethodItem) obj;
584
                                return methodItem.method.getClass().equals(this.method.getClass());
585
                        }
586
                        return false;
587
                }
588
        }
589
        
590
}