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