root / branches / v2_0_0_prep / libraries / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / MultiShapeSymbolSelector.java @ 38781
History | View | Annotate | Download (4.98 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.app.gui.styling; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
|
45 |
import javax.swing.JPanel; |
46 |
import javax.swing.JTabbedPane; |
47 |
|
48 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
49 |
import org.gvsig.app.project.documents.view.legend.gui.ISymbolSelector; |
50 |
import org.gvsig.fmap.geom.Geometry; |
51 |
import org.gvsig.i18n.Messages; |
52 |
import org.gvsig.symbology.SymbologyLocator; |
53 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol; |
54 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
55 |
//import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol;
|
56 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
57 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
58 |
|
59 |
|
60 |
public class MultiShapeSymbolSelector extends JPanel implements ISymbolSelector { |
61 |
/**
|
62 |
*
|
63 |
*/
|
64 |
private static final long serialVersionUID = 3967550608736418084L; |
65 |
private SymbolSelector markerSelector;
|
66 |
private SymbolSelector lineSelector;
|
67 |
private SymbolSelector fillSelector;
|
68 |
private WindowInfo wi;
|
69 |
private JTabbedPane tabbedPane; |
70 |
|
71 |
public static ISymbolSelector createSymbolBrowser() { |
72 |
WindowInfo winfo = new WindowInfo(WindowInfo.RESIZABLE|WindowInfo.MAXIMIZABLE|WindowInfo.ICONIFIABLE);
|
73 |
winfo.setWidth(706);
|
74 |
winfo.setHeight(500);
|
75 |
winfo.setTitle(Messages.getText("symbols_browser"));
|
76 |
return new MultiShapeSymbolSelector(winfo); |
77 |
} |
78 |
|
79 |
private MultiShapeSymbolSelector(WindowInfo wi) {
|
80 |
this((Object)null); |
81 |
this.wi = wi;
|
82 |
} |
83 |
|
84 |
MultiShapeSymbolSelector(Object currSymbol) {
|
85 |
IMultiShapeSymbol sym = (IMultiShapeSymbol) currSymbol; |
86 |
if (sym == null) { |
87 |
markerSelector = (SymbolSelector) SymbolSelector |
88 |
.createSymbolSelector(null, Geometry.TYPES.POINT);
|
89 |
lineSelector = (SymbolSelector) SymbolSelector |
90 |
.createSymbolSelector(null, Geometry.TYPES.CURVE);
|
91 |
fillSelector = (SymbolSelector) SymbolSelector |
92 |
.createSymbolSelector(null, Geometry.TYPES.SURFACE);
|
93 |
} else {
|
94 |
markerSelector = (SymbolSelector) SymbolSelector |
95 |
.createSymbolSelector(sym.getMarkerSymbol(), |
96 |
Geometry.TYPES.POINT); |
97 |
lineSelector = (SymbolSelector) SymbolSelector |
98 |
.createSymbolSelector(sym.getLineSymbol(), |
99 |
Geometry.TYPES.CURVE); |
100 |
fillSelector = (SymbolSelector) SymbolSelector |
101 |
.createSymbolSelector(sym.getFillSymbol(), |
102 |
Geometry.TYPES.SURFACE); |
103 |
} |
104 |
initialize(); |
105 |
} |
106 |
|
107 |
|
108 |
private void initialize() { |
109 |
setLayout(new BorderLayout()); |
110 |
add(getJTabbedPane(), BorderLayout.CENTER);
|
111 |
} |
112 |
|
113 |
|
114 |
private JTabbedPane getJTabbedPane() { |
115 |
if (tabbedPane == null) { |
116 |
tabbedPane = new JTabbedPane(); |
117 |
tabbedPane.addTab(Messages.getText("marker"), markerSelector);
|
118 |
tabbedPane.addTab(Messages.getText("line"), lineSelector);
|
119 |
tabbedPane.addTab(Messages.getText("fill"), fillSelector);
|
120 |
tabbedPane.setPreferredSize(getWindowInfo().getMinimumSize()); |
121 |
} |
122 |
|
123 |
return tabbedPane;
|
124 |
} |
125 |
|
126 |
|
127 |
public Object getSelectedObject() { |
128 |
IMultiShapeSymbol sym = SymbologyLocator.getSymbologyManager().createMultiShapeSymbol(); |
129 |
sym.setMarkerSymbol((IMarkerSymbol) markerSelector.getSelectedObject()); |
130 |
sym.setLineSymbol((ILineSymbol) lineSelector.getSelectedObject()); |
131 |
sym.setFillSymbol((IFillSymbol) fillSelector.getSelectedObject()); |
132 |
return sym;
|
133 |
} |
134 |
|
135 |
public void setSymbol(Object symbol) { |
136 |
IMultiShapeSymbol sym = (IMultiShapeSymbol) symbol; |
137 |
markerSelector.setSymbol(sym.getMarkerSymbol()); |
138 |
lineSelector.setSymbol(sym.getLineSymbol()); |
139 |
fillSelector.setSymbol(sym.getFillSymbol()); |
140 |
} |
141 |
|
142 |
public WindowInfo getWindowInfo() {
|
143 |
if (wi == null) { |
144 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
145 |
wi.setWidth(706);
|
146 |
wi.setHeight(500);
|
147 |
wi.setTitle(Messages.getText("symbol_selector"));
|
148 |
} |
149 |
return wi;
|
150 |
} |
151 |
|
152 |
public Object getWindowProfile() { |
153 |
if( wi.isModal() ) {
|
154 |
return WindowInfo.DIALOG_PROFILE;
|
155 |
} |
156 |
return WindowInfo.EDITOR_PROFILE;
|
157 |
} |
158 |
} |