Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SymbolSelector.java @ 28961

History | View | Annotate | Download (35.8 KB)

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

    
46
import java.awt.BorderLayout;
47
import java.awt.Color;
48
import java.awt.Component;
49
import java.awt.Dimension;
50
import java.awt.FlowLayout;
51
import java.awt.Font;
52
import java.awt.GridLayout;
53
import java.awt.Point;
54
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionListener;
56
import java.awt.event.InputEvent;
57
import java.awt.event.MouseEvent;
58
import java.awt.event.MouseListener;
59
import java.awt.event.MouseMotionListener;
60
import java.io.File;
61

    
62
import javax.swing.BorderFactory;
63
import javax.swing.BoxLayout;
64
import javax.swing.JComponent;
65
import javax.swing.JLabel;
66
import javax.swing.JList;
67
import javax.swing.JPanel;
68
import javax.swing.JScrollPane;
69
import javax.swing.JSplitPane;
70
import javax.swing.JTextField;
71
import javax.swing.JToggleButton;
72
import javax.swing.ListCellRenderer;
73
import javax.swing.event.ListSelectionEvent;
74
import javax.swing.event.ListSelectionListener;
75
import javax.swing.event.TreeSelectionListener;
76
import javax.swing.tree.DefaultMutableTreeNode;
77

    
78
import org.gvsig.fmap.geom.Geometry;
79
import org.gvsig.fmap.geom.GeometryLocator;
80
import org.gvsig.fmap.geom.GeometryManager;
81
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
82
import org.gvsig.fmap.geom.exception.CreateGeometryException;
83
import org.gvsig.fmap.geom.primitive.GeneralPathX;
84
import org.gvsig.fmap.geom.util.UtilFunctions;
85
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
86
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol;
87
import org.gvsig.fmap.mapcontext.rendering.symbols.ILineSymbol;
88
import org.gvsig.fmap.mapcontext.rendering.symbols.IMarkerSymbol;
89
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
90
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
91
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol;
92
import org.gvsig.fmap.mapcontext.rendering.symbols.MultiLayerFillSymbol;
93
import org.gvsig.fmap.mapcontext.rendering.symbols.MultiLayerLineSymbol;
94
import org.gvsig.fmap.mapcontext.rendering.symbols.MultiLayerMarkerSymbol;
95
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
96
import org.gvsig.gui.beans.AcceptCancelPanel;
97
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
98
import org.gvsig.gui.beans.swing.JButton;
99
import org.gvsig.gui.beans.swing.JComboBoxFontSizes;
100
import org.gvsig.gui.beans.swing.JComboBoxFonts;
101
import org.gvsig.gui.beans.swing.JFileChooser;
102
import org.gvsig.gui.beans.swing.JIncrementalNumberField;
103
import org.slf4j.Logger;
104
import org.slf4j.LoggerFactory;
105

    
106
import com.iver.andami.PluginServices;
107
import com.iver.andami.messages.NotificationManager;
108
import com.iver.andami.ui.mdiManager.WindowInfo;
109
import com.iver.cit.gvsig.gui.JComboBoxUnits;
110
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
111
import com.iver.cit.gvsig.project.documents.view.legend.gui.ISymbolSelector;
112
import com.iver.utiles.XMLException;
113

    
114
/**
115
 * Creates the panel where the user has the options to select a symbol.
116
 * Apart from the option to select one, the user will have a previsualization
117
 * of all the symbols stored and posibilities to modify an existing one, to create
118
 * a new symbol and so on.
119
 *
120
 * @author jaume dominguez faus - jaume.dominguez@iver.es
121
 */
