gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.extension / src / main / java / org / gvsig / gvsig3d / app / gui / styling / SymbolSelector3D.java @ 342
History | View | Annotate | Download (7.21 KB)
1 |
package org.gvsig.gvsig3d.app.gui.styling; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.GridBagConstraints; |
6 |
import java.awt.GridBagLayout; |
7 |
import java.awt.Insets; |
8 |
import java.awt.event.ActionEvent; |
9 |
import java.awt.event.ActionListener; |
10 |
import java.awt.event.ItemEvent; |
11 |
import java.awt.event.ItemListener; |
12 |
|
13 |
import javax.swing.DefaultComboBoxModel; |
14 |
import javax.swing.JButton; |
15 |
import javax.swing.JComboBox; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.SwingConstants; |
18 |
import javax.swing.border.TitledBorder; |
19 |
|
20 |
import org.gvsig.andami.PluginServices; |
21 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
22 |
import org.gvsig.app.gui.styling.SymbolSelector; |
23 |
import org.gvsig.app.project.documents.view.legend.gui.ISymbolSelector; |
24 |
import org.gvsig.fmap.geom.type.GeometryType; |
25 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
26 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.NodeMarker3DSymbol; |
27 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.PictureMarker3DSymbol; |
28 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.SimpleMarker3DSymbol; |
29 |
import org.gvsig.gvsig3d.symbology3d.I3DSymbol; |
30 |
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol; |
31 |
import org.gvsig.i18n.Messages; |
32 |
|
33 |
import ucar.nc2.constants._Coordinate; |
34 |
|
35 |
public class SymbolSelector3D extends JPanel implements ISymbolSelector, |
36 |
ActionListener {
|
37 |
/**
|
38 |
*
|
39 |
*/
|
40 |
private static final long serialVersionUID = 7378124199631050961L; |
41 |
private WindowInfo wi;
|
42 |
private JPanel _tabsPane; |
43 |
private JComboBox comboBox; |
44 |
private SimpleSymbolTab _ssTab;
|
45 |
private PictureSymbolTab _psTab;
|
46 |
private Object3DSymbolTab _obTab;
|
47 |
|
48 |
private ISymbol _oldsymbol;
|
49 |
private JPanel panel; |
50 |
private JButton btnNewButton; |
51 |
private JButton btnNewButton_1; |
52 |
private ISymbol _newSymbol;
|
53 |
|
54 |
private ISymbolSelectorTab _activeTab;
|
55 |
|
56 |
public SymbolSelector3D() {
|
57 |
super();
|
58 |
|
59 |
initComponents(); |
60 |
_tabsPane.setLayout(new BorderLayout(0, 0)); |
61 |
_ssTab = new SimpleSymbolTab(this); |
62 |
_psTab = new PictureSymbolTab(this); |
63 |
_obTab = new Object3DSymbolTab(this); |
64 |
_tabsPane.add(_ssTab); |
65 |
_activeTab = _ssTab; |
66 |
addAcceptCancelButtons(); |
67 |
|
68 |
} |
69 |
|
70 |
public SymbolSelector3D(ISymbol symbol) {
|
71 |
super();
|
72 |
_oldsymbol = symbol; |
73 |
|
74 |
} |
75 |
|
76 |
public SymbolSelector3D(ISymbol symbol, GeometryType shapeType) {
|
77 |
super();
|
78 |
_oldsymbol = symbol; |
79 |
initComponents(); |
80 |
SimpleSymbolTab ssTab = new SimpleSymbolTab(this); |
81 |
_tabsPane.add(ssTab); |
82 |
addAcceptCancelButtons(); |
83 |
|
84 |
} |
85 |
|
86 |
public SymbolSelector3D(String domain, ISymbol symbol, Integer shapeType) { |
87 |
super();
|
88 |
_oldsymbol = symbol; |
89 |
_ssTab = new SimpleSymbolTab(this); |
90 |
_psTab = new PictureSymbolTab(this); |
91 |
_obTab = new Object3DSymbolTab(this); |
92 |
initComponents(); |
93 |
|
94 |
if (symbol.getClass().equals(SimpleMarker3DSymbol.class)) {
|
95 |
_ssTab.updatePanel((I3DSymbol) symbol); |
96 |
_tabsPane.add(_ssTab, BorderLayout.CENTER);
|
97 |
_activeTab = _ssTab; |
98 |
comboBox.setSelectedIndex(0);
|
99 |
} else if (symbol.getClass().equals(PictureMarker3DSymbol.class)) { |
100 |
_psTab.updatePanel((I3DSymbol) symbol); |
101 |
_tabsPane.add(_psTab, BorderLayout.CENTER);
|
102 |
_activeTab = _psTab; |
103 |
comboBox.setSelectedIndex(1);
|
104 |
} else if (symbol.getClass().equals(NodeMarker3DSymbol.class)) { |
105 |
_obTab.updatePanel((I3DSymbol) symbol); |
106 |
_tabsPane.add(_obTab, BorderLayout.CENTER);
|
107 |
_activeTab = _obTab; |
108 |
comboBox.setSelectedIndex(2);
|
109 |
} |
110 |
addAcceptCancelButtons(); |
111 |
|
112 |
} |
113 |
|
114 |
private void initComponents() { |
115 |
setBorder(new TitledBorder(null, "Marker Symbols", |
116 |
TitledBorder.LEADING, TitledBorder.TOP, null, null)); |
117 |
GridBagLayout gridBagLayout = new GridBagLayout(); |
118 |
gridBagLayout.columnWidths = new int[] { 0, 0 }; |
119 |
gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 }; |
120 |
gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; |
121 |
gridBagLayout.rowWeights = new double[] { 0.2, 0.6, 0.2, |
122 |
Double.MIN_VALUE };
|
123 |
setLayout(gridBagLayout); |
124 |
|
125 |
comboBox = new JComboBox(); |
126 |
comboBox.addItemListener(new ItemListener() { |
127 |
public void itemStateChanged(ItemEvent arg0) { |
128 |
int which = comboBox.getSelectedIndex();
|
129 |
System.out.println("Case: " + which); |
130 |
switch (which) {
|
131 |
case 0: |
132 |
_tabsPane.removeAll(); |
133 |
System.out.println("A?ado panel 1"); |
134 |
_tabsPane.add(_ssTab, BorderLayout.CENTER);
|
135 |
_activeTab = _ssTab; |
136 |
_tabsPane.repaint(); |
137 |
_tabsPane.validate(); |
138 |
break;
|
139 |
|
140 |
case 1: |
141 |
_tabsPane.removeAll(); |
142 |
System.out.println("A?ado panel 2"); |
143 |
_tabsPane.add(_psTab, BorderLayout.CENTER);
|
144 |
_activeTab = _psTab; |
145 |
_tabsPane.repaint(); |
146 |
_tabsPane.validate(); |
147 |
break;
|
148 |
|
149 |
case 2: |
150 |
_tabsPane.removeAll(); |
151 |
System.out.println("A?ado panel 3"); |
152 |
_tabsPane.add(_obTab, BorderLayout.CENTER);
|
153 |
_activeTab = _obTab; |
154 |
_tabsPane.repaint(); |
155 |
_tabsPane.validate(); |
156 |
break;
|
157 |
default:
|
158 |
break;
|
159 |
|
160 |
} |
161 |
|
162 |
} |
163 |
}); |
164 |
comboBox.setModel(new DefaultComboBoxModel(new String[] { "Simple ", |
165 |
"Picture", "3D Object " })); |
166 |
GridBagConstraints gbc_comboBox = new GridBagConstraints(); |
167 |
gbc_comboBox.insets = new Insets(0, 0, 5, 0); |
168 |
gbc_comboBox.weightx = 0.3;
|
169 |
gbc_comboBox.ipadx = 10;
|
170 |
gbc_comboBox.anchor = GridBagConstraints.WEST;
|
171 |
gbc_comboBox.gridx = 0;
|
172 |
gbc_comboBox.gridy = 0;
|
173 |
add(comboBox, gbc_comboBox); |
174 |
|
175 |
_tabsPane = new JPanel(); |
176 |
GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); |
177 |
gbc_tabbedPane.weighty = 0.8;
|
178 |
gbc_tabbedPane.weightx = 0.8;
|
179 |
gbc_tabbedPane.insets = new Insets(0, 0, 5, 0); |
180 |
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
|
181 |
gbc_tabbedPane.gridx = 0;
|
182 |
gbc_tabbedPane.gridy = 1;
|
183 |
add(_tabsPane, gbc_tabbedPane); |
184 |
|
185 |
} |
186 |
|
187 |
private void addAcceptCancelButtons() { |
188 |
|
189 |
panel = new JPanel(); |
190 |
GridBagConstraints gbc_panel = new GridBagConstraints(); |
191 |
gbc_panel.anchor = GridBagConstraints.NORTHEAST;
|
192 |
gbc_panel.weighty = 0.2;
|
193 |
gbc_panel.weightx = 0.2;
|
194 |
gbc_panel.gridx = 0;
|
195 |
gbc_panel.gridy = 2;
|
196 |
add(panel, gbc_panel); |
197 |
panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); |
198 |
|
199 |
btnNewButton = new JButton("Cancel"); |
200 |
btnNewButton.addActionListener(new ActionListener() { |
201 |
public void actionPerformed(ActionEvent arg0) { |
202 |
PluginServices.getMDIManager().closeWindow( |
203 |
SymbolSelector3D.this); |
204 |
} |
205 |
}); |
206 |
panel.add(btnNewButton); |
207 |
|
208 |
btnNewButton_1 = new JButton("Accept"); |
209 |
btnNewButton_1.addActionListener(new ActionListener() { |
210 |
public void actionPerformed(ActionEvent arg0) { |
211 |
_newSymbol = _activeTab.getNewSymbol(); |
212 |
|
213 |
if (_newSymbol instanceof ISimpleMarker3DSymbol) |
214 |
((ISimpleMarker3DSymbol) (_newSymbol)) |
215 |
.setGeometry(((ISimpleMarker3DSymbol) (_oldsymbol)) |
216 |
.getGeometry()); |
217 |
// setSymbol(_newSymbol);
|
218 |
|
219 |
PluginServices.getMDIManager().closeWindow( |
220 |
SymbolSelector3D.this); |
221 |
} |
222 |
}); |
223 |
btnNewButton_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
224 |
panel.add(btnNewButton_1); |
225 |
|
226 |
} |
227 |
|
228 |
public ISymbol getSymbol() {
|
229 |
|
230 |
return _oldsymbol;
|
231 |
|
232 |
} |
233 |
|
234 |
public WindowInfo getWindowInfo() {
|
235 |
|
236 |
if (wi == null) { |
237 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
238 |
wi.setWidth(200);
|
239 |
wi.setHeight(400);
|
240 |
wi.setTitle(Messages.getText("symbol_selector"));
|
241 |
} |
242 |
return wi;
|
243 |
} |
244 |
|
245 |
public Object getWindowProfile() { |
246 |
return WindowInfo.DIALOG_PROFILE;
|
247 |
} |
248 |
|
249 |
public void actionPerformed(ActionEvent e) { |
250 |
// TODO Auto-generated method stub
|
251 |
|
252 |
} |
253 |
|
254 |
public Object getSelectedObject() { |
255 |
return _newSymbol;
|
256 |
} |
257 |
|
258 |
public void setSymbol(Object symbol) { |
259 |
_newSymbol = (ISymbol) symbol; |
260 |
|
261 |
} |
262 |
|
263 |
} |