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