root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SymbolSelector.java @ 20779
History | View | Annotate | Download (34 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.gui.beans.AcceptCancelPanel; |
79 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
80 |
import org.gvsig.gui.beans.swing.JButton; |
81 |
import org.gvsig.gui.beans.swing.JComboBoxFontSizes; |
82 |
import org.gvsig.gui.beans.swing.JComboBoxFonts; |
83 |
import org.gvsig.gui.beans.swing.JFileChooser; |
84 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
85 |
|
86 |
import com.iver.andami.PluginServices; |
87 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
88 |
import com.iver.cit.gvsig.fmap.core.CartographicSupport; |
89 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
90 |
import com.iver.cit.gvsig.fmap.core.FShape; |
91 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
92 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
93 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
94 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
95 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
96 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
97 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
98 |
import com.iver.cit.gvsig.fmap.core.symbols.IMultiLayerSymbol; |
99 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
100 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
101 |
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerLineSymbol; |
102 |
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerMarkerSymbol; |
103 |
import com.iver.cit.gvsig.gui.JComboBoxUnits; |
104 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
105 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.ISymbolSelector; |
106 |
|
107 |
/**
|
108 |
* Creates the panel where the user has the options to select a symbol.
|
109 |
* Apart from the option to select one, the user will have a previsualization
|
110 |
* of all the symbols stored and posibilities to modify an existing one, to create
|
111 |
* a new symbol and so on.
|
112 |
*
|
113 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
114 |
*/
|
115 |
public class SymbolSelector extends JPanel implements ISymbolSelector, ActionListener { |
116 |
|
117 |
private static final long serialVersionUID = -6405660392303659551L; |
118 |
private JPanel jPanel = null; |
119 |
protected JScrollPane jScrollPane = null; |
120 |
private JScrollPane jScrollPane1 = null; |
121 |
private WindowInfo wi;
|
122 |
private JSplitPane jSplitPane = null; |
123 |
protected AcceptCancelPanel okCancelPanel;
|
124 |
private JPanel northPanel; |
125 |
private ColorChooserPanel jcc1;
|
126 |
private ColorChooserPanel jcc2;
|
127 |
private JIncrementalNumberField txtSize;
|
128 |
private JIncrementalNumberField txtAngle;
|
129 |
private JPanel jPanelButtons; |
130 |
private JButton btnProperties; |
131 |
private int shapeType; |
132 |
private JButton btnSaveSymbol; |
133 |
private JButton btnResetSymbol; |
134 |
private JButton btnNewSymbol; |
135 |
private JComboBoxFonts cmbFonts;
|
136 |
private JToggleButton btnBold; |
137 |
private JToggleButton btnItalic; |
138 |
private JToggleButton btnUnderlined; |
139 |
protected JLabel lblTitle; |
140 |
protected File dir; |
141 |
protected File rootDir; |
142 |
protected JComponent jPanelPreview = null; |
143 |
protected GridBagLayoutPanel jPanelOptions = null; |
144 |
protected JList jListSymbols = null; |
145 |
protected String treeRootName; |
146 |
protected ILibraryModel library;
|
147 |
private JIncrementalNumberField txtWidth;
|
148 |
protected boolean act = true; |
149 |
boolean accepted = true; |
150 |
|
151 |
|
152 |
protected SelectorFilter sFilter = new SelectorFilter() { |
153 |
private final IGeometry dummyPointGeom = ShapeFactory.createPoint2D(new FPoint2D()); |
154 |
private final IGeometry dummyLineGeom = ShapeFactory.createPolyline2D(new GeneralPathX()); |
155 |
private final IGeometry dummyPolygonGeom = ShapeFactory.createPolygon2D(new GeneralPathX()); |
156 |
|
157 |
public boolean accepts(Object obj) { |
158 |
if (obj instanceof ISymbol) { |
159 |
ISymbol sym = (ISymbol) obj; |
160 |
|
161 |
IGeometry compareGeometry = null;
|
162 |
switch (SymbolSelector.this.shapeType) {
|
163 |
case FShape.TEXT:
|
164 |
return sym instanceof ITextSymbol; |
165 |
case FShape.POINT:
|
166 |
compareGeometry = dummyPointGeom; |
167 |
break;
|
168 |
case FShape.LINE:
|
169 |
compareGeometry = dummyLineGeom; |
170 |
break;
|
171 |
case FShape.POLYGON:
|
172 |
compareGeometry = dummyPolygonGeom; |
173 |
break;
|
174 |
} |
175 |
return sym.isSuitableFor(compareGeometry);
|
176 |
} |
177 |
return false; |
178 |
} |
179 |
}; |
180 |
protected JComboBoxUnits cmbUnits;
|
181 |
protected JComboBoxUnitsReferenceSystem cmbReferenceSystem;
|
182 |
private JComboBoxFontSizes cmbFontSize;
|
183 |
protected LibraryBrowser libraryBrowser;
|
184 |
/**
|
185 |
* Constructor method
|
186 |
*
|
187 |
* @param currentElement
|
188 |
* @param shapeType
|
189 |
*/
|
190 |
private SymbolSelector(Object currentElement, int shapeType, boolean initialize) { |
191 |
super();
|
192 |
|
193 |
// TODO 09/08/07 check the currentElement type is suitable for the shapeType specified
|
194 |
if (currentElement != null && currentElement instanceof ISymbol) { |
195 |
ISymbol sym = (ISymbol) currentElement; |
196 |
currentElement = SymbologyFactory.createSymbolFromXML( |
197 |
sym.getXMLEntity(), "");
|
198 |
String desc = sym.getDescription();
|
199 |
desc += " ("+PluginServices.getText(this, "current")+")"; |
200 |
((ISymbol)currentElement).setDescription(desc); |
201 |
} |
202 |
|
203 |
this.shapeType = shapeType;
|
204 |
// Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
|
205 |
rootDir = new File(SymbologyFactory.SymbolLibraryPath); |
206 |
// prefs.get("SymbolLibraryFolder", System.getProperty("user.home")+"/gvSIG/Symbols"));
|
207 |
if (!rootDir.exists())
|
208 |
rootDir.mkdir(); |
209 |
treeRootName = PluginServices.getText(this, "symbol_library"); |
210 |
try {
|
211 |
if (initialize)
|
212 |
initialize(currentElement); |
213 |
} catch (ClassNotFoundException e) { |
214 |
throw new Error(e); |
215 |
} |
216 |
|
217 |
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* Constructor method, it is <b>protected</b> by convenience to let StyleSelector
|
222 |
* to invoke it, but rigorously it should be <b>private</b>.
|
223 |
*
|
224 |
* @param symbol
|
225 |
* @param shapeType
|
226 |
* @param filter
|
227 |
*/
|
228 |
protected SymbolSelector(Object symbol, int shapeType, SelectorFilter filter, boolean initialize) { |
229 |
this(symbol, shapeType, initialize);
|
230 |
sFilter = filter; |
231 |
} |
232 |
|
233 |
/**
|
234 |
* This method initializes this
|
235 |
* @param currentElement
|
236 |
* @throws ClassNotFoundException
|
237 |
*
|
238 |
*/
|
239 |
protected void initialize(Object currentElement) throws ClassNotFoundException { |
240 |
library = new SymbolLibrary(rootDir);
|
241 |
|
242 |
this.setLayout(new BorderLayout()); |
243 |
this.setSize(400, 221); |
244 |
|
245 |
this.add(getJNorthPanel(), BorderLayout.NORTH); |
246 |
this.add(getJSplitPane(), BorderLayout.CENTER); |
247 |
this.add(getJEastPanel(), BorderLayout.EAST); |
248 |
ActionListener okAction = new ActionListener() { |
249 |
public void actionPerformed(ActionEvent e) { |
250 |
PluginServices.getMDIManager().closeWindow(SymbolSelector.this); |
251 |
} |
252 |
}, cancelAction = new ActionListener() { |
253 |
public void actionPerformed(ActionEvent e) { |
254 |
accepted = false;
|
255 |
|
256 |
setSymbol(null);
|
257 |
PluginServices.getMDIManager().closeWindow(SymbolSelector.this); |
258 |
} |
259 |
}; |
260 |
|
261 |
okCancelPanel = new AcceptCancelPanel();
|
262 |
okCancelPanel.setOkButtonActionListener(okAction); |
263 |
okCancelPanel.setCancelButtonActionListener(cancelAction); |
264 |
|
265 |
this.add(okCancelPanel, BorderLayout.SOUTH); |
266 |
libraryBrowser.setSelectionRow(0);
|
267 |
|
268 |
SillyDragNDropAction dndAction = new SillyDragNDropAction();
|
269 |
libraryBrowser.addMouseListener(dndAction); |
270 |
libraryBrowser.addMouseMotionListener(dndAction); |
271 |
getJListSymbols().addMouseListener(dndAction); |
272 |
getJListSymbols().addMouseMotionListener(dndAction); |
273 |
setSymbol(currentElement); |
274 |
} |
275 |
|
276 |
/**
|
277 |
* Creates a new symbol selector list model in order to allow the user
|
278 |
* to select an existing symbol previously created.
|
279 |
*
|
280 |
* @return listModel SymbolSelectorListModel
|
281 |
*/
|
282 |
protected SymbolSelectorListModel newListModel() {
|
283 |
SymbolSelectorListModel listModel = new SymbolSelectorListModel(
|
284 |
dir, |
285 |
sFilter, |
286 |
SymbolLibrary.SYMBOL_FILE_EXTENSION); |
287 |
return listModel;
|
288 |
} |
289 |
/**
|
290 |
* Initializes tha JNorthPanel.
|
291 |
*
|
292 |
* @return northPanel JPanel
|
293 |
* @throws IllegalArgumentException
|
294 |
*/
|
295 |
protected JPanel getJNorthPanel() throws IllegalArgumentException { |
296 |
if (northPanel == null) { |
297 |
String text = ""; |
298 |
switch (shapeType) {
|
299 |
case FShape.POINT:
|
300 |
text = PluginServices.getText(this, "point_symbols"); |
301 |
break;
|
302 |
case FShape.LINE:
|
303 |
text = PluginServices.getText(this, "line_symbols"); |
304 |
break;
|
305 |
case FShape.POLYGON:
|
306 |
text = PluginServices.getText(this, "polygon_symbols"); |
307 |
break;
|
308 |
case FShape.TEXT:
|
309 |
text = PluginServices.getText(this, "text_symbols"); |
310 |
break;
|
311 |
default:
|
312 |
throw new IllegalArgumentException(PluginServices.getText(this, "shape_type_not_yet_supported")); |
313 |
} |
314 |
northPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
315 |
lblTitle = new JLabel(text); |
316 |
lblTitle.setFont(lblTitle.getFont().deriveFont(Font.BOLD));
|
317 |
northPanel.add(lblTitle); |
318 |
} |
319 |
return northPanel;
|
320 |
} |
321 |
|
322 |
/**
|
323 |
* This method initializes jList
|
324 |
*
|
325 |
* @return javax.swing.JList
|
326 |
*/
|
327 |
protected JList getJListSymbols() { |
328 |
if (jListSymbols == null) { |
329 |
jListSymbols = new JList() ; |
330 |
jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
331 |
jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP);
|
332 |
jListSymbols.setVisibleRowCount(-1);
|
333 |
jListSymbols.addListSelectionListener(new ListSelectionListener() { |
334 |
public void valueChanged(ListSelectionEvent e) { |
335 |
if (jListSymbols.getSelectedValue()!=null) { |
336 |
ISymbol selSym = SymbologyFactory.createSymbolFromXML( |
337 |
((ISymbol) jListSymbols.getSelectedValue()).getXMLEntity(), null);
|
338 |
setSymbol(selSym); |
339 |
updateOptionsPanel(); |
340 |
} |
341 |
} |
342 |
}); |
343 |
ListCellRenderer renderer = new ListCellRenderer() { |
344 |
private Color mySelectedBGColor = new Color(255,145,100,255); |
345 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
346 |
ISymbol sym = (ISymbol) value; |
347 |
JPanel pnl = new JPanel(); |
348 |
BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS); |
349 |
pnl.setLayout(layout); |
350 |
Color bgColor = (isSelected) ? mySelectedBGColor
|
351 |
: getJListSymbols().getBackground(); |
352 |
|
353 |
pnl.setBackground(bgColor); |
354 |
SymbolPreviewer sp = new SymbolPreviewer();
|
355 |
sp.setAlignmentX(Component.CENTER_ALIGNMENT);
|
356 |
sp.setPreferredSize(new Dimension(50, 50)); |
357 |
sp.setSymbol(sym); |
358 |
sp.setBackground(bgColor); |
359 |
pnl.add(sp); |
360 |
String desc = sym.getDescription();
|
361 |
if (desc == null) { |
362 |
desc = "["+PluginServices.getText(this, "no_desc")+"]"; |
363 |
} |
364 |
JLabel lbl = new JLabel(desc); |
365 |
lbl.setBackground(bgColor); |
366 |
lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
|
367 |
pnl.add(lbl); |
368 |
|
369 |
return pnl;
|
370 |
} |
371 |
|
372 |
}; |
373 |
jListSymbols.setCellRenderer(renderer); |
374 |
} |
375 |
return jListSymbols;
|
376 |
} |
377 |
/**
|
378 |
* Updates the options panel depending on the type of symbol that the user
|
379 |
* is controlling or using to show specific options for each one.
|
380 |
*
|
381 |
*/
|
382 |
protected void updateOptionsPanel() throws IllegalArgumentException { |
383 |
Object mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();
|
384 |
|
385 |
if (mySelectedElement == null) return; |
386 |
act = false; // disable events |
387 |
|
388 |
if (mySelectedElement instanceof CartographicSupport) { |
389 |
CartographicSupport cs = (CartographicSupport) mySelectedElement; |
390 |
cmbUnits.setSelectedUnitIndex(cs.getUnit()); |
391 |
cmbReferenceSystem.setSelectedIndex(cs.getReferenceSystem()); |
392 |
} |
393 |
|
394 |
try {
|
395 |
if (shapeType == FShape.POINT) {
|
396 |
IMarkerSymbol m = (IMarkerSymbol) mySelectedElement; |
397 |
jcc1.setColor(m.getColor()); |
398 |
txtSize.setDouble(m.getSize()); |
399 |
txtAngle.setDouble(m.getRotation()); |
400 |
} |
401 |
|
402 |
if (shapeType == FShape.LINE) {
|
403 |
ILineSymbol l = (ILineSymbol) mySelectedElement; |
404 |
jcc1.setColor(l.getColor()); |
405 |
jcc1.setAlpha(l.getAlpha()); |
406 |
txtSize.setDouble(l.getLineWidth()); |
407 |
} |
408 |
|
409 |
if (shapeType == FShape.POLYGON) {
|
410 |
IFillSymbol f = (IFillSymbol) mySelectedElement; |
411 |
|
412 |
jcc1.setUseColorIsSelected(f.hasFill()); |
413 |
jcc1.setColor(f.getFillColor()); |
414 |
jcc1.setAlpha(f.getFillAlpha()); |
415 |
jcc2.setUseColorIsSelected(f.hasOutline()); |
416 |
ILineSymbol outline = f.getOutline(); |
417 |
if (outline != null) { |
418 |
jcc2.setColor(outline.getColor()); |
419 |
txtWidth.setDouble(outline.getLineWidth()); |
420 |
} |
421 |
|
422 |
} |
423 |
|
424 |
|
425 |
if (shapeType == FShape.TEXT) {
|
426 |
ITextSymbol t = (ITextSymbol) mySelectedElement; |
427 |
jcc1.setColor(t.getTextColor()); |
428 |
Double s = new Double(t.getFont().getSize()); |
429 |
cmbFontSize.setSelectedItem(s); |
430 |
int i = cmbFontSize.getSelectedIndex();
|
431 |
if (i == -1) { |
432 |
cmbFontSize.addItem(s); |
433 |
cmbFontSize.setSelectedItem(s); |
434 |
} |
435 |
} |
436 |
} catch (NullPointerException npEx) { |
437 |
throw new IllegalArgumentException(npEx); |
438 |
} catch (ClassCastException ccEx) { |
439 |
throw new IllegalArgumentException(ccEx); |
440 |
} |
441 |
|
442 |
act = true; // enable events |
443 |
} |
444 |
|
445 |
/**
|
446 |
* This method initializes jPanel
|
447 |
*
|
448 |
* @return javax.swing.JPanel
|
449 |
*/
|
450 |
protected JPanel getJEastPanel() { |
451 |
if (jPanel == null) { |
452 |
jPanel = new JPanel(); |
453 |
jPanel.setLayout(new BorderLayout()); |
454 |
jPanel.add(getJPanelOptions(), BorderLayout.CENTER);
|
455 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
456 |
aux.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "preview"))); |
457 |
aux.add(getJPanelPreview()); |
458 |
jPanel.add(aux, BorderLayout.NORTH);
|
459 |
|
460 |
jPanel.add(getJPanelOptions()); |
461 |
aux = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5)); |
462 |
aux.add(getJPanelButtons()); |
463 |
jPanel.add(aux, BorderLayout.SOUTH);
|
464 |
} |
465 |
return jPanel;
|
466 |
} |
467 |
|
468 |
private JPanel getJPanelButtons() { |
469 |
if (jPanelButtons == null) { |
470 |
jPanelButtons = new JPanel(); |
471 |
GridLayout layout = new GridLayout(); |
472 |
layout.setColumns(1);
|
473 |
layout.setVgap(5);
|
474 |
jPanelButtons.add(getBtnNewSymbol()); |
475 |
jPanelButtons.add(getBtnSaveSymbol()); |
476 |
jPanelButtons.add(getBtnResetSymbol()); |
477 |
jPanelButtons.add(getBtnProperties()); |
478 |
|
479 |
// do not add components bellow this line!
|
480 |
layout.setRows(jPanelButtons.getComponentCount()); |
481 |
jPanelButtons.setLayout(layout); |
482 |
} |
483 |
return jPanelButtons;
|
484 |
} |
485 |
|
486 |
private JButton getBtnNewSymbol() { |
487 |
if (btnNewSymbol == null) { |
488 |
btnNewSymbol = new JButton(); |
489 |
btnNewSymbol.setName("btnNewSymbol");
|
490 |
btnNewSymbol.setText(PluginServices.getText(this, "new")); |
491 |
btnNewSymbol.addActionListener(this);
|
492 |
} |
493 |
return btnNewSymbol;
|
494 |
} |
495 |
|
496 |
private JButton getBtnResetSymbol() { |
497 |
if (btnResetSymbol == null) { |
498 |
btnResetSymbol = new JButton(); |
499 |
btnResetSymbol.setName("btnResetSymbol");
|
500 |
btnResetSymbol.setText(PluginServices.getText(this, "reset")); |
501 |
btnResetSymbol.addActionListener(this);
|
502 |
} |
503 |
return btnResetSymbol;
|
504 |
} |
505 |
|
506 |
private JButton getBtnSaveSymbol() { |
507 |
if (btnSaveSymbol == null) { |
508 |
btnSaveSymbol = new JButton(); |
509 |
btnSaveSymbol.setName("btnSaveSymbol");
|
510 |
btnSaveSymbol.setText(PluginServices.getText(this, "save")); |
511 |
btnSaveSymbol.addActionListener(this);
|
512 |
} |
513 |
return btnSaveSymbol;
|
514 |
} |
515 |
|
516 |
private JButton getBtnProperties() { |
517 |
if (btnProperties == null) { |
518 |
btnProperties = new JButton(); |
519 |
btnProperties.setName("btnProperties");
|
520 |
btnProperties.setText(PluginServices.getText(this, "properties")); |
521 |
btnProperties.addActionListener(this);
|
522 |
} |
523 |
return btnProperties;
|
524 |
} |
525 |
|
526 |
/**
|
527 |
* This method initializes jScrollPane
|
528 |
*
|
529 |
* @return javax.swing.JScrollPane
|
530 |
* @throws ClassNotFoundException
|
531 |
*/
|
532 |
protected JScrollPane getLeftJScrollPane() throws ClassNotFoundException { |
533 |
if (jScrollPane == null) { |
534 |
jScrollPane = new JScrollPane(); |
535 |
jScrollPane.setPreferredSize(new java.awt.Dimension(80,130)); |
536 |
jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
537 |
libraryBrowser = new LibraryBrowser(library);
|
538 |
libraryBrowser.addTreeSelectionListener(new TreeSelectionListener() { |
539 |
public void valueChanged(javax.swing.event.TreeSelectionEvent e) { |
540 |
dir = (File) ((DefaultMutableTreeNode) |
541 |
libraryBrowser.getLastSelectedPathComponent()).getUserObject(); |
542 |
|
543 |
if (dir == null) return; |
544 |
|
545 |
jListSymbols.setModel(newListModel()); |
546 |
// jListSymbols.setSelectedValue(selectedElement, true);
|
547 |
} |
548 |
}); |
549 |
jScrollPane.setViewportView(libraryBrowser); |
550 |
} |
551 |
return jScrollPane;
|
552 |
} |
553 |
|
554 |
/**
|
555 |
* This method initializes jScrollPane1
|
556 |
*
|
557 |
* @return javax.swing.JScrollPane
|
558 |
*/
|
559 |
private JScrollPane getJScrollPane1() { |
560 |
if (jScrollPane1 == null) { |
561 |
jScrollPane1 = new JScrollPane(); |
562 |
jScrollPane1.setViewportView(getJListSymbols()); |
563 |
} |
564 |
return jScrollPane1;
|
565 |
} |
566 |
|
567 |
/**
|
568 |
* This method initializes jPanelPreview
|
569 |
*
|
570 |
* @return javax.swing.JComponent
|
571 |
*/
|
572 |
protected JComponent getJPanelPreview() { |
573 |
if (jPanelPreview == null) { |
574 |
jPanelPreview = new SymbolPreviewer();
|
575 |
jPanelPreview.setPreferredSize(new java.awt.Dimension(100,100)); |
576 |
jPanelPreview.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); |
577 |
} |
578 |
return jPanelPreview;
|
579 |
} |
580 |
/**
|
581 |
* This method initializes jPanelOptions
|
582 |
*
|
583 |
* @return javax.swing.JPanel
|
584 |
*/
|
585 |
protected JPanel getJPanelOptions() { |
586 |
if (jPanelOptions == null) { |
587 |
jPanelOptions = new GridBagLayoutPanel();
|
588 |
jPanelOptions.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "options"))); |
589 |
jcc2 = new ColorChooserPanel(true,true); |
590 |
jcc2.setAlpha(255);
|
591 |
if (shapeType == FShape.POINT) {
|
592 |
jcc1 = new ColorChooserPanel(true); |
593 |
|
594 |
jPanelOptions.addComponent( |
595 |
PluginServices.getText(this, "color")+":", jcc1); |
596 |
jPanelOptions.addComponent( |
597 |
PluginServices.getText(this, "size")+":", |
598 |
txtSize = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1)); |
599 |
jPanelOptions.addComponent(PluginServices.getText(this, "units")+":", |
600 |
cmbUnits = new JComboBoxUnits());
|
601 |
jPanelOptions.addComponent("",
|
602 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
603 |
jPanelOptions.addComponent( |
604 |
PluginServices.getText(this, "angle")+":", |
605 |
txtAngle = new JIncrementalNumberField());
|
606 |
|
607 |
|
608 |
} else if (shapeType == FShape.LINE) { |
609 |
jcc1 = new ColorChooserPanel(true); |
610 |
jPanelOptions.addComponent( |
611 |
PluginServices.getText(this, "color")+":", jcc1); |
612 |
jPanelOptions.addComponent( |
613 |
PluginServices.getText(this, "width")+":", |
614 |
txtSize = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1)); |
615 |
jPanelOptions.addComponent(PluginServices.getText(this, "units")+":", |
616 |
cmbUnits = new JComboBoxUnits());
|
617 |
jPanelOptions.addComponent("",
|
618 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
619 |
|
620 |
} else if (shapeType == FShape.POLYGON) { |
621 |
jcc1 = new ColorChooserPanel(true, true); |
622 |
jPanelOptions.addComponent( |
623 |
PluginServices.getText(this, "fill_color")+":", jcc1); |
624 |
jPanelOptions.addComponent( |
625 |
PluginServices.getText(this, "outline_color")+":", jcc2); |
626 |
jPanelOptions.addComponent( |
627 |
PluginServices.getText(this, "outline_width"), |
628 |
txtWidth = new JIncrementalNumberField(String.valueOf(3), 3, 0, Double.MAX_VALUE, 1)); |
629 |
jPanelOptions.addComponent(PluginServices.getText(this, "units")+":", |
630 |
cmbUnits = new JComboBoxUnits());
|
631 |
jPanelOptions.addComponent("",
|
632 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
633 |
|
634 |
} else if (shapeType == FShape.TEXT) { |
635 |
jcc1 = new ColorChooserPanel(true); |
636 |
jPanelOptions.addComponent( |
637 |
PluginServices.getText(this, "font")+":", getCmbFonts()); |
638 |
|
639 |
jPanelOptions.addComponent( |
640 |
PluginServices.getText(this, "color")+":", jcc1); |
641 |
jPanelOptions.addComponent(PluginServices.getText(this, "size")+":", |
642 |
cmbFontSize = new JComboBoxFontSizes());
|
643 |
jPanelOptions.addComponent(PluginServices.getText(this, "units")+":", |
644 |
cmbUnits = new JComboBoxUnits());
|
645 |
jPanelOptions.addComponent("",
|
646 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
647 |
|
648 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING,0,1)); |
649 |
aux.add(getBtnBold()); |
650 |
aux.add(getBtnItalic()); |
651 |
aux.add(getBtnUnderlined()); |
652 |
jPanelOptions.addComponent( |
653 |
PluginServices.getText(this, "style")+":", aux); |
654 |
|
655 |
} |
656 |
|
657 |
jcc1.setAlpha(255);
|
658 |
|
659 |
if (txtSize != null) txtSize.addActionListener(this); |
660 |
if (cmbUnits != null) cmbUnits.addActionListener(this); |
661 |
if (cmbReferenceSystem != null) cmbReferenceSystem.addActionListener(this); |
662 |
if (jcc1 != null) jcc1.addActionListener(this); |
663 |
if (jcc2 != null) jcc2.addActionListener(this); |
664 |
if (txtWidth != null) txtWidth.addActionListener(this); |
665 |
if (cmbFontSize != null) cmbFontSize.addActionListener(this); |
666 |
if (txtAngle != null) txtAngle.addActionListener(this); |
667 |
} |
668 |
return jPanelOptions;
|
669 |
} |
670 |
|
671 |
private JToggleButton getBtnUnderlined() { |
672 |
if (btnUnderlined == null) { |
673 |
btnUnderlined = new JToggleButton(PluginServices.getIconTheme(). |
674 |
get("underline-icon"));
|
675 |
} |
676 |
return btnUnderlined;
|
677 |
} |
678 |
|
679 |
private JToggleButton getBtnItalic() { |
680 |
if (btnItalic == null) { |
681 |
btnItalic = new JToggleButton(PluginServices.getIconTheme(). |
682 |
get("italic-icon"));
|
683 |
} |
684 |
return btnItalic;
|
685 |
} |
686 |
|
687 |
private JToggleButton getBtnBold() { |
688 |
if (btnBold == null) { |
689 |
btnBold = new JToggleButton(PluginServices.getIconTheme(). |
690 |
get("bold-icon"));
|
691 |
} |
692 |
return btnBold;
|
693 |
} |
694 |
|
695 |
|
696 |
private JComboBoxFonts getCmbFonts() {
|
697 |
if (cmbFonts == null) { |
698 |
cmbFonts = new JComboBoxFonts();
|
699 |
} |
700 |
return cmbFonts;
|
701 |
} |
702 |
|
703 |
public WindowInfo getWindowInfo() {
|
704 |
if (wi == null) { |
705 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
706 |
wi.setWidth(706);
|
707 |
wi.setHeight(500);
|
708 |
wi.setTitle(PluginServices.getText(this, "symbol_selector")); |
709 |
} |
710 |
return wi;
|
711 |
} |
712 |
|
713 |
protected JSplitPane getJSplitPane() throws ClassNotFoundException { |
714 |
if (jSplitPane == null) { |
715 |
jSplitPane = new JSplitPane(); |
716 |
jSplitPane.setDividerLocation(200);
|
717 |
jSplitPane.setResizeWeight(0.4);
|
718 |
jSplitPane.setLeftComponent(getLeftJScrollPane()); |
719 |
jSplitPane.setRightComponent(getJScrollPane1()); |
720 |
} |
721 |
return jSplitPane;
|
722 |
} |
723 |
|
724 |
public Object getSelectedObject() { |
725 |
if (!accepted) return null; |
726 |
Object mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();
|
727 |
|
728 |
// if this symbol only has one layer, then no multilayer is needed
|
729 |
if (mySelectedElement instanceof IMultiLayerSymbol) { |
730 |
if (((IMultiLayerSymbol) mySelectedElement).getLayerCount()==1) |
731 |
return ((IMultiLayerSymbol) mySelectedElement).getLayer(0); |
732 |
} |
733 |
|
734 |
if (mySelectedElement instanceof CartographicSupport) { |
735 |
CartographicSupport csSym = (CartographicSupport) mySelectedElement; |
736 |
csSym.setUnit(cmbUnits.getSelectedUnitIndex()); |
737 |
csSym.setReferenceSystem(cmbReferenceSystem.getSelectedIndex()); |
738 |
} |
739 |
|
740 |
return mySelectedElement;
|
741 |
} |
742 |
|
743 |
public void setSymbol(Object symbol) { |
744 |
((SymbolPreviewer) jPanelPreview).setSymbol((ISymbol) symbol); |
745 |
updateOptionsPanel(); |
746 |
} |
747 |
|
748 |
/**
|
749 |
* Invoked when the PROPERTIES button is pressed
|
750 |
*/
|
751 |
protected void propertiesPressed() { |
752 |
ISymbol mySelectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol(); |
753 |
if (mySelectedElement ==null) |
754 |
return;
|
755 |
|
756 |
ISymbol clonedSymbol = SymbologyFactory.createSymbolFromXML( |
757 |
mySelectedElement.getXMLEntity(), null);
|
758 |
SymbolEditor se = new SymbolEditor(clonedSymbol, shapeType);
|
759 |
PluginServices.getMDIManager().addWindow(se); |
760 |
|
761 |
ISymbol symbol = se.getSymbol(); |
762 |
if (symbol instanceof IMultiLayerSymbol) { |
763 |
IMultiLayerSymbol mSym = (IMultiLayerSymbol) symbol; |
764 |
if (mSym.getLayerCount() == 1) { |
765 |
symbol = mSym.getLayer(0);
|
766 |
} |
767 |
} |
768 |
setSymbol(symbol); |
769 |
|
770 |
} |
771 |
|
772 |
/**
|
773 |
* Invoked when the NEW button is pressed
|
774 |
*/
|
775 |
protected void newPressed() { |
776 |
SymbolEditor se = new SymbolEditor(null, shapeType); |
777 |
PluginServices.getMDIManager().addWindow(se); |
778 |
setSymbol(se.getSymbol()); |
779 |
} |
780 |
|
781 |
/**
|
782 |
* Invoked when the RESET button is pressed
|
783 |
*/
|
784 |
protected void resetPressed() { |
785 |
setSymbol(null);
|
786 |
} |
787 |
|
788 |
/**
|
789 |
* Invoked when the SAVE button is pressed
|
790 |
*/
|
791 |
protected void savePressed() { |
792 |
if (getSelectedObject() ==null) |
793 |
return;
|
794 |
|
795 |
|
796 |
JFileChooser jfc = new JFileChooser("SYMBOL_SELECTOR_FILECHOOSER", rootDir); |
797 |
javax.swing.filechooser.FileFilter ff = new javax.swing.filechooser.FileFilter() {
|
798 |
public boolean accept(File f) { |
799 |
return f.getAbsolutePath().
|
800 |
toLowerCase(). |
801 |
endsWith(SymbolLibrary.SYMBOL_FILE_EXTENSION) || f.isDirectory(); |
802 |
} |
803 |
|
804 |
public String getDescription() { |
805 |
return PluginServices.getText(
|
806 |
this, "gvSIG_symbol_definition_file")+ " (*.sym)"; |
807 |
} |
808 |
}; |
809 |
jfc.setFileFilter(ff); |
810 |
JPanel accessory = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
811 |
accessory.add(new JLabel(PluginServices.getText(this, "enter_description"))); |
812 |
JTextField txtDesc = new JTextField(25); |
813 |
accessory.add(txtDesc); |
814 |
jfc.setAccessory(accessory); |
815 |
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { |
816 |
File targetFile = jfc.getSelectedFile();
|
817 |
|
818 |
// apply description
|
819 |
String desc;
|
820 |
if (txtDesc.getText()==null || txtDesc.getText().trim().equals("")) { |
821 |
// default to file name
|
822 |
String s = targetFile.getAbsolutePath();
|
823 |
desc = s.substring(s.lastIndexOf(File.separator)+1). |
824 |
replaceAll(SymbolLibrary.SYMBOL_FILE_EXTENSION, "");
|
825 |
} else {
|
826 |
desc = txtDesc.getText().trim(); |
827 |
} |
828 |
ISymbol s = (ISymbol) getSelectedObject(); |
829 |
s.setDescription(desc); |
830 |
|
831 |
|
832 |
getJListSymbols().setModel(newListModel()); |
833 |
// getJListSymbols().setSelectedValue(
|
834 |
// selectedElement, true);
|
835 |
String symbolFileName = targetFile.getAbsolutePath().substring(
|
836 |
targetFile.getAbsolutePath().lastIndexOf(File.separator)+1, |
837 |
targetFile.getAbsolutePath().length()); |
838 |
File targetDir = new File(targetFile.getAbsolutePath().substring( |
839 |
0,
|
840 |
targetFile.getAbsolutePath().lastIndexOf(File.separator)));
|
841 |
library.addElement(s, symbolFileName , targetDir); |
842 |
} |
843 |
} |
844 |
|
845 |
|
846 |
public void actionPerformed(ActionEvent e) { |
847 |
if (!act) return; |
848 |
Object selectedElement = ((SymbolPreviewer) jPanelPreview).getSymbol();//getSelectedObject(); |
849 |
performActionOn(selectedElement, e); |
850 |
SymbolSelector.this.repaint(); |
851 |
} |
852 |
|
853 |
protected void performActionOn(Object selectedElement, ActionEvent e) { |
854 |
JComponent comp = (JComponent) e.getSource(); |
855 |
|
856 |
if ( comp.equals(getBtnProperties()) ) {
|
857 |
// properties pressed
|
858 |
propertiesPressed(); |
859 |
} else if ( comp.equals(getBtnNewSymbol()) ) { |
860 |
// new pressed
|
861 |
newPressed(); |
862 |
} else if ( comp.equals(getBtnResetSymbol()) ) { |
863 |
// reset pressed
|
864 |
resetPressed(); |
865 |
} else if ( comp.equals(getBtnSaveSymbol()) ) { |
866 |
// save pressed
|
867 |
savePressed(); |
868 |
} else if (comp.equals(jcc1)) { |
869 |
if (selectedElement == null) |
870 |
return;
|
871 |
|
872 |
Color c = jcc1.getColor();
|
873 |
|
874 |
if (selectedElement instanceof IMarkerSymbol) { |
875 |
IMarkerSymbol m = (IMarkerSymbol) selectedElement; |
876 |
if (m instanceof MultiLayerMarkerSymbol) { |
877 |
MultiLayerMarkerSymbol mm = (MultiLayerMarkerSymbol) m; |
878 |
mm.setAlpha(jcc1.getAlpha()); |
879 |
} else {
|
880 |
m.setColor(c); |
881 |
} |
882 |
} |
883 |
|
884 |
if (selectedElement instanceof ILineSymbol) { |
885 |
ILineSymbol l = (ILineSymbol) selectedElement; |
886 |
if (l instanceof MultiLayerLineSymbol) { |
887 |
MultiLayerLineSymbol ml = (MultiLayerLineSymbol) l; |
888 |
ml.setAlpha(jcc1.getAlpha()); |
889 |
} else {
|
890 |
l.setLineColor(c); |
891 |
} |
892 |
} |
893 |
|
894 |
if (selectedElement instanceof IFillSymbol) { |
895 |
IFillSymbol f = (IFillSymbol) selectedElement; |
896 |
|
897 |
f.setHasFill(jcc1.getUseColorisSelected()); |
898 |
f.setFillColor(c); |
899 |
} |
900 |
|
901 |
if (selectedElement instanceof ITextSymbol) { |
902 |
ITextSymbol t = (ITextSymbol) selectedElement; |
903 |
t.setTextColor(c); |
904 |
} |
905 |
|
906 |
} else if (comp.equals(jcc2)) { |
907 |
if (selectedElement == null) |
908 |
return;
|
909 |
Color c = jcc2.getColor();
|
910 |
|
911 |
|
912 |
if (selectedElement instanceof IFillSymbol) { |
913 |
IFillSymbol f = (IFillSymbol) selectedElement; |
914 |
ILineSymbol outline = f.getOutline(); |
915 |
f.setHasOutline(jcc2.getUseColorisSelected()); |
916 |
|
917 |
if (outline!=null) { |
918 |
ILineSymbol l = (ILineSymbol) outline; |
919 |
if (l instanceof MultiLayerLineSymbol && c != null) { |
920 |
MultiLayerLineSymbol ml = (MultiLayerLineSymbol) l; |
921 |
ml.setAlpha(c.getAlpha()); |
922 |
} else {
|
923 |
l.setLineColor(c); |
924 |
} |
925 |
} |
926 |
|
927 |
} |
928 |
} else if (comp.equals(txtSize)) { |
929 |
double s = txtSize.getDouble();
|
930 |
|
931 |
if (selectedElement instanceof IMarkerSymbol) { |
932 |
IMarkerSymbol m = (IMarkerSymbol) selectedElement; |
933 |
m.setSize(s); |
934 |
} |
935 |
|
936 |
if (selectedElement instanceof ILineSymbol) { |
937 |
ILineSymbol l = (ILineSymbol) selectedElement; |
938 |
l.setLineWidth(s); |
939 |
} |
940 |
} else if (comp.equals(cmbUnits)) { |
941 |
if (selectedElement instanceof CartographicSupport) { |
942 |
CartographicSupport cs = (CartographicSupport) selectedElement; |
943 |
cs.setUnit(cmbUnits.getSelectedUnitIndex()); |
944 |
} |
945 |
} else if (comp.equals(cmbReferenceSystem)) { |
946 |
if (selectedElement instanceof CartographicSupport) { |
947 |
CartographicSupport cs = (CartographicSupport) selectedElement; |
948 |
cs.setUnit(cmbReferenceSystem.getSelectedIndex()); |
949 |
} |
950 |
} else if (comp.equals(txtWidth)) { |
951 |
double w = txtWidth.getDouble();
|
952 |
if (selectedElement instanceof IFillSymbol) { |
953 |
IFillSymbol f = (IFillSymbol) selectedElement; |
954 |
ILineSymbol outline = f.getOutline(); |
955 |
if (outline!=null) |
956 |
outline.setLineWidth(w); |
957 |
} |
958 |
} else if (comp.equals(cmbFontSize)) { |
959 |
double s = ((Integer) cmbFontSize.getSelectedItem()).doubleValue(); |
960 |
if (selectedElement instanceof ITextSymbol) { |
961 |
ITextSymbol t = (ITextSymbol) selectedElement; |
962 |
t.setFontSize(s); |
963 |
} |
964 |
} else if (comp.equals(txtAngle)) { |
965 |
double a = Math.toRadians(txtAngle.getDouble()); |
966 |
if (selectedElement instanceof IMarkerSymbol) { |
967 |
IMarkerSymbol m = (IMarkerSymbol) selectedElement; |
968 |
m.setRotation(a); |
969 |
} |
970 |
} |
971 |
} |
972 |
|
973 |
public static ISymbolSelector createSymbolSelector(Object currSymbol, int shapeType) { |
974 |
return createSymbolSelector(currSymbol, shapeType, null); |
975 |
} |
976 |
|
977 |
public static ISymbolSelector createSymbolSelector(Object currSymbol, int shapeType, SelectorFilter filter) { |
978 |
ISymbolSelector selector = null;
|
979 |
|
980 |
// patch for backwards compatibility
|
981 |
// if (currSymbol instanceof FSymbol) {
|
982 |
// currSymbol = SymbologyFactory.deriveFSymbol((FSymbol) currSymbol);
|
983 |
// }
|
984 |
|
985 |
if (filter==null) |
986 |
selector = (shapeType == FShape.MULTI) ? |
987 |
new MultiShapeSymbolSelector(currSymbol) :
|
988 |
new SymbolSelector(currSymbol, shapeType, true); |
989 |
else
|
990 |
selector = (shapeType == FShape.MULTI) ? |
991 |
new MultiShapeSymbolSelector(currSymbol) :
|
992 |
new SymbolSelector(currSymbol, shapeType, filter, true); |
993 |
return selector;
|
994 |
} |
995 |
|
996 |
class SillyDragNDropAction implements MouseListener, MouseMotionListener { |
997 |
private boolean doDrop = false; |
998 |
private Object selected; |
999 |
private File sourceFolder; |
1000 |
|
1001 |
public void mouseClicked(MouseEvent e) { } |
1002 |
public void mouseEntered(MouseEvent e) { } |
1003 |
public void mouseExited(MouseEvent e) { } |
1004 |
|
1005 |
public void mousePressed(MouseEvent e) { |
1006 |
if (e.getSource().equals(getJListSymbols())) {
|
1007 |
selected = getJListSymbols().getSelectedValue(); |
1008 |
doDrop = selected!=null;
|
1009 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) libraryBrowser.getLastSelectedPathComponent(); |
1010 |
if (node.getUserObject() instanceof File) { |
1011 |
sourceFolder = (File) node.getUserObject();
|
1012 |
} |
1013 |
} |
1014 |
e.consume(); |
1015 |
} |
1016 |
|
1017 |
public void mouseReleased(MouseEvent e) { |
1018 |
if (doDrop && e.getSource().equals(getJListSymbols())) {
|
1019 |
Point p = new Point(getJListSymbols().getLocation().x-e.getPoint().x, getJListSymbols().getLocation().y+e.getPoint().y); |
1020 |
if (libraryBrowser.getBounds().contains(p)) {
|
1021 |
File destFolder = libraryBrowser.getElementBellow(p);
|
1022 |
if (destFolder != null) { |
1023 |
ISymbol sym = (ISymbol) selected; |
1024 |
int move = InputEvent.SHIFT_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; |
1025 |
// int copy = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
|
1026 |
|
1027 |
library.addElement(sym, sym.getDescription(), destFolder); |
1028 |
if ((e.getModifiers() & (move)) !=0) { |
1029 |
library.removeElement(sym, sourceFolder); |
1030 |
} |
1031 |
|
1032 |
} |
1033 |
libraryBrowser.refresh(); |
1034 |
} |
1035 |
|
1036 |
} |
1037 |
doDrop = false;
|
1038 |
} |
1039 |
|
1040 |
public void mouseDragged(MouseEvent e) { |
1041 |
if (e.getSource().equals(getJListSymbols())) {
|
1042 |
|
1043 |
Point p = new Point(getJListSymbols().getLocation().x-e.getPoint().x, getJListSymbols().getLocation().y+e.getPoint().y); |
1044 |
if (libraryBrowser.getBounds().contains(p)) {
|
1045 |
libraryBrowser.setSelectedElementBellow(p); |
1046 |
} |
1047 |
} |
1048 |
} |
1049 |
|
1050 |
public void mouseMoved(MouseEvent e) { |
1051 |
|
1052 |
} |
1053 |
|
1054 |
} |
1055 |
|
1056 |
} |