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