122
public class SymbolSelector extends JPanel implements ISymbolSelector, ActionListener {
123
        private static final long serialVersionUID = -6405660392303659551L;
124
        private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
125
        private static final Logger logger = LoggerFactory.getLogger(SymbolSelector.class);
126
        private JPanel jPanel = null;
127
        protected JScrollPane jScrollPane = null;
128
        private JScrollPane jScrollPane1 = null;
129
        private WindowInfo wi;
130
        private JSplitPane jSplitPane = null;
131
        protected AcceptCancelPanel okCancelPanel;
132
        private JPanel northPanel;
133
        private ColorChooserPanel jcc1;
134
        private ColorChooserPanel jcc2;
135
        private JIncrementalNumberField txtSize;
136
        private JIncrementalNumberField txtAngle;
137
        private JPanel jPanelButtons;
138
        private JButton btnProperties;
139
        private int shapeType;
140
        private JButton btnSaveSymbol;
141
        private JButton btnResetSymbol;
142
        private JButton btnNewSymbol;
143
        private JComboBoxFonts cmbFonts;
144
        private JToggleButton btnBold;
145
        private JToggleButton btnItalic;
146
        private JToggleButton btnUnderlined;
147
        protected JLabel lblTitle;
148
        protected File dir;
149
        protected File rootDir;
150
        protected JComponent jPanelPreview = null;
151
        protected GridBagLayoutPanel jPanelOptions = null;
152
        protected JList jListSymbols = null;
153
        protected String treeRootName;
154
        protected ILibraryModel library;
155
        private JIncrementalNumberField txtWidth;
156
        protected boolean act = true;
157
        boolean accepted = true;
158

    
159

    
160
        protected SelectorFilter sFilter = new SelectorFilter() {
161
                private Geometry dummyPointGeom = null;
162
                private Geometry dummyLineGeom = null;
163
                private Geometry dummyPolygonGeom = null;
164
                private boolean isInitialized = false;
165

    
166
                public boolean accepts(Object obj) {
167
                        if (!isInitialized){
168
                                try {
169
                                        dummyPointGeom = geomManager.createPoint(0, 0, SUBTYPES.GEOM2D);
170
                                        dummyLineGeom = geomManager.createSurface(new GeneralPathX(), SUBTYPES.GEOM2D);
171
                                        dummyPolygonGeom = geomManager.createSurface(new GeneralPathX(), SUBTYPES.GEOM2D);
172
                                } catch (CreateGeometryException e) {
173
                                        logger.error("Error creating a geometry", e);
174
                                }
175
                                isInitialized = true;
176
                        }
177

    
178
                        if (obj instanceof ISymbol) {
179
                                ISymbol sym = (ISymbol) obj;
180

    
181
                                Geometry compareGeometry = null;
182
                                switch (SymbolSelector.this.shapeType) {
183
                                case Geometry.TYPES.TEXT:
184
                                        return sym instanceof ITextSymbol;
185
                                case Geometry.TYPES.POINT:
186
                                        compareGeometry = dummyPointGeom;
187
                                        break;
188
                                case Geometry.TYPES.CURVE:
189
                                        compareGeometry = dummyLineGeom;
190
                                        break;
191
                                case Geometry.TYPES.SURFACE:
192
                                        compareGeometry = dummyPolygonGeom;
193
                                        break;
194
                                }
195
                                return sym.isSuitableFor(compareGeometry);
196
                        }
197
                        return false;
198
                }
199
        };
200
        protected JComboBoxUnits cmbUnits;
201
        protected JComboBoxUnitsReferenceSystem cmbReferenceSystem;
202
        private JComboBoxFontSizes cmbFontSize;
203
        protected LibraryBrowser libraryBrowser;
204
        /**
205
         * Constructor method
206
         *
207
         * @param currentElement
208
         * @param shapeType
209
         */
210
        private SymbolSelector(Object currentElement, int shapeType, boolean initialize) {
211
                super();
212

    
213
                // TODO  09/08/07 check the currentElement type is suitable for the shapeType specified
214
                if (currentElement != null && currentElement instanceof ISymbol) {
215
                        ISymbol sym = (ISymbol) currentElement;
216
                        try {
217
                                currentElement = SymbologyFactory.createSymbolFromXML(
218
                                                sym.getXMLEntity(), "");
219
                        } catch (XMLException e) {
220
                                NotificationManager.addWarning("Symbol layer", e);
221
                        }
222
                        String desc = sym.getDescription();
223
                        //                    desc += " ("+PluginServices.getText(this, "current")+")";
224
                        //                    ((ISymbol)currentElement).setDescription(desc);
225
                }
226

    
227
                //             for symbols MULTIPOINT is the same than POINT
228
                if (shapeType == Geometry.TYPES.MULTIPOINT) {
229
                        shapeType = Geometry.TYPES.POINT;
230
                }
231

    
232
                this.shapeType = shapeType;
233
                //            Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
234
                rootDir = new File(SymbologyFactory.SymbolLibraryPath);
235
                //                                prefs.get("SymbolLibraryFolder", System.getProperty("user.home")+"/gvSIG/Symbols"));
236
                if (!rootDir.exists()) {
237
                        rootDir.mkdir();
238
                }
239
                treeRootName = PluginServices.getText(this, "symbol_library");
240
                try {
241
                        if (initialize) {
242
                                initialize(currentElement);
243
                        }
244
                } catch (ClassNotFoundException e) {
245
                        throw new Error(e);
246
                }
247

    
248

    
249
        }
250

    
251
        /**
252
         * Constructor method, it is <b>protected</b> by convenience to let StyleSelector
253
         * to invoke it, but rigorously it should be <b>private</b>.
254
         *
255
         * @param symbol
256
         * @param shapeType
257
         * @param filter
258
         */
259
        protected SymbolSelector(Object symbol, int shapeType, SelectorFilter filter, boolean initialize) {
260
                this(symbol, shapeType, initialize);
261
                sFilter = filter;
262
        }
263

    
264
        /**
265
         * This method initializes this
266
         * @param currentElement
267
         * @throws ClassNotFoundException
268
         *
269
         */
270
        protected void initialize(Object currentElement) throws ClassNotFoundException {
271
                library = new SymbolLibrary(rootDir);
272

    
273
                this.setLayout(new BorderLayout());
274
                this.setSize(400, 221);
275

    
276
                this.add(getJNorthPanel(), BorderLayout.NORTH);
277
                this.add(getJSplitPane(), BorderLayout.CENTER);
278
                this.add(getJEastPanel(), BorderLayout.EAST);
279
                ActionListener okAction = new ActionListener() {
280
                        public void actionPerformed(ActionEvent e) {
281
                                PluginServices.getMDIManager().closeWindow(SymbolSelector.this);
282
                        }
283
                }, cancelAction = new ActionListener() {
284
                        public void actionPerformed(ActionEvent e) {
285
                                accepted = false;
286

    
287
                                setSymbol(null);
288
                                PluginServices.getMDIManager().closeWindow(SymbolSelector.this);
289
                        }
290
                };
291

    
292
                okCancelPanel = new AcceptCancelPanel();
293
                okCancelPanel.setOkButtonActionListener(okAction);
294
                okCancelPanel.setCancelButtonActionListener(cancelAction);
295

    
296
                this.add(okCancelPanel, BorderLayout.SOUTH);
297
                libraryBrowser.setSelectionRow(0);
298

    
299
                SillyDragNDropAction dndAction = new SillyDragNDropAction();
300
                libraryBrowser.addMouseListener(dndAction);
301
                libraryBrowser.addMouseMotionListener(dndAction);
302
                getJListSymbols().addMouseListener(dndAction);
303
                getJListSymbols().addMouseMotionListener(dndAction);
304
                setSymbol(currentElement);
305
        }
306

    
307
        /**
308
         * Creates a new symbol selector list model in order to allow the user
309
         * to select an existing symbol previously created.
310
         *
311
         * @return listModel SymbolSelectorListModel
312
         */
313
        protected SymbolSelectorListModel newListModel() {
314
                SymbolSelectorListModel listModel = new SymbolSelectorListModel(
315
                                dir,
316
                                sFilter,
317
                                SymbolLibrary.SYMBOL_FILE_EXTENSION);
318
                return listModel;
319
        }
320
        /**
321
         * Initializes tha JNorthPanel.
322
         *
323
         * @return northPanel JPanel
324
         * @throws IllegalArgumentException
325
         */
326
        protected JPanel getJNorthPanel() throws IllegalArgumentException {
327
                if (northPanel == null) {
328
                        String text = "";
329
                        switch (shapeType) {
330
                        case Geometry.TYPES.POINT:
331
                                text = PluginServices.getText(this, "point_symbols");
332
                                break;
333
                        case Geometry.TYPES.CURVE:
334
                                text = PluginServices.getText(this, "line_symbols");
335
                                break;
336
                        case Geometry.TYPES.SURFACE:
337
                                text = PluginServices.getText(this, "polygon_symbols");
338
                                break;
339
                        case Geometry.TYPES.TEXT:
340
                                text = PluginServices.getText(this, "text_symbols");
341
                                break;
342
                        default:
343
                                throw new IllegalArgumentException(PluginServices.getText(this, "shape_type_not_yet_supported"));
344
                        }
345
                        northPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
346
                        lblTitle = new JLabel(text);
347
                        lblTitle.setFont(lblTitle.getFont().deriveFont(Font.BOLD));
348
                        northPanel.add(lblTitle);
349
                }
350
                return northPanel;
351
        }
352

    
353
        /**
354
         * This method initializes jList
355
         *
356
         * @return javax.swing.JList
357
         */
358
        protected JList getJListSymbols() {
359
                if (jListSymbols == null) {
360
                        jListSymbols = new JList() ;
361
                        jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
362
                        jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP);
363
                        jListSymbols.setVisibleRowCount(-1);
364
                        jListSymbols.addListSelectionListener(new ListSelectionListener() {
365
                                public void valueChanged(ListSelectionEvent e) {
366
                                        if (jListSymbols.getSelectedValue()!=null) {
367
                                                ISymbol selSym=null;
368
                                                try {
369
                                                        selSym = SymbologyFactory.createSymbolFromXML(
370
                                                                        ((ISymbol) jListSymbols.getSelectedValue()).getXMLEntity(), null);
371
                                                } catch (XMLException e1) {
372
                                                        NotificationManager.addWarning("Symbol layer", e1);
373
                                                }
374
                                                setSymbol(selSym);
375
                                                updateOptionsPanel();
376
                                        }
377
                                }
378
                        });
379
                        ListCellRenderer renderer = new ListCellRenderer() {
380
                                private Color mySelectedBGColor = new Color(255,145,100,255);
381
                                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
382
                                        ISymbol sym = (ISymbol) value;
383
                                        JPanel pnl = new JPanel();
384
                                        BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS);
385
                                        pnl.setLayout(layout);
386
                                        Color bgColor = (isSelected) ? mySelectedBGColor
387
                                                        : getJListSymbols().getBackground();
388

    
389
                                        pnl.setBackground(bgColor);
390
                                        SymbolPreviewer sp = new SymbolPreviewer();
391
                                        sp.setAlignmentX(Component.CENTER_ALIGNMENT);
392
                                        sp.setPreferredSize(new Dimension(50, 50));
393
                                        sp.setSymbol(sym);
394
                                        sp.setBackground(bgColor);
395
                                        pnl.add(sp);
396
                                        String desc = sym.getDescription();
397
                                        if (desc == null) {
398
                                                desc = "["+PluginServices.getText(this, "no_desc")+"]";
399
                                        }
400
                                        JLabel lbl = new JLabel(desc);
401
                                        lbl.setBackground(bgColor);
402
                                        lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
403
                                        pnl.add(lbl);
404

    
405
                                        return pnl;
406
                                }
407

    
408
                        };
