svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / SymbolEditor.java @ 43510
History | View | Annotate | Download (18.5 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.gui.styling; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.FlowLayout; |
29 |
import java.awt.event.ActionEvent; |
30 |
import java.awt.event.ActionListener; |
31 |
import java.lang.reflect.Constructor; |
32 |
import java.util.ArrayList; |
33 |
import java.util.Comparator; |
34 |
import java.util.Hashtable; |
35 |
import java.util.Iterator; |
36 |
import java.util.List; |
37 |
import java.util.Map; |
38 |
import java.util.TreeSet; |
39 |
|
40 |
import javax.swing.BorderFactory; |
41 |
import javax.swing.JComboBox; |
42 |
import javax.swing.JLabel; |
43 |
import javax.swing.JPanel; |
44 |
import javax.swing.JTabbedPane; |
45 |
|
46 |
import org.slf4j.Logger; |
47 |
import org.slf4j.LoggerFactory; |
48 |
|
49 |
import org.gvsig.andami.PluginServices; |
50 |
import org.gvsig.andami.messages.NotificationManager; |
51 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
52 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
53 |
import org.gvsig.app.gui.JComboBoxUnits; |
54 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
55 |
import org.gvsig.fmap.geom.GeometryLocator; |
56 |
import org.gvsig.fmap.geom.GeometryManager; |
57 |
import org.gvsig.fmap.geom.type.GeometryType; |
58 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
59 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
60 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
61 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
62 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
63 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
64 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
65 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
66 |
import org.gvsig.i18n.Messages; |
67 |
import org.gvsig.symbology.swing.SymbologySwingLocator; |
68 |
import org.gvsig.symbology.swing.SymbologySwingManager; |
69 |
|
70 |
/**
|
71 |
* Creates the panel that is used to control the properties of a symbol in
|
72 |
* order to modify or check them and to create a new one.
|
73 |
*
|
74 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
75 |
*
|
76 |
*/
|
77 |
public class SymbolEditor extends JPanel implements IWindow { |
78 |
private static final long serialVersionUID = 9209260593958625497L; |
79 |
|
80 |
private static final GeometryManager GEOMETRY_MANAGER = |
81 |
GeometryLocator.getGeometryManager(); |
82 |
|
83 |
private static final Logger LOG = |
84 |
LoggerFactory.getLogger(SymbolEditor.class); |
85 |
|
86 |
private WindowInfo wi;
|
87 |
private JPanel pnlWest = null; |
88 |
private JPanel pnlCenter = null; |
89 |
private JPanel pnlPreview = null; |
90 |
private JPanel pnlLayers = null; |
91 |
private AcceptCancelPanel okCancelPanel;
|
92 |
private ISymbol symbol;
|
93 |
private SymbolPreviewer symbolPreview = null; |
94 |
private JPanel pnlTypeAndUnits = null; |
95 |
private JComboBox cmbType; |
96 |
private JComboBoxUnits cmbUnits;
|
97 |
private JTabbedPane tabbedPane = null; |
98 |
private GeometryType shapeType;
|
99 |
private ActionListener cmbTypeActionListener; |
100 |
|
101 |
private AbstractTypeSymbolEditor[] tabs; |
102 |
private SymbolLayerManager layerManager;
|
103 |
private boolean replacing = false; |
104 |
private JComboBoxUnitsReferenceSystem cmbUnitsReferenceSystem;
|
105 |
|
106 |
private ISymbol oldSymbol;
|
107 |
|
108 |
private MapContextManager mapContextManager = MapContextLocator
|
109 |
.getMapContextManager(); |
110 |
|
111 |
|
112 |
public SymbolEditor(ISymbol symbol, GeometryType geometryType) {
|
113 |
super();
|
114 |
initialize(symbol, geometryType); |
115 |
} |
116 |
|
117 |
public SymbolEditor(ISymbol symbol, int shapeType) { |
118 |
super();
|
119 |
try {
|
120 |
GeometryType geometryType = GEOMETRY_MANAGER.getGeometryType(shapeType, SUBTYPES.GEOM2D); |
121 |
initialize(symbol, geometryType); |
122 |
} catch (GeometryTypeNotSupportedException e1) {
|
123 |
LOG.error("Impossible to get the geometry type", e1);
|
124 |
} catch (GeometryTypeNotValidException e1) {
|
125 |
LOG.error("Impossible to get the geometry type", e1);
|
126 |
} |
127 |
} |
128 |
|
129 |
|
130 |
/**
|
131 |
* Constructor method
|
132 |
*
|
133 |
* @param symbol ISymbol
|
134 |
* @param shapeType int
|
135 |
*/
|
136 |
private void initialize(ISymbol symbol, GeometryType shapeType) { |
137 |
////////// /-------------------------------------
|
138 |
// removing the Geometry.TYPES.TEXT: this code can not be executed
|
139 |
// if (shapeType == Geometry.TYPES.TEXT) {
|
140 |
//// this.symbol = symbol == null ? new SimpleTextSymbol(): symbol;
|
141 |
// this.symbol = symbol == null ? SymbologyLocator.getSymbologyManager().createSimpleTextSymbol(): symbol;
|
142 |
// } else {
|
143 |
////////// /-------------------------------------
|
144 |
|
145 |
if (!(symbol instanceof IMultiLayerSymbol)) { |
146 |
// this is a simple symbol (or null one); it will be
|
147 |
// converted to a multilayer one to accept layer addition
|
148 |
IMultiLayerSymbol nSym = |
149 |
mapContextManager.getSymbolManager() |
150 |
.createMultiLayerSymbol(shapeType.getType()); |
151 |
|
152 |
// if (!(symbol instanceof FSymbol)) {
|
153 |
nSym.addLayer(symbol); |
154 |
// }
|
155 |
|
156 |
if (symbol instanceof CartographicSupport) { |
157 |
CartographicSupport cs = (CartographicSupport) symbol; |
158 |
CartographicSupport nCs = (CartographicSupport) nSym; |
159 |
nCs.setReferenceSystem(cs.getReferenceSystem()); |
160 |
nCs.setUnit(cs.getUnit()); |
161 |
} |
162 |
|
163 |
this.symbol = nSym;
|
164 |
} else {
|
165 |
this.symbol = symbol;
|
166 |
} |
167 |
|
168 |
// apply units and reference system to comboboxes
|
169 |
if (this.symbol instanceof CartographicSupport) { |
170 |
CartographicSupport cs = (CartographicSupport) this.symbol;
|
171 |
getCmbUnits().setSelectedUnitIndex(cs.getUnit()); |
172 |
getCmbUnitsReferenceSystem(). |
173 |
setSelectedIndex(cs.getReferenceSystem()); |
174 |
|
175 |
} |
176 |
|
177 |
// }
|
178 |
try {
|
179 |
this.oldSymbol = (ISymbol) this.symbol.clone(); |
180 |
} catch (CloneNotSupportedException e) { |
181 |
NotificationManager.addWarning("Symbol layer", e);
|
182 |
} |
183 |
this.shapeType = shapeType;
|
184 |
initialize(); |
185 |
} |
186 |
|
187 |
/**
|
188 |
* This method initializes this
|
189 |
*
|
190 |
*/
|
191 |
private void initialize() { |
192 |
SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager(); |
193 |
cmbTypeActionListener = new ActionListener() { |
194 |
int prevIndex = -2; |
195 |
|
196 |
public void actionPerformed(ActionEvent e) { |
197 |
int index = getCmbType().getSelectedIndex();
|
198 |
if (prevIndex != index) {
|
199 |
// needs to refresh
|
200 |
prevIndex = index; |
201 |
|
202 |
AbstractTypeSymbolEditor options = (AbstractTypeSymbolEditor) getCmbType() |
203 |
.getSelectedItem(); |
204 |
|
205 |
////////// /-------------------------------------
|
206 |
if (layerManager!=null) { |
207 |
////////// /-------------------------------------
|
208 |
ISymbol l = layerManager.getSelectedLayer(); |
209 |
|
210 |
// if the symbol is not null and is it managed by the "options" class
|
211 |
// refresh the controls
|
212 |
if (l != null |
213 |
// && l.getClass().equals(options.getSymbolClass())) {
|
214 |
&& options.canManageSymbol(l)) { |
215 |
if (l instanceof CartographicSupport) { |
216 |
CartographicSupport cs = (CartographicSupport) l; |
217 |
getCmbUnits().setSelectedUnitIndex(cs.getUnit()); |
218 |
getCmbUnitsReferenceSystem().setSelectedIndex(cs.getReferenceSystem()); |
219 |
} |
220 |
options.refreshControls(l); |
221 |
} |
222 |
|
223 |
replaceOptions(options); |
224 |
////////// /-------------------------------------
|
225 |
} else {
|
226 |
replaceOptions(options); |
227 |
} |
228 |
////////// /-------------------------------------
|
229 |
|
230 |
} |
231 |
} |
232 |
}; |
233 |
|
234 |
Comparator tabComparator = new Comparator() { |
235 |
public int compare(Object o1, Object o2) { |
236 |
AbstractTypeSymbolEditor pnl1 = (AbstractTypeSymbolEditor) o1; |
237 |
AbstractTypeSymbolEditor pnl2 = (AbstractTypeSymbolEditor) o2; |
238 |
int result = pnl1.getName().compareTo(pnl2.getName());
|
239 |
return result;
|
240 |
} |
241 |
}; |
242 |
|
243 |
|
244 |
TreeSet set = new TreeSet(tabComparator); |
245 |
List editors = symbologySwingManager.getSymbolEditorClassesByGeometryType(shapeType);
|
246 |
Class[] constrLocator = new Class[] {SymbolEditor.class}; |
247 |
Object[] constrInitargs = new Object[] { this }; |
248 |
for (int i = 0; i < editors.size(); i++) { |
249 |
Class editorClass = (Class) editors.get(i); |
250 |
try {
|
251 |
Constructor c = editorClass.getConstructor(constrLocator);
|
252 |
AbstractTypeSymbolEditor instance = (AbstractTypeSymbolEditor) c.newInstance(constrInitargs); |
253 |
set.add(instance); |
254 |
} catch (Exception e) { |
255 |
NotificationManager.addError(Messages.getText("failed_installing_symbol_editor")+" " |
256 |
+editorClass.getName(), e); |
257 |
} |
258 |
}; |
259 |
tabs = (AbstractTypeSymbolEditor[]) set
|
260 |
.toArray(new AbstractTypeSymbolEditor[0]); |
261 |
|
262 |
this.setLayout(new BorderLayout()); |
263 |
this.add(getPnlWest(), BorderLayout.WEST); |
264 |
this.add(getPnlCenter(), BorderLayout.CENTER); |
265 |
this.add(getOkCancelPanel(), BorderLayout.SOUTH); |
266 |
|
267 |
cmbTypeActionListener.actionPerformed(null);
|
268 |
refresh(); |
269 |
} |
270 |
/**
|
271 |
* Returns an array of tabs. The value of this array will depend on the
|
272 |
* symbol selected. For example, if the symbol is composed by lines this
|
273 |
* method will return tha tabs that allow the user to modify a simple line
|
274 |
* symbol(in this case simple line and arrow decorator tabs)
|
275 |
* @param sym
|
276 |
* @return tabs[] AbstractTypeSymbolEditor[]
|
277 |
*/
|
278 |
private AbstractTypeSymbolEditor getOptionsForSymbol(ISymbol sym) {
|
279 |
if (sym == null) { |
280 |
return tabs[0]; |
281 |
} |
282 |
for (int i = 0; i < tabs.length; i++) { |
283 |
// if (tabs[i].getSymbolClass().equals(sym.getClass())) {
|
284 |
if (tabs[i].canManageSymbol(sym)) {
|
285 |
return tabs[i];
|
286 |
} |
287 |
} |
288 |
return tabs[0]; |
289 |
} |
290 |
/**
|
291 |
* Initializes the OkCancel panel where the accept and cancel buttons
|
292 |
* will be placed
|
293 |
* @return okCancelPanel AcceptCancelPanel
|
294 |
*/
|
295 |
private AcceptCancelPanel getOkCancelPanel() {
|
296 |
if (okCancelPanel == null) { |
297 |
ActionListener action = new ActionListener() { |
298 |
public void actionPerformed(ActionEvent e) { |
299 |
if ("CANCEL".equals(e.getActionCommand())) { |
300 |
symbol = oldSymbol; |
301 |
} |
302 |
PluginServices.getMDIManager().closeWindow( |
303 |
SymbolEditor.this); |
304 |
} |
305 |
}; |
306 |
okCancelPanel = new AcceptCancelPanel(action, action);
|
307 |
} |
308 |
return okCancelPanel;
|
309 |
} |
310 |
|
311 |
public WindowInfo getWindowInfo() {
|
312 |
if (wi == null) { |
313 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
314 |
wi.setWidth(650);
|
315 |
wi.setHeight(400);
|
316 |
wi.setTitle(Messages.getText("symbol_property_editor"));
|
317 |
} |
318 |
return wi;
|
319 |
} |
320 |
|
321 |
public ISymbol getSymbol() {
|
322 |
if (symbol instanceof CartographicSupport) { |
323 |
CartographicSupport cs = (CartographicSupport) symbol; |
324 |
cs.setUnit(getUnit()); |
325 |
cs.setReferenceSystem(getReferenceSystem()); |
326 |
} |
327 |
//
|
328 |
// if (symbol instanceof MultiLayerLineSymbol) {
|
329 |
// MultiLayerLineSymbol mLineSym = (MultiLayerLineSymbol) symbol;
|
330 |
// double lineWidth = 0;
|
331 |
// for (int i = 0; i < mLineSym.getLayerCount(); i++) {
|
332 |
// lineWidth = Math.max(lineWidth, ((ILineSymbol) mLineSym.getLayer(i)).getLineWidth());
|
333 |
// }
|
334 |
//
|
335 |
// if (mLineSym.getLineWidth() != lineWidth)
|
336 |
// mLineSym.setLineWidth(lineWidth);
|
337 |
// }
|
338 |
return symbol;
|
339 |
} |
340 |
/**
|
341 |
* Initializes the west panel
|
342 |
* @return
|
343 |
*/
|
344 |
private JPanel getPnlWest() { |
345 |
if (pnlWest == null) { |
346 |
pnlWest = new JPanel(); |
347 |
pnlWest.setLayout(new BorderLayout()); |
348 |
pnlWest.add(getPnlPreview(), java.awt.BorderLayout.NORTH); |
349 |
////////// /-------------------------------------
|
350 |
if (symbol instanceof IMultiLayerSymbol) { |
351 |
////////// /-------------------------------------
|
352 |
|
353 |
|
354 |
pnlWest.add(getPnlLayers(), java.awt.BorderLayout.SOUTH); |
355 |
|
356 |
////////// /-------------------------------------
|
357 |
} // otherwise, no layer manager needed
|
358 |
////////// /-------------------------------------
|
359 |
} |
360 |
return pnlWest;
|
361 |
} |
362 |
/**
|
363 |
* Initializes the center panel that shows the properties of a symbol.
|
364 |
*
|
365 |
* @return pnlCenter JPanel
|
366 |
*/
|
367 |
private JPanel getPnlCenter() { |
368 |
if (pnlCenter == null) { |
369 |
pnlCenter = new JPanel(new BorderLayout()); |
370 |
pnlCenter.setBorder(BorderFactory.createTitledBorder(null, |
371 |
Messages.getText("properties")));
|
372 |
pnlCenter.add(getPnlTypeAndUnits(), java.awt.BorderLayout.NORTH); |
373 |
} |
374 |
return pnlCenter;
|
375 |
} |
376 |
/**
|
377 |
* Initializes the preview panel that allows the user to see a previsualization
|
378 |
* of the final symbol
|
379 |
*
|
380 |
* @return pnlPreview JPanel
|
381 |
*/
|
382 |
private JPanel getPnlPreview() { |
383 |
if (pnlPreview == null) { |
384 |
pnlPreview = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
385 |
pnlPreview.setBorder(BorderFactory.createTitledBorder(null, |
386 |
Messages.getText("preview")));
|
387 |
pnlPreview.add(getSymbolPreviewer()); |
388 |
} |
389 |
return pnlPreview;
|
390 |
} |
391 |
/**
|
392 |
* Initializes the Layers panel that shows the different layers created that
|
393 |
* compose a symbol.
|
394 |
* @return pnlLayers JPanel
|
395 |
*/
|
396 |
private JPanel getPnlLayers() { |
397 |
if (pnlLayers == null) { |
398 |
pnlLayers = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
399 |
pnlLayers.setBorder(BorderFactory.createTitledBorder(null, |
400 |
Messages.getText("layers")));
|
401 |
pnlLayers.add(getLayerManager()); |
402 |
} |
403 |
return pnlLayers;
|
404 |
} |
405 |
/**
|
406 |
* Obtains the layer manager used in the panel that shows the different layers
|
407 |
* that compose the symbol.
|
408 |
*
|
409 |
* @return layerManager SymbolLayerManager
|
410 |
*/
|
411 |
private SymbolLayerManager getLayerManager() {
|
412 |
if (layerManager == null) { |
413 |
layerManager = new SymbolLayerManager(this); |
414 |
} |
415 |
return layerManager;
|
416 |
} |
417 |
/**
|
418 |
* Obtains the symbol previewer used in the panel that shows the previsualization
|
419 |
* of the final symbol.
|
420 |
*
|
421 |
* @return symbolPreview getSymbolPreviewer
|
422 |
*/
|
423 |
private SymbolPreviewer getSymbolPreviewer() {
|
424 |
if (symbolPreview == null) { |
425 |
symbolPreview = new SymbolPreviewer();
|
426 |
symbolPreview.setPreferredSize(new Dimension(150, 100)); |
427 |
|
428 |
} |
429 |
return symbolPreview;
|
430 |
} |
431 |
/**
|
432 |
* Initializes the type and units panel where two Jcomboboxes will be placed
|
433 |
* in order to change the type and the units used in the map.
|
434 |
*
|
435 |
* @return pnlTypeAndUnits JPanel
|
436 |
*/
|
437 |
private JPanel getPnlTypeAndUnits() { |
438 |
if (pnlTypeAndUnits == null) { |
439 |
pnlTypeAndUnits = new JPanel(); |
440 |
pnlTypeAndUnits.setLayout(new BorderLayout()); |
441 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
442 |
aux.add(new JLabel(Messages.getText("type"))); |
443 |
aux.add(getCmbType()); |
444 |
pnlTypeAndUnits.add(aux, BorderLayout.WEST);
|
445 |
|
446 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
447 |
aux.add(new JLabel(Messages.getText("units"))); |
448 |
aux.add(getCmbUnits()); |
449 |
aux.add(getCmbUnitsReferenceSystem()); |
450 |
pnlTypeAndUnits.add(aux, BorderLayout.EAST);
|
451 |
|
452 |
} |
453 |
return pnlTypeAndUnits;
|
454 |
} |
455 |
/**
|
456 |
* Obtains the JCombobox to select the reference unit to be used in the
|
457 |
* final representation of the map in this case there are two options (in
|
458 |
* the paper and in the map).
|
459 |
* @return
|
460 |
*/
|
461 |
private JComboBoxUnitsReferenceSystem getCmbUnitsReferenceSystem() {
|
462 |
if (cmbUnitsReferenceSystem == null) { |
463 |
cmbUnitsReferenceSystem = new JComboBoxUnitsReferenceSystem();
|
464 |
|
465 |
} |
466 |
|
467 |
return cmbUnitsReferenceSystem;
|
468 |
} |
469 |
/**
|
470 |
* Returns the Jcombobox used to select the reference unit (centimeters,
|
471 |
* milimeters and so on) to be used in the final representation of the map.
|
472 |
*
|
473 |
* @return cmbUnits JUnitsComboBox
|
474 |
*/
|
475 |
private JComboBoxUnits getCmbUnits() {
|
476 |
if (cmbUnits == null) { |
477 |
cmbUnits = new JComboBoxUnits();
|
478 |
} |
479 |
return cmbUnits;
|
480 |
} |
481 |
/**
|
482 |
* Returns the option selected in the reference unit Jcombobox
|
483 |
*
|
484 |
*/
|
485 |
public int getUnit() { |
486 |
return getCmbUnits().getSelectedUnitIndex();
|
487 |
} |
488 |
|
489 |
public int getReferenceSystem() { |
490 |
return getCmbUnitsReferenceSystem().getSelectedIndex();
|
491 |
} |
492 |
/**
|
493 |
* Returns the Jcombobox used in the panel to select the type of symbol.
|
494 |
*
|
495 |
* @return cmbType JComboBox
|
496 |
*/
|
497 |
private JComboBox getCmbType() { |
498 |
if (cmbType == null) { |
499 |
cmbType = new JComboBox(tabs); |
500 |
cmbType.addActionListener(cmbTypeActionListener); |
501 |
} |
502 |
return cmbType;
|
503 |
} |
504 |
/**
|
505 |
* Sets a layer to a symbol in order to create a final symbol composed
|
506 |
* by different layers.
|
507 |
*
|
508 |
* @param layer
|
509 |
*/
|
510 |
protected void setLayerToSymbol(ISymbol layer) { |
511 |
int i = getLayerManager().getSelectedLayerIndex();
|
512 |
IMultiLayerSymbol s = (IMultiLayerSymbol) symbol; |
513 |
if (i >= 0 && i < s.getLayerCount()) { |
514 |
s.setLayer(s.getLayerCount() - 1 - i, layer);
|
515 |
|
516 |
} |
517 |
refresh(); |
518 |
} |
519 |
|
520 |
public void refresh() { |
521 |
getSymbolPreviewer().setSymbol(symbol); |
522 |
doLayout(); |
523 |
repaint(); |
524 |
} |
525 |
|
526 |
/**
|
527 |
* <p>
|
528 |
* Returns the type of the symbol that this panels is created for.<br>
|
529 |
* </p>
|
530 |
* <p>
|
531 |
* Possible values returned by this method are
|
532 |
* <ol>
|
533 |
* <li> <b> Geometry.TYPES.POINT </b>, for maker symbols </li>
|
534 |
* <li> <b> Geometry.TYPES.SURFACE </b>, for fill symbols </li>
|
535 |
* <li> <b> Geometry.TYPES.CURVE </b>, for line symbols (not yet implemented) </li>
|
536 |
* <li> <b> Geometry.TYPES.TEXT </b>, for text symbols (not yet implemented) </li>
|
537 |
* <li> maybe some other in the future </li>
|
538 |
* </ol>
|
539 |
* </p>
|
540 |
*
|
541 |
* @return
|
542 |
*/
|
543 |
public int getShapeType() { |
544 |
return shapeType.getType();
|
545 |
} |
546 |
/**
|
547 |
* Obtains a new layer
|
548 |
*
|
549 |
* @return sym ISymbol
|
550 |
*/
|
551 |
public ISymbol getNewLayer() {
|
552 |
ISymbol sym = ((AbstractTypeSymbolEditor) getCmbType().getSelectedItem()) |
553 |
.getLayer(); |
554 |
|
555 |
return sym;
|
556 |
} |
557 |
|
558 |
private void replaceOptions(AbstractTypeSymbolEditor options) { |
559 |
if (!replacing) {
|
560 |
replacing = true;
|
561 |
if (tabbedPane != null) { |
562 |
getPnlCenter().remove(tabbedPane); |
563 |
} |
564 |
JPanel[] tabs = options.getTabs(); |
565 |
tabbedPane = new JTabbedPane(); |
566 |
tabbedPane.setPreferredSize(new Dimension(300, 300)); |
567 |
for (int i = 0; i < tabs.length; i++) { |
568 |
tabbedPane.addTab(tabs[i].getName(), tabs[i]); |
569 |
} |
570 |
getPnlCenter().add(tabbedPane, BorderLayout.CENTER);
|
571 |
getPnlCenter().doLayout(); |
572 |
replacing = false;
|
573 |
} |
574 |
} |
575 |
|
576 |
|
577 |
public void setOptionsPageFor(ISymbol symbol) { |
578 |
AbstractTypeSymbolEditor options = getOptionsForSymbol(symbol); |
579 |
|
580 |
options.refreshControls(symbol); |
581 |
getCmbType().setSelectedItem(options); |
582 |
} |
583 |
/**
|
584 |
* Obtains the units to be used for the reference system.
|
585 |
*
|
586 |
*/
|
587 |
public int getUnitsReferenceSystem() { |
588 |
return cmbUnitsReferenceSystem.getSelectedIndex();
|
589 |
} |
590 |
|
591 |
/**
|
592 |
* @deprecated use SymblogySwingManager
|
593 |
*/
|
594 |
public static void addSymbolEditorPanel(Class<? extends TypeSymbolEditor> symbolEditor, int shapeType) { |
595 |
SymbologySwingManager manager = SymbologySwingLocator.getSwingManager(); |
596 |
manager.registerSymbolEditor(symbolEditor, shapeType); |
597 |
} |
598 |
|
599 |
/**
|
600 |
* @deprecated use SymblogySwingManager
|
601 |
*/
|
602 |
private static List getSymbolsByType(GeometryType geometryType){ |
603 |
SymbologySwingManager manager = SymbologySwingLocator.getSwingManager(); |
604 |
return manager.getSymbolEditorClassesByGeometryType(geometryType);
|
605 |
} |
606 |
|
607 |
public Object getWindowProfile() { |
608 |
return WindowInfo.DIALOG_PROFILE;
|
609 |
} |
610 |
|
611 |
} |