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 @ 47464
History | View | Annotate | Download (19.7 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 |
import javax.swing.SwingUtilities; |
46 |
import org.apache.commons.lang3.mutable.MutableObject; |
47 |
|
48 |
import org.slf4j.Logger; |
49 |
import org.slf4j.LoggerFactory; |
50 |
|
51 |
import org.gvsig.andami.PluginServices; |
52 |
import org.gvsig.andami.messages.NotificationManager; |
53 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
54 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
55 |
import org.gvsig.app.gui.JComboBoxUnits; |
56 |
import org.gvsig.fmap.dal.feature.Feature; |
57 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
58 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
59 |
import org.gvsig.fmap.geom.GeometryLocator; |
60 |
import org.gvsig.fmap.geom.GeometryManager; |
61 |
import org.gvsig.fmap.geom.type.GeometryType; |
62 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
63 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
64 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
65 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
67 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
68 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
69 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
70 |
import org.gvsig.i18n.Messages; |
71 |
import org.gvsig.symbology.swing.SymbologySwingLocator; |
72 |
import org.gvsig.symbology.swing.SymbologySwingManager; |
73 |
|
74 |
/**
|
75 |
* Creates the panel that is used to control the properties of a symbol in
|
76 |
* order to modify or check them and to create a new one.
|
77 |
*
|
78 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
79 |
*
|
80 |
*/
|
81 |
public class SymbolEditor extends JPanel implements IWindow { |
82 |
private static final long serialVersionUID = 9209260593958625497L; |
83 |
|
84 |
private static final GeometryManager GEOMETRY_MANAGER = |
85 |
GeometryLocator.getGeometryManager(); |
86 |
|
87 |
private static final Logger LOG = |
88 |
LoggerFactory.getLogger(SymbolEditor.class); |
89 |
|
90 |
private WindowInfo wi;
|
91 |
private JPanel pnlWest = null; |
92 |
private JPanel pnlCenter = null; |
93 |
private JPanel pnlPreview = null; |
94 |
private JPanel pnlLayers = null; |
95 |
private AcceptCancelPanel okCancelPanel;
|
96 |
private ISymbol symbol;
|
97 |
private SymbolPreviewer symbolPreview = null; |
98 |
private JPanel pnlTypeAndUnits = null; |
99 |
private JComboBox cmbType; |
100 |
private JComboBoxUnits cmbUnits;
|
101 |
private JTabbedPane tabbedPane = null; |
102 |
private GeometryType shapeType;
|
103 |
private ActionListener cmbTypeActionListener; |
104 |
|
105 |
private AbstractTypeSymbolEditor[] tabs; |
106 |
private SymbolLayerManager layerManager;
|
107 |
private boolean replacing = false; |
108 |
private JComboBoxUnitsReferenceSystem cmbUnitsReferenceSystem;
|
109 |
|
110 |
private ISymbol oldSymbol;
|
111 |
|
112 |
private MapContextManager mapContextManager = MapContextLocator
|
113 |
.getMapContextManager(); |
114 |
private transient FeatureStore featureStore; |
115 |
private transient MutableObject<Feature> sampleFeature; |
116 |
|
117 |
public SymbolEditor(ISymbol symbol, GeometryType geometryType) {
|
118 |
super();
|
119 |
initialize(symbol, geometryType); |
120 |
} |
121 |
|
122 |
public SymbolEditor(ISymbol symbol, int shapeType) { |
123 |
super();
|
124 |
try {
|
125 |
GeometryType geometryType = GEOMETRY_MANAGER.getGeometryType(shapeType, SUBTYPES.GEOM2D); |
126 |
initialize(symbol, geometryType); |
127 |
} catch (GeometryTypeNotSupportedException e1) {
|
128 |
LOG.error("Impossible to get the geometry type", e1);
|
129 |
} catch (GeometryTypeNotValidException e1) {
|
130 |
LOG.error("Impossible to get the geometry type", e1);
|
131 |
} |
132 |
} |
133 |
|
134 |
|
135 |
/**
|
136 |
* Constructor method
|
137 |
*
|
138 |
* @param symbol ISymbol
|
139 |
* @param shapeType int
|
140 |
*/
|
141 |
private void initialize(ISymbol symbol, GeometryType shapeType) { |
142 |
////////// /-------------------------------------
|
143 |
// removing the Geometry.TYPES.TEXT: this code can not be executed
|
144 |
// if (shapeType == Geometry.TYPES.TEXT) {
|
145 |
//// this.symbol = symbol == null ? new SimpleTextSymbol(): symbol;
|
146 |
// this.symbol = symbol == null ? SymbologyLocator.getSymbologyManager().createSimpleTextSymbol(): symbol;
|
147 |
// } else {
|
148 |
////////// /-------------------------------------
|
149 |
|
150 |
if (!(symbol instanceof IMultiLayerSymbol)) { |
151 |
// this is a simple symbol (or null one); it will be
|
152 |
// converted to a multilayer one to accept layer addition
|
153 |
IMultiLayerSymbol nSym = |
154 |
mapContextManager.getSymbolManager() |
155 |
.createMultiLayerSymbol(shapeType.getType()); |
156 |
|
157 |
// if (!(symbol instanceof FSymbol)) {
|
158 |
nSym.addLayer(symbol); |
159 |
// }
|
160 |
|
161 |
if (symbol instanceof CartographicSupport) { |
162 |
CartographicSupport cs = (CartographicSupport) symbol; |
163 |
CartographicSupport nCs = (CartographicSupport) nSym; |
164 |
nCs.setReferenceSystem(cs.getReferenceSystem()); |
165 |
nCs.setUnit(cs.getUnit()); |
166 |
} |
167 |
|
168 |
this.symbol = nSym;
|
169 |
} else {
|
170 |
this.symbol = symbol;
|
171 |
} |
172 |
|
173 |
// apply units and reference system to comboboxes
|
174 |
if (this.symbol instanceof CartographicSupport) { |
175 |
CartographicSupport cs = (CartographicSupport) this.symbol;
|
176 |
getCmbUnits().setSelectedUnitIndex(cs.getUnit()); |
177 |
getCmbUnitsReferenceSystem(). |
178 |
setSelectedIndex(cs.getReferenceSystem()); |
179 |
|
180 |
} |
181 |
|
182 |
// }
|
183 |
try {
|
184 |
this.oldSymbol = (ISymbol) this.symbol.clone(); |
185 |
} catch (CloneNotSupportedException e) { |
186 |
NotificationManager.addWarning("Symbol layer", e);
|
187 |
} |
188 |
this.shapeType = shapeType;
|
189 |
initialize(); |
190 |
} |
191 |
|
192 |
/**
|
193 |
* This method initializes this
|
194 |
*
|
195 |
*/
|
196 |
private void initialize() { |
197 |
SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager(); |
198 |
cmbTypeActionListener = new ActionListener() { |
199 |
int prevIndex = -2; |
200 |
|
201 |
public void actionPerformed(ActionEvent e) { |
202 |
int index = getCmbType().getSelectedIndex();
|
203 |
if (prevIndex != index) {
|
204 |
// needs to refresh
|
205 |
prevIndex = index; |
206 |
|
207 |
AbstractTypeSymbolEditor options = (AbstractTypeSymbolEditor) getCmbType() |
208 |
.getSelectedItem(); |
209 |
|
210 |
////////// /-------------------------------------
|
211 |
if (layerManager!=null) { |
212 |
////////// /-------------------------------------
|
213 |
ISymbol l = layerManager.getSelectedLayer(); |
214 |
|
215 |
// if the symbol is not null and is it managed by the "options" class
|
216 |
// refresh the controls
|
217 |
if (l != null |
218 |
// && l.getClass().equals(options.getSymbolClass())) {
|
219 |
&& options.canManageSymbol(l)) { |
220 |
if (l instanceof CartographicSupport) { |
221 |
CartographicSupport cs = (CartographicSupport) l; |
222 |
getCmbUnits().setSelectedUnitIndex(cs.getUnit()); |
223 |
getCmbUnitsReferenceSystem().setSelectedIndex(cs.getReferenceSystem()); |
224 |
} |
225 |
options.refreshControls(l); |
226 |
} |
227 |
|
228 |
replaceOptions(options); |
229 |
////////// /-------------------------------------
|
230 |
} else {
|
231 |
replaceOptions(options); |
232 |
} |
233 |
////////// /-------------------------------------
|
234 |
|
235 |
} |
236 |
} |
237 |
}; |
238 |
|
239 |
Comparator tabComparator = new Comparator() { |
240 |
public int compare(Object o1, Object o2) { |
241 |
AbstractTypeSymbolEditor pnl1 = (AbstractTypeSymbolEditor) o1; |
242 |
AbstractTypeSymbolEditor pnl2 = (AbstractTypeSymbolEditor) o2; |
243 |
int result = pnl1.getName().compareTo(pnl2.getName());
|
244 |
return result;
|
245 |
} |
246 |
}; |
247 |
|
248 |
|
249 |
TreeSet set = new TreeSet(tabComparator); |
250 |
List editors = symbologySwingManager.getSymbolEditorClassesByGeometryType(shapeType);
|
251 |
Class[] constrLocator = new Class[] {SymbolEditor.class}; |
252 |
Object[] constrInitargs = new Object[] { this }; |
253 |
for (int i = 0; i < editors.size(); i++) { |
254 |
Class editorClass = (Class) editors.get(i); |
255 |
try {
|
256 |
Constructor c = editorClass.getConstructor(constrLocator);
|
257 |
AbstractTypeSymbolEditor instance = (AbstractTypeSymbolEditor) c.newInstance(constrInitargs); |
258 |
instance.setFeatureStore(featureStore); |
259 |
set.add(instance); |
260 |
} catch (Exception e) { |
261 |
NotificationManager.addError(Messages.getText("failed_installing_symbol_editor")+" " |
262 |
+editorClass.getName(), e); |
263 |
} |
264 |
}; |
265 |
tabs = (AbstractTypeSymbolEditor[]) set
|
266 |
.toArray(new AbstractTypeSymbolEditor[0]); |
267 |
|
268 |
this.setLayout(new BorderLayout()); |
269 |
this.add(getPnlWest(), BorderLayout.WEST); |
270 |
this.add(getPnlCenter(), BorderLayout.CENTER); |
271 |
this.add(getOkCancelPanel(), BorderLayout.SOUTH); |
272 |
|
273 |
cmbTypeActionListener.actionPerformed(null);
|
274 |
refresh(); |
275 |
} |
276 |
/**
|
277 |
* Returns an array of tabs. The value of this array will depend on the
|
278 |
* symbol selected. For example, if the symbol is composed by lines this
|
279 |
* method will return tha tabs that allow the user to modify a simple line
|
280 |
* symbol(in this case simple line and arrow decorator tabs)
|
281 |
* @param sym
|
282 |
* @return tabs[] AbstractTypeSymbolEditor[]
|
283 |
*/
|
284 |
private AbstractTypeSymbolEditor getOptionsForSymbol(ISymbol sym) {
|
285 |
if (sym == null) { |
286 |
return tabs[0]; |
287 |
} |
288 |
for (int i = 0; i < tabs.length; i++) { |
289 |
// if (tabs[i].getSymbolClass().equals(sym.getClass())) {
|
290 |
if (tabs[i].canManageSymbol(sym)) {
|
291 |
return tabs[i];
|
292 |
} |
293 |
} |
294 |
return tabs[0]; |
295 |
} |
296 |
/**
|
297 |
* Initializes the OkCancel panel where the accept and cancel buttons
|
298 |
* will be placed
|
299 |
* @return okCancelPanel AcceptCancelPanel
|
300 |
*/
|
301 |
private AcceptCancelPanel getOkCancelPanel() {
|
302 |
if (okCancelPanel == null) { |
303 |
ActionListener action = new ActionListener() { |
304 |
public void actionPerformed(ActionEvent e) { |
305 |
if ("CANCEL".equals(e.getActionCommand())) { |
306 |
symbol = oldSymbol; |
307 |
} |
308 |
PluginServices.getMDIManager().closeWindow( |
309 |
SymbolEditor.this); |
310 |
} |
311 |
}; |
312 |
okCancelPanel = new AcceptCancelPanel(action, action);
|
313 |
} |
314 |
return okCancelPanel;
|
315 |
} |
316 |
|
317 |
public WindowInfo getWindowInfo() {
|
318 |
if (wi == null) { |
319 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
320 |
wi.setWidth(750);
|
321 |
wi.setHeight(500);
|
322 |
wi.setTitle(Messages.getText("symbol_property_editor"));
|
323 |
} |
324 |
return wi;
|
325 |
} |
326 |
|
327 |
public ISymbol getSymbol() {
|
328 |
if (symbol instanceof CartographicSupport) { |
329 |
CartographicSupport cs = (CartographicSupport) symbol; |
330 |
cs.setUnit(getUnit()); |
331 |
cs.setReferenceSystem(getReferenceSystem()); |
332 |
} |
333 |
//
|
334 |
// if (symbol instanceof MultiLayerLineSymbol) {
|
335 |
// MultiLayerLineSymbol mLineSym = (MultiLayerLineSymbol) symbol;
|
336 |
// double lineWidth = 0;
|
337 |
// for (int i = 0; i < mLineSym.getLayerCount(); i++) {
|
338 |
// lineWidth = Math.max(lineWidth, ((ILineSymbol) mLineSym.getLayer(i)).getLineWidth());
|
339 |
// }
|
340 |
//
|
341 |
// if (mLineSym.getLineWidth() != lineWidth)
|
342 |
// mLineSym.setLineWidth(lineWidth);
|
343 |
// }
|
344 |
return symbol;
|
345 |
} |
346 |
/**
|
347 |
* Initializes the west panel
|
348 |
* @return
|
349 |
*/
|
350 |
private JPanel getPnlWest() { |
351 |
if (pnlWest == null) { |
352 |
pnlWest = new JPanel(); |
353 |
pnlWest.setLayout(new BorderLayout()); |
354 |
pnlWest.add(getPnlPreview(), java.awt.BorderLayout.NORTH); |
355 |
////////// /-------------------------------------
|
356 |
if (symbol instanceof IMultiLayerSymbol) { |
357 |
////////// /-------------------------------------
|
358 |
|
359 |
|
360 |
pnlWest.add(getPnlLayers(), java.awt.BorderLayout.SOUTH); |
361 |
|
362 |
////////// /-------------------------------------
|
363 |
} // otherwise, no layer manager needed
|
364 |
////////// /-------------------------------------
|
365 |
} |
366 |
return pnlWest;
|
367 |
} |
368 |
/**
|
369 |
* Initializes the center panel that shows the properties of a symbol.
|
370 |
*
|
371 |
* @return pnlCenter JPanel
|
372 |
*/
|
373 |
private JPanel getPnlCenter() { |
374 |
if (pnlCenter == null) { |
375 |
pnlCenter = new JPanel(new BorderLayout()); |
376 |
pnlCenter.setBorder(BorderFactory.createTitledBorder(null, |
377 |
Messages.getText("properties")));
|
378 |
pnlCenter.add(getPnlTypeAndUnits(), java.awt.BorderLayout.NORTH); |
379 |
} |
380 |
return pnlCenter;
|
381 |
} |
382 |
/**
|
383 |
* Initializes the preview panel that allows the user to see a previsualization
|
384 |
* of the final symbol
|
385 |
*
|
386 |
* @return pnlPreview JPanel
|
387 |
*/
|
388 |
private JPanel getPnlPreview() { |
389 |
if (pnlPreview == null) { |
390 |
pnlPreview = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
391 |
pnlPreview.setBorder(BorderFactory.createTitledBorder(null, |
392 |
Messages.getText("preview")));
|
393 |
pnlPreview.add(getSymbolPreviewer()); |
394 |
} |
395 |
return pnlPreview;
|
396 |
} |
397 |
/**
|
398 |
* Initializes the Layers panel that shows the different layers created that
|
399 |
* compose a symbol.
|
400 |
* @return pnlLayers JPanel
|
401 |
*/
|
402 |
private JPanel getPnlLayers() { |
403 |
if (pnlLayers == null) { |
404 |
pnlLayers = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
405 |
pnlLayers.setBorder(BorderFactory.createTitledBorder(null, |
406 |
Messages.getText("layers")));
|
407 |
pnlLayers.add(getLayerManager()); |
408 |
} |
409 |
return pnlLayers;
|
410 |
} |
411 |
/**
|
412 |
* Obtains the layer manager used in the panel that shows the different layers
|
413 |
* that compose the symbol.
|
414 |
*
|
415 |
* @return layerManager SymbolLayerManager
|
416 |
*/
|
417 |
private SymbolLayerManager getLayerManager() {
|
418 |
if (layerManager == null) { |
419 |
layerManager = new SymbolLayerManager(this); |
420 |
} |
421 |
return layerManager;
|
422 |
} |
423 |
/**
|
424 |
* Obtains the symbol previewer used in the panel that shows the previsualization
|
425 |
* of the final symbol.
|
426 |
*
|
427 |
* @return symbolPreview getSymbolPreviewer
|
428 |
*/
|
429 |
private SymbolPreviewer getSymbolPreviewer() {
|
430 |
if (symbolPreview == null) { |
431 |
symbolPreview = new SymbolPreviewer(getSampleFeature());
|
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 |
if( this.featureStore!=null ) { |
620 |
this.sampleFeature.setValue(this.featureStore.getSampleFeature()); |
621 |
for (AbstractTypeSymbolEditor editor : tabs) {
|
622 |
editor.setFeatureStore(this.featureStore);
|
623 |
} |
624 |
} |
625 |
} |
626 |
|
627 |
public MutableObject<Feature> getSampleFeature() {
|
628 |
if( this.sampleFeature == null ) { |
629 |
this.sampleFeature = new MutableObject(); |
630 |
if( this.featureStore!=null ) { |
631 |
this.sampleFeature.setValue(this.featureStore.getSampleFeature()); |
632 |
} |
633 |
} |
634 |
return this.sampleFeature; |
635 |
} |
636 |
} |