409
                        jListSymbols.setCellRenderer(renderer);
410
                }
411
                return jListSymbols;
412
        }
413
        /**
414
         * Updates the options panel depending on the type of symbol that the user
415
         * is controlling or using to show specific options for each one.
416
         *
417
         */
418
        protected void updateOptionsPanel() throws IllegalArgumentException {
419
                Object mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();
420

    
421
//                if (mySelectedElement == null) {
422
//                        return;
423
//                }
424
                act = false; // disable events
425

    
426
                if (mySelectedElement instanceof CartographicSupport) {
427
                        CartographicSupport cs = (CartographicSupport) mySelectedElement;
428
                        cmbUnits.setSelectedUnitIndex(cs.getUnit());
429
                        cmbReferenceSystem.setSelectedIndex(cs.getReferenceSystem());
430
                }
431

    
432
                if (mySelectedElement instanceof IMultiLayerSymbol){
433
                        if (((IMultiLayerSymbol)mySelectedElement).getLayerCount() == 1) {
434
                                mySelectedElement = ((IMultiLayerSymbol)mySelectedElement).getLayer(0);
435
                        }
436
                }
437

    
438
                try {
439

    
440
                        jcc1.setEnabled(mySelectedElement!=null);
441
                        jcc2.setEnabled(mySelectedElement!=null);
442

    
443
                        if(mySelectedElement instanceof IMultiLayerSymbol){
444
                                jcc1.setColor(Color.WHITE);
445
                                jcc2.setColor(Color.WHITE);
446
                                jcc1.setEnabled(false);
447
                                jcc2.setEnabled(false);
448
                        }
449

    
450
                        if (shapeType == Geometry.TYPES.POINT) {
451
                                IMarkerSymbol m = (IMarkerSymbol) mySelectedElement;
452
                                txtSize.setEnabled(m!=null);
453
                                txtAngle.setEnabled(m!=null);
454
                                if(m!=null){
455
                                        jcc1.setColor(m.getColor());
456
                                        txtSize.setDouble(m.getSize());
457
                                        txtAngle.setDouble(Math.toDegrees(m.getRotation()));
458
                                }
459
                        }
460

    
461
                        if (shapeType == Geometry.TYPES.CURVE) {
462
                                ILineSymbol l = (ILineSymbol) mySelectedElement;
463
                                txtSize.setEnabled(l!=null);
464
                                if(l!=null){
465
                                        jcc1.setColor(l.getColor());
466
                                        jcc1.setAlpha(l.getAlpha());
467
                                        txtSize.setDouble(l.getLineWidth());
468
                                }
469
                        }
470

    
471
                        if (shapeType == Geometry.TYPES.SURFACE) {
472
                                IFillSymbol f = (IFillSymbol) mySelectedElement;
473

    
474
                                txtWidth.setEnabled(f!=null);
475
                                cmbReferenceSystem.setEnabled(f!=null);
476
                                cmbUnits.setEnabled(f!=null);
477

    
478
                                if (f!=null){
479
                                        jcc1.setUseColorIsSelected(f.hasFill());
480
                                        jcc1.setColor(f.getFillColor());
481
                                        jcc1.setAlpha(f.getFillAlpha());
482
                                        jcc2.setUseColorIsSelected(f.hasOutline());
483
                                        ILineSymbol outline = f.getOutline();
484
                                        if (outline != null) {
485
                                                jcc2.setColor(outline.getColor());
486
                                                txtWidth.setDouble(outline.getLineWidth());
487
                                        }
488

    
489
                                        if(f instanceof MultiLayerFillSymbol){
490
                                                txtWidth.setEnabled(false);
491
                                                cmbReferenceSystem.setEnabled(false);
492
                                                cmbUnits.setEnabled(false);
493
                                        }
494
                                }
495
                        }
496

    
497

    
498
                        if (shapeType == Geometry.TYPES.TEXT) {
499
                                ITextSymbol t = (ITextSymbol) mySelectedElement;
500
                                cmbFontSize.setEnabled(t!=null);
501
                                if(t!=null){
502
                                        jcc1.setColor(t.getTextColor());
503
                                        Double s = new Double(t.getFont().getSize());
504
                                        cmbFontSize.setSelectedItem(s);
505
                                        int i = cmbFontSize.getSelectedIndex();
506
                                        if (i == -1) {
507
                                                cmbFontSize.addItem(s);
508
                                                cmbFontSize.setSelectedItem(s);
509
                                        }
510
                                }
511
                        }
512
                } catch (NullPointerException npEx) {
513
                        throw new IllegalArgumentException(npEx);
514
                } catch (ClassCastException ccEx) {
515
                        throw new IllegalArgumentException(ccEx);
516
                }
517

    
518
                act = true;  // enable events
519
        }
520

    
521
        /**
522
         * This method initializes jPanel
523
         *
524
         * @return javax.swing.JPanel
525
         */
526
        protected JPanel getJEastPanel() {
527
                if (jPanel == null) {
528
                        jPanel = new JPanel();
529
                        jPanel.setLayout(new BorderLayout());
530
                        jPanel.add(getJPanelOptions(), BorderLayout.CENTER);
531
                        JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
532
                        aux.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "preview")));
533
                        aux.add(getJPanelPreview());
534
                        jPanel.add(aux, BorderLayout.NORTH);
535

    
536
                        jPanel.add(getJPanelOptions());
537
                        aux = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
538
                        aux.add(getJPanelButtons());
539
                        jPanel.add(aux, BorderLayout.SOUTH);
540
                }
541
                return jPanel;
542
        }
543

    
544
        private JPanel getJPanelButtons() {
545
                if (jPanelButtons == null) {
546
                        jPanelButtons = new JPanel();
547
                        GridLayout layout = new GridLayout();
548
                        layout.setColumns(1);
549
                        layout.setVgap(5);
550
                        jPanelButtons.add(getBtnNewSymbol());
551
                        jPanelButtons.add(getBtnSaveSymbol());
552
                        jPanelButtons.add(getBtnResetSymbol());
553
                        jPanelButtons.add(getBtnProperties());
554

    
555
                        // do not add components bellow this line!
556
                        layout.setRows(jPanelButtons.getComponentCount());
557
                        jPanelButtons.setLayout(layout);
558
                }
559
                return jPanelButtons;
560
        }
561

    
562
        private JButton getBtnNewSymbol() {
563
                if (btnNewSymbol == null) {
564
                        btnNewSymbol = new JButton();
565
                        btnNewSymbol.setName("btnNewSymbol");
566
                        btnNewSymbol.setText(PluginServices.getText(this, "new"));
567
                        btnNewSymbol.addActionListener(this);
568
                }
569
                return btnNewSymbol;
570
        }
571

    
572
        private JButton getBtnResetSymbol() {
573
                if (btnResetSymbol == null) {
574
                        btnResetSymbol = new JButton();
575
                        btnResetSymbol.setName("btnResetSymbol");
576
                        btnResetSymbol.setText(PluginServices.getText(this, "reset"));
577
                        btnResetSymbol.addActionListener(this);
578
                }
579
                return btnResetSymbol;
580
        }
581

    
582
        private JButton getBtnSaveSymbol() {
583
                if (btnSaveSymbol == null) {
584
                        btnSaveSymbol = new JButton();
585
                        btnSaveSymbol.setName("btnSaveSymbol");
586
                        btnSaveSymbol.setText(PluginServices.getText(this, "save"));
587
                        btnSaveSymbol.addActionListener(this);
588
                }
589
                return btnSaveSymbol;
590
        }
591

    
592
        private JButton getBtnProperties() {
593
                if (btnProperties == null) {
594
                        btnProperties = new JButton();
595
                        btnProperties.setName("btnProperties");
596
                        btnProperties.setText(PluginServices.getText(this, "properties"));
597
                        btnProperties.addActionListener(this);
598
                }
599
                return btnProperties;
600
        }
601

    
602
        /**
603
         * This method initializes jScrollPane
604
         *
605
         * @return javax.swing.JScrollPane
606
         * @throws ClassNotFoundException
607
         */
608
        protected JScrollPane getLeftJScrollPane() throws ClassNotFoundException {
609
                if (jScrollPane == null) {
610
                        jScrollPane = new JScrollPane();
611
                        jScrollPane.setPreferredSize(new java.awt.Dimension(80,130));
612
                        jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
613
                        libraryBrowser = new LibraryBrowser(library);
614
                        libraryBrowser.addTreeSelectionListener(new TreeSelectionListener() {
615
                                public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
616
                                        dir = (File) ((DefaultMutableTreeNode)
617
                                                        libraryBrowser.getLastSelectedPathComponent()).getUserObject();
618

    
619
                                        if (dir == null) {
620
                                                return;
621
                                        }
622

    
623
                                        jListSymbols.setModel(newListModel());
624
                                        //                                        jListSymbols.setSelectedValue(selectedElement, true);
625
                                }
626
                        });
627
                        jScrollPane.setViewportView(libraryBrowser);
628
                }
629
                return jScrollPane;
630
        }
631

    
632
        /**
633
         * This method initializes jScrollPane1
634
         *
635
         * @return javax.swing.JScrollPane
636
         */
637
        private JScrollPane getJScrollPane1() {
638
                if (jScrollPane1 == null) {
639
                        jScrollPane1 = new JScrollPane();
640
                        jScrollPane1.setViewportView(getJListSymbols());
641
                }
642
                return jScrollPane1;
643
        }
644

    
645
        /**
646
         * This method initializes jPanelPreview
647
         *
648
         * @return javax.swing.JComponent
649
         */
650
        protected JComponent getJPanelPreview() {
651
                if (jPanelPreview == null) {
652
                        jPanelPreview = new SymbolPreviewer();
653
                        jPanelPreview.setPreferredSize(new java.awt.Dimension(100,100));
654
                        jPanelPreview.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
655
                }
656
                return jPanelPreview;
657
        }
658
        /**
659
         * This method initializes jPanelOptions
660
         *
661
         * @return javax.swing.JPanel
662
         */
663
        protected JPanel getJPanelOptions() {
664
                if (jPanelOptions == null) {
665
                        jPanelOptions = new GridBagLayoutPanel();
666
                        jPanelOptions.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "options")));
667
                        jcc2 = new ColorChooserPanel(true,true);
668
                        jcc2.setAlpha(255);
669
                        if (shapeType == Geometry.TYPES.POINT) {
670
                                jcc1 = new ColorChooserPanel(true);
671

    
672
                                jPanelOptions.addComponent(
673
                                                PluginServices.getText(this, "color")+":", jcc1);
674
                                jPanelOptions.addComponent(
675
                                                PluginServices.getText(this, "size")+":",
676
                                                txtSize = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1));
677
                                jPanelOptions.addComponent(PluginServices.getText(this, "units")+":",
678
                                                cmbUnits = new JComboBoxUnits());
679
                                jPanelOptions.addComponent("",
680
                                                cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
681
                                jPanelOptions.addComponent(
682
                                                PluginServices.getText(this, "angle")+ " (" +PluginServices.getText(this, "degree")+"):",
683
                                                txtAngle = new JIncrementalNumberField());
684

    
685

    
686
                        } else if (shapeType == Geometry.TYPES.CURVE) {
687
                                jcc1 = new ColorChooserPanel(true);
688
                                jPanelOptions.addComponent(
689
                                                PluginServices.getText(this, "color")+":", jcc1);
690
                                jPanelOptions.addComponent(
691
                                                PluginServices.getText(this, "width")+":",
692
                                                txtSize = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1));
693
                                jPanelOptions.addComponent(PluginServices.getText(this, "units")+":",
694
                                                cmbUnits = new JComboBoxUnits());
695
                                jPanelOptions.addComponent("",
696
                                                cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
697

    
698
                        } else if (shapeType == Geometry.TYPES.SURFACE) {
699
                                jcc1 = new ColorChooserPanel(true, true);
700
                                jPanelOptions.addComponent(
701
                                                PluginServices.getText(this, "fill_color")+":", jcc1);
702
                                jPanelOptions.addComponent(
703
                                                PluginServices.getText(this, "outline_color")+":", jcc2);
704
                                jPanelOptions.addComponent(
705
                                                PluginServices.getText(this, "outline_width"),
706
                                                txtWidth = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1));
707
                                jPanelOptions.addComponent(PluginServices.getText(this, "units")+":",
708
                                                cmbUnits = new JComboBoxUnits());
709
                                jPanelOptions.addComponent("",
710
                                                cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
711

    
712
                        } else if (shapeType == Geometry.TYPES.TEXT) {
713
                                jcc1 = new ColorChooserPanel(true);
714
                                jPanelOptions.addComponent(
715
                                                PluginServices.getText(this, "font")+":", getCmbFonts());
716

    
717
                                jPanelOptions.addComponent(
718
                                                PluginServices.getText(this, "color")+":", jcc1);
719
                                jPanelOptions.addComponent(PluginServices.getText(this, "size")+":",
720
                                                cmbFontSize = new JComboBoxFontSizes());
721
                                jPanelOptions.addComponent(PluginServices.getText(this, "units")+":",
722
                                                cmbUnits = new JComboBoxUnits());
723
                                jPanelOptions.addComponent("",
724
                                                cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
725

    
726
                                JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING,0,1));
727
                                aux.add(getBtnBold());
728
                                aux.add(getBtnItalic());
729
                                aux.add(getBtnUnderlined());
730
                                jPanelOptions.addComponent(
731
                                                PluginServices.getText(this, "style")+":", aux);
732

    
733
                        }
734

    
735
                        jcc1.setAlpha(255);
736

    
737
                        if (txtSize != null) {
738
                                txtSize.addActionListener(this);
739
                        }
740
                        if (cmbUnits != null) {
741
                                cmbUnits.addActionListener(this);
742
                        }
743
                        if (cmbReferenceSystem != null) {
744
                                cmbReferenceSystem.addActionListener(this);
745
                        }
746
                        if (jcc1 != null) {
747
                                jcc1.addActionListener(this);
748
                        }
749
                        if (jcc2 != null) {
750
                                jcc2.addActionListener(this);
751
                        }
752
                        if (txtWidth != null) {
753
                                txtWidth.addActionListener(this);
754
                        }
755
                        if (cmbFontSize != null) {
756
                                cmbFontSize.addActionListener(this);
757
                        }
758
                        if (txtAngle != null) {
759
                                txtAngle.addActionListener(this);
760
                        }
761
                }
762
                return jPanelOptions;
763
        }
764

    
765
        private JToggleButton getBtnUnderlined() {
766
                if (btnUnderlined == null) {
767
                        btnUnderlined = new JToggleButton(PluginServices.getIconTheme().
768
                                        get("underline-icon"));
769
                }
770
                return btnUnderlined;
771
        }
772

    
773
        private JToggleButton getBtnItalic() {
774
                if (btnItalic == null) {
775
                        btnItalic = new JToggleButton(PluginServices.getIconTheme().
776
                                        get("italic-icon"));
777
                }
778
                return btnItalic;
779
        }
780

    
781
        private JToggleButton getBtnBold() {
782
                if (btnBold == null) {
783
                        btnBold = new JToggleButton(PluginServices.getIconTheme().
784
                                        get("bold-icon"));
785
                }
786
                return btnBold;
787
        }
788

    
789

    
790
        private JComboBoxFonts getCmbFonts() {
791
                if (cmbFonts == null) {
792
                        cmbFonts = new JComboBoxFonts();
793
                }
794
                return cmbFonts;
795
        }
796

    
797
        public WindowInfo getWindowInfo() {
798
                if (wi == null) {
799
                        wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
800
                        wi.setWidth(706);
801
                        wi.setHeight(500);
802
                        wi.setTitle(PluginServices.getText(this, "symbol_selector"));
803
                }
804
                return wi;
805
        }
806

    
807
        protected JSplitPane getJSplitPane() throws ClassNotFoundException {
808
                if (jSplitPane == null) {
809
                        jSplitPane = new JSplitPane();
810
                        jSplitPane.setDividerLocation(200);
811
                        jSplitPane.setResizeWeight(0.4);
812
                        jSplitPane.setLeftComponent(getLeftJScrollPane());
813
                        jSplitPane.setRightComponent(getJScrollPane1());
814
                }
815
                return jSplitPane;
816
        }
817

    
818
        public Object getSelectedObject() {
819
                if (!accepted) {
820
                        return null;
821
                }
822
                Object mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();
823

    
824
                // if this symbol only has one layer, then no multilayer is needed
825
                if (mySelectedElement instanceof IMultiLayerSymbol) {
826
                        if (((IMultiLayerSymbol) mySelectedElement).getLayerCount()==1) {
827
                                return ((IMultiLayerSymbol) mySelectedElement).getLayer(0);
828
                        }
829
                }
830

    
831
                if (mySelectedElement instanceof CartographicSupport) {
832
                        CartographicSupport csSym = (CartographicSupport) mySelectedElement;
833
                        csSym.setUnit(cmbUnits.getSelectedUnitIndex());
834
                        csSym.setReferenceSystem(cmbReferenceSystem.getSelectedIndex());
835
                }
836

    
837
                return mySelectedElement;
838
        }
839

    
840
        public void setSymbol(Object symbol) {
841
                ((SymbolPreviewer) jPanelPreview).setSymbol((ISymbol) symbol);
842
                updateOptionsPanel();
843
        }
844

    
845
        /**
846
         * Invoked when the PROPERTIES button is pressed
847
         */
848
        protected void propertiesPressed() {
849
                ISymbol mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();
850
                if (mySelectedElement ==null) {
851
                        return;
852
                }
853

    
854
                ISymbol clonedSymbol=null;
855
                try {
856
                        clonedSymbol = SymbologyFactory.createSymbolFromXML(
857
                                        mySelectedElement.getXMLEntity(), null);
858
                } catch (XMLException e) {
859
                        NotificationManager.addWarning("Symbol layer", e);
860
                }
861
                SymbolEditor se = new SymbolEditor(clonedSymbol, shapeType);
862
                PluginServices.getMDIManager().addWindow(se);
863

    
864
                ISymbol symbol = se.getSymbol();
865
                if (symbol instanceof IMultiLayerSymbol) {
866
                        IMultiLayerSymbol mSym = (IMultiLayerSymbol) symbol;
867
                        if (mSym.getLayerCount() == 1) {
868
                                symbol =  mSym.getLayer(0);
869
                        }
870
                }
871
                setSymbol(symbol);
872

    
873
        }
874

    
875
        /**
876
         * Invoked when the NEW button is pressed
877
         */
878
        protected void newPressed() {
879
                SymbolEditor se = new SymbolEditor(null, shapeType);
880
                PluginServices.getMDIManager().addWindow(se);
881
                setSymbol(se.getSymbol());
882
        }
883

    
884
        /**
885
         * Invoked when the RESET button is pressed
886
         */
887
        protected void resetPressed() {
888
                setSymbol(null);
889
        }
890

    
891
        /**
892
         * Invoked when the SAVE button is pressed
893
         */
894
        protected void savePressed() {
895
                if (getSelectedObject() ==null) {
896
                        return;
897
                }
898

    
899

    
900
                JFileChooser jfc = new JFileChooser("SYMBOL_SELECTOR_FILECHOOSER", rootDir);
901
                javax.swing.filechooser.FileFilter ff = new javax.swing.filechooser.FileFilter() {
902
                        public boolean accept(File f) {
903
                                return f.getAbsolutePath().
904
                                toLowerCase().
905
                                endsWith(SymbolLibrary.SYMBOL_FILE_EXTENSION) || f.isDirectory();
906
                        }
907

    
908
                        public String getDescription() {
909
                                return PluginServices.getText(
910
                                                this, "gvSIG_symbol_definition_file")+ " (*.sym)";
911
                        }
912
                };
913
                jfc.setFileFilter(ff);
914
                JPanel accessory = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
915
                accessory.add(new JLabel(PluginServices.getText(this, "enter_description")));
916
                JTextField txtDesc = new JTextField(25);
917
                accessory.add(txtDesc);
918
                jfc.setAccessory(accessory);
919
                if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
920
                        File targetFile = jfc.getSelectedFile();
921

    
922
                        // apply description
923
                        String desc;
924
                        if (txtDesc.getText()==null || txtDesc.getText().trim().equals("")) {
925
                                // default to file name
926
                                String s = targetFile.getAbsolutePath();
927
                                desc = s.substring(s.lastIndexOf(File.separator)+1).
928
                                replaceAll(SymbolLibrary.SYMBOL_FILE_EXTENSION, "");
929
                        } else {
930
                                desc = txtDesc.getText().trim();
931
                        }
932
                        ISymbol s = (ISymbol) getSelectedObject();
933
                        s.setDescription(desc);
934

    
935

    
936
                        String symbolFileName = targetFile.getAbsolutePath().substring(
937
                                        targetFile.getAbsolutePath().lastIndexOf(File.separator)+1,
938
                                        targetFile.getAbsolutePath().length());
939
                        File targetDir = new File(targetFile.getAbsolutePath().substring(
940
                                        0,
941
                                        targetFile.getAbsolutePath().lastIndexOf(File.separator)));
942
                        library.addElement(s, symbolFileName , targetDir);
943
                        getJListSymbols().setModel(newListModel());
944
                }
945
        }
946

    
947

    
948
        public void actionPerformed(ActionEvent e) {
949
                if (!act) {
950
                        return;
951
                }
952
                Object selectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();//getSelectedObject();
953
                performActionOn(selectedElement, e);
954
                SymbolSelector.this.repaint();
955
        }
956

    
957
        protected void performActionOn(Object selectedElement, ActionEvent e) {
958
                JComponent comp = (JComponent) e.getSource();
959

    
960
                if ( comp.equals(getBtnProperties()) ) {
961
                        // properties pressed
962
                        propertiesPressed();
963
                } else if ( comp.equals(getBtnNewSymbol()) ) {
964
                        // new pressed
965
                        newPressed();
966
                } else if ( comp.equals(getBtnResetSymbol()) ) {
967
                        // reset pressed
968
                        resetPressed();
969
                } else if ( comp.equals(getBtnSaveSymbol()) ) {
970
                        // save pressed
971
                        savePressed();
972
                } else if (comp.equals(jcc1)) {
973
                        if (selectedElement == null) {
974
                                return;
975
                        }
976

    
977
                        Color c = jcc1.getColor();
978

    
979
                        if (selectedElement instanceof IMarkerSymbol) {
980
                                IMarkerSymbol m = (IMarkerSymbol) selectedElement;
981
                                if (m instanceof MultiLayerMarkerSymbol) {
982
                                        MultiLayerMarkerSymbol mm = (MultiLayerMarkerSymbol) m;
983
                                        mm.setAlpha(jcc1.getAlpha());
984
                                } else {
985
                                        m.setColor(c);
986
                                }
987
                        }
988

    
989
                        if (selectedElement instanceof ILineSymbol) {
990
                                ILineSymbol l = (ILineSymbol) selectedElement;
991
                                if (l instanceof MultiLayerLineSymbol) {
992
                                        MultiLayerLineSymbol ml = (MultiLayerLineSymbol) l;
993
                                        ml.setAlpha(jcc1.getAlpha());
994
                                } else {
995
                                        l.setLineColor(c);
996
                                }
997
                        }
998

    
999
                        if (selectedElement instanceof IFillSymbol) {
1000
                                IFillSymbol f = (IFillSymbol) selectedElement;
1001

    
1002
                                f.setHasFill(jcc1.getUseColorisSelected());
1003
                                f.setFillColor(c);
1004
                        }
1005

    
1006
                        if (selectedElement instanceof ITextSymbol) {
1007
                                ITextSymbol t = (ITextSymbol) selectedElement;
1008
                                t.setTextColor(c);
1009
                        }
1010

    
1011
                } else if (comp.equals(jcc2)) {
1012
                        if (selectedElement == null) {
1013
                                return;
1014
                        }
1015
                        Color c = jcc2.getColor();
1016

    
1017

    
1018
                        if (selectedElement instanceof IFillSymbol) {
1019
                                IFillSymbol f = (IFillSymbol) selectedElement;
1020
                                ILineSymbol outline = f.getOutline();
1021
                                f.setHasOutline(jcc2.getUseColorisSelected());
1022

    
1023
                                if (outline!=null) {
1024
                                        ILineSymbol l = outline;
1025
                                        if (l instanceof MultiLayerLineSymbol && c != null) {
1026
                                                MultiLayerLineSymbol ml = (MultiLayerLineSymbol) l;
1027
                                                ml.setAlpha(c.getAlpha());
1028
                                        } else {
1029
                                                l.setLineColor(c);
1030
                                        }
1031
                                }
1032

    
1033
                        }
1034
                } else if (comp.equals(txtSize)) {
1035
                        double s = txtSize.getDouble();
1036

    
1037
                        if (selectedElement instanceof IMarkerSymbol) {
1038
                                IMarkerSymbol m = (IMarkerSymbol) selectedElement;
1039
                                m.setSize(s);
1040
                        }
1041

    
1042
                        if (selectedElement instanceof ILineSymbol) {
1043
                                ILineSymbol l = (ILineSymbol) selectedElement;
1044
                                l.setLineWidth(s);
1045
                        }
1046
                } else if (comp.equals(cmbUnits)) {
1047
                        if (selectedElement instanceof CartographicSupport) {
1048
                                CartographicSupport cs = (CartographicSupport) selectedElement;
1049
                                cs.setUnit(cmbUnits.getSelectedUnitIndex());
1050
                        }
1051
                } else if (comp.equals(cmbReferenceSystem)) {
1052
                        if (selectedElement instanceof CartographicSupport) {
1053
                                CartographicSupport cs = (CartographicSupport) selectedElement;
1054
                                cs.setUnit(cmbReferenceSystem.getSelectedIndex());
1055
                        }
1056
                } else if (comp.equals(txtWidth)) {
1057
                        double w = txtWidth.getDouble();
1058
                        if (selectedElement instanceof IFillSymbol) {
1059
                                IFillSymbol f = (IFillSymbol) selectedElement;
1060
                                ILineSymbol outline = f.getOutline();
1061
                                if (outline!=null) {
1062
                                        outline.setLineWidth(w);
1063
                                }
1064
                        }
1065
                } else if (comp.equals(cmbFontSize)) {
1066
                        double s = ((Integer) cmbFontSize.getSelectedItem()).doubleValue();
1067
                        if (selectedElement instanceof ITextSymbol) {
1068
                                ITextSymbol t = (ITextSymbol) selectedElement;
1069
                                t.setFontSize(s);
1070
                        }
1071
                } else if (comp.equals(txtAngle)) {
1072
                        double a = Math.toRadians(txtAngle.getDouble());
1073
                        if (selectedElement instanceof IMarkerSymbol) {
1074
                                IMarkerSymbol m = (IMarkerSymbol) selectedElement;
1075
                                m.setRotation(a);
1076
                        }
1077
                }
1078
        }
1079

    
1080
        public static ISymbolSelector createSymbolSelector(Object currSymbol, int shapeType) {
1081
                return createSymbolSelector(currSymbol, shapeType, null);
1082
        }
1083

    
1084
        public static ISymbolSelector createSymbolSelector(Object currSymbol, int shapeType, SelectorFilter filter) {
1085
                ISymbolSelector selector = null;
1086

    
1087
                // patch for backwards compatibility
1088
                //                if (currSymbol instanceof FSymbol) {
1089
                //                        currSymbol = SymbologyFactory.deriveFSymbol((FSymbol) currSymbol);
1090
                //                }
1091

    
1092
                if (filter==null) {
1093
                        selector = (shapeType == Geometry.TYPES.GEOMETRY) ?
1094
                                        new MultiShapeSymbolSelector(currSymbol) :
1095
                                                new SymbolSelector(currSymbol, shapeType, true);
1096
                } else {
1097
                        selector = (shapeType == Geometry.TYPES.GEOMETRY) ?
1098
                                        new MultiShapeSymbolSelector(currSymbol) :
1099
                                                new SymbolSelector(currSymbol, shapeType, filter, true);
1100
                }
1101
                return selector;
1102
        }
1103

    
1104
        class SillyDragNDropAction implements MouseListener, MouseMotionListener {
1105
                private boolean doDrop = false;
1106
                private Object selected;
1107
                private File sourceFolder;
1108

    
1109
                public void mouseClicked(MouseEvent e) { }
1110
                public void mouseEntered(MouseEvent e) { }
1111
                public void mouseExited(MouseEvent e) { }
1112

    
1113
                public void mousePressed(MouseEvent e) {
1114
                        if (e.getSource().equals(getJListSymbols())) {
1115
                                selected = getJListSymbols().getSelectedValue();
1116
                                doDrop = selected!=null;
1117
                                DefaultMutableTreeNode node = (DefaultMutableTreeNode) libraryBrowser.getLastSelectedPathComponent();
1118
                                if (node.getUserObject() instanceof File) {
1119
                                        sourceFolder = (File) node.getUserObject();
1120
                                }
1121
                        }
1122
                        e.consume();
1123
                }
1124

    
1125
                public void mouseReleased(MouseEvent e) {
1126
                        if (doDrop && e.getSource().equals(getJListSymbols())) {
1127
                                Point p = new Point(getJListSymbols().getLocation().x-e.getPoint().x, getJListSymbols().getLocation().y+e.getPoint().y);
1128
                                if (libraryBrowser.getBounds().contains(p)) {
1129
                                        File destFolder = libraryBrowser.getElementBellow(p);
1130
                                        if (destFolder != null) {
1131
                                                ISymbol sym = (ISymbol) selected;
1132
                                                int move = InputEvent.SHIFT_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK;
1133
                                                //                                            int copy = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
1134

    
1135
                                                library.addElement(sym, sym.getDescription(), destFolder);
1136
                                                if ((e.getModifiers() & (move)) !=0) {
1137
                                                        library.removeElement(sym, sourceFolder);
1138
                                                }
1139

    
1140
                                        }
1141
                                        libraryBrowser.refresh();
1142
                                }
1143

    
1144
                        }
1145
                        doDrop = false;
1146
                }
1147

    
1148
                public void mouseDragged(MouseEvent e) {
1149
                        if (e.getSource().equals(getJListSymbols())) {
1150

    
1151
                                Point p = new Point(getJListSymbols().getLocation().x-e.getPoint().x, getJListSymbols().getLocation().y+e.getPoint().y);
1152
                                if (libraryBrowser.getBounds().contains(p)) {
1153
                                        libraryBrowser.setSelectedElementBellow(p);
1154
                                }
1155
                        }
1156
                }
1157

    
1158
                public void mouseMoved(MouseEvent e) {
1159

    
1160
                }
1161

    
1162
        }
1163

    
1164
        public Object getWindowProfile() {
1165
                return WindowInfo.DIALOG_PROFILE;
1166
        }
1167

    
1168
}