svn-gvsig-desktop / tags / v1_1_Build_1009 / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / panels / ChooseGeometryType.java @ 12649
History | View | Annotate | Download (7.78 KB)
1 |
package com.iver.cit.gvsig.gui.cad.panels; |
---|---|
2 |
|
3 |
import javax.swing.ButtonGroup; |
4 |
import javax.swing.JLabel; |
5 |
import javax.swing.JPanel; |
6 |
import javax.swing.JRadioButton; |
7 |
import javax.swing.JTextField; |
8 |
import javax.swing.event.CaretEvent; |
9 |
import javax.swing.event.CaretListener; |
10 |
|
11 |
import jwizardcomponent.JWizardComponents; |
12 |
import jwizardcomponent.JWizardPanel; |
13 |
|
14 |
import com.hardcode.driverManager.Driver; |
15 |
import com.iver.andami.PluginServices; |
16 |
import com.iver.cit.gvsig.fmap.core.FShape; |
17 |
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter; |
18 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
19 |
|
20 |
/**
|
21 |
* @author fjp
|
22 |
*
|
23 |
* Panel para que el usuario seleccione el driver que va a utilizar para
|
24 |
* crear un tema desde cero.
|
25 |
*
|
26 |
*/
|
27 |
public class ChooseGeometryType extends JWizardPanel { |
28 |
|
29 |
private JLabel lblSelecGeometryType = null; |
30 |
private JPanel jPanelGeometryTypeOptions = null; |
31 |
private JRadioButton jRadioButtonPoint = null; |
32 |
private JRadioButton jRadioButtonLine = null; |
33 |
private JRadioButton jRadioButtonPolygon = null; |
34 |
private JRadioButton jRadioButtonMulti = null; |
35 |
private JRadioButton jRadioButtonMultiPoint = null; |
36 |
private JTextField jTextFieldLayerName = null; |
37 |
private JLabel jLabelLayerName = null; |
38 |
private String driverName; |
39 |
|
40 |
private class MyInputEventListener implements CaretListener |
41 |
{ |
42 |
public void caretUpdate(CaretEvent arg0) { |
43 |
if (jTextFieldLayerName.getText().length() > 0) |
44 |
setNextButtonEnabled(true);
|
45 |
else
|
46 |
setNextButtonEnabled(false);
|
47 |
|
48 |
} |
49 |
|
50 |
} |
51 |
|
52 |
public ChooseGeometryType(JWizardComponents wizardComponents) {
|
53 |
super(wizardComponents);
|
54 |
initialize(); |
55 |
// TODO Auto-generated constructor stub
|
56 |
} |
57 |
|
58 |
/**
|
59 |
* This method initializes this
|
60 |
*
|
61 |
*/
|
62 |
private void initialize() { |
63 |
jLabelLayerName = new JLabel(); |
64 |
jLabelLayerName.setBounds(new java.awt.Rectangle(14,9,321,22)); |
65 |
jLabelLayerName.setText(PluginServices.getText(this,"enter_layer_name")); |
66 |
lblSelecGeometryType = new JLabel(); |
67 |
lblSelecGeometryType.setText(PluginServices.getText(this,"select_geometry_type")); |
68 |
lblSelecGeometryType.setBounds(new java.awt.Rectangle(13,63,329,15)); |
69 |
this.setLayout(null); |
70 |
this.setSize(new java.awt.Dimension(358,263)); |
71 |
this.add(lblSelecGeometryType, null); |
72 |
this.add(getJPanelGeometryTypeOptions(), null); |
73 |
this.add(getJTextFieldLayerName(), null); |
74 |
this.add(jLabelLayerName, null); |
75 |
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* This method initializes jPanelGeometryTypeOptions
|
80 |
*
|
81 |
* @return javax.swing.JPanel
|
82 |
*/
|
83 |
private JPanel getJPanelGeometryTypeOptions() { |
84 |
if (jPanelGeometryTypeOptions == null) { |
85 |
jPanelGeometryTypeOptions = new JPanel(); |
86 |
jPanelGeometryTypeOptions.setLayout(null);
|
87 |
jPanelGeometryTypeOptions.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"Geometry_types"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
88 |
jPanelGeometryTypeOptions.setPreferredSize(new java.awt.Dimension(300,400)); |
89 |
jPanelGeometryTypeOptions.setBounds(new java.awt.Rectangle(14,82,326,172)); |
90 |
jPanelGeometryTypeOptions.add(getJRadioButtonPoint(), null);
|
91 |
jPanelGeometryTypeOptions.add(getJRadioButtonLine(), null);
|
92 |
jPanelGeometryTypeOptions.add(getJRadioButtonPolygon(), null);
|
93 |
jPanelGeometryTypeOptions.add(getJRadioButtonMulti(), null);
|
94 |
jPanelGeometryTypeOptions.add(getJRadioButtonMultiPoint(), null);
|
95 |
|
96 |
//Group the radio buttons.
|
97 |
ButtonGroup group = new ButtonGroup(); |
98 |
group.add(getJRadioButtonPoint()); |
99 |
group.add(getJRadioButtonLine()); |
100 |
group.add(getJRadioButtonPolygon()); |
101 |
group.add(getJRadioButtonMulti()); |
102 |
group.add(getJRadioButtonMultiPoint()); |
103 |
|
104 |
} |
105 |
return jPanelGeometryTypeOptions;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* This method initializes jRadioButtonPoint
|
110 |
*
|
111 |
* @return javax.swing.JRadioButton
|
112 |
*/
|
113 |
private JRadioButton getJRadioButtonPoint() { |
114 |
if (jRadioButtonPoint == null) { |
115 |
jRadioButtonPoint = new JRadioButton(); |
116 |
jRadioButtonPoint.setText(PluginServices.getText(this,"point_type")); |
117 |
jRadioButtonPoint.setBounds(new java.awt.Rectangle(19,31,297,23)); |
118 |
} |
119 |
return jRadioButtonPoint;
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* This method initializes jRadioButtonLine
|
124 |
*
|
125 |
* @return javax.swing.JRadioButton
|
126 |
*/
|
127 |
private JRadioButton getJRadioButtonLine() { |
128 |
if (jRadioButtonLine == null) { |
129 |
jRadioButtonLine = new JRadioButton(); |
130 |
jRadioButtonLine.setText(PluginServices.getText(this,"line_type")); |
131 |
jRadioButtonLine.setSelected(true);
|
132 |
jRadioButtonLine.setBounds(new java.awt.Rectangle(19,81,297,23)); |
133 |
} |
134 |
return jRadioButtonLine;
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* This method initializes jRadioButtonPolygon
|
139 |
*
|
140 |
* @return javax.swing.JRadioButton
|
141 |
*/
|
142 |
private JRadioButton getJRadioButtonPolygon() { |
143 |
if (jRadioButtonPolygon == null) { |
144 |
jRadioButtonPolygon = new JRadioButton(); |
145 |
jRadioButtonPolygon.setText(PluginServices.getText(this,"polygon_type")); |
146 |
jRadioButtonPolygon.setBounds(new java.awt.Rectangle(19,106,297,23)); |
147 |
} |
148 |
return jRadioButtonPolygon;
|
149 |
} |
150 |
|
151 |
/**
|
152 |
* This method initializes jRadioButtonMulti
|
153 |
*
|
154 |
* @return javax.swing.JRadioButton
|
155 |
*/
|
156 |
private JRadioButton getJRadioButtonMulti() { |
157 |
if (jRadioButtonMulti == null) { |
158 |
jRadioButtonMulti = new JRadioButton(); |
159 |
jRadioButtonMulti.setText(PluginServices.getText(this,"multi_type")); |
160 |
jRadioButtonMulti.setBounds(new java.awt.Rectangle(19,131,297,23)); |
161 |
} |
162 |
return jRadioButtonMulti;
|
163 |
} |
164 |
|
165 |
/**
|
166 |
* This method initializes jRadioButton
|
167 |
*
|
168 |
* @return javax.swing.JRadioButton
|
169 |
*/
|
170 |
private JRadioButton getJRadioButtonMultiPoint() { |
171 |
if (jRadioButtonMultiPoint == null) { |
172 |
jRadioButtonMultiPoint = new JRadioButton(); |
173 |
jRadioButtonMultiPoint.setText(PluginServices.getText(this,"multipoint_type")); |
174 |
jRadioButtonMultiPoint.setBounds(new java.awt.Rectangle(19,56,297,23)); |
175 |
} |
176 |
return jRadioButtonMultiPoint;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* En funci?n de qu? tipo de driver sea, habilitamos o deshabilitamos
|
181 |
* las opciones. Por ejemplo, si es de tipo shp, deshabilitamos
|
182 |
* multi_type
|
183 |
* @param writer
|
184 |
*/
|
185 |
public void setDriver(Driver driver) { |
186 |
// En funci?n de qu? tipo de driver sea, habilitamos o deshabilitamos
|
187 |
// las opciones. Por ejemplo, si es de tipo shp, deshabilitamos
|
188 |
// multi_type
|
189 |
IWriteable aux = (IWriteable) driver; |
190 |
ISpatialWriter writer = (ISpatialWriter) aux.getWriter(); |
191 |
System.out.println("Writer seleccionado:" + writer.getName()); |
192 |
driverName = driver.getName(); |
193 |
getJRadioButtonPoint().setEnabled(writer.canWriteGeometry(FShape.POINT)); |
194 |
getJRadioButtonMultiPoint().setEnabled(writer.canWriteGeometry(FShape.MULTIPOINT)); |
195 |
getJRadioButtonLine().setEnabled(writer.canWriteGeometry(FShape.LINE)); |
196 |
getJRadioButtonPolygon().setEnabled(writer.canWriteGeometry(FShape.POLYGON)); |
197 |
getJRadioButtonMulti().setEnabled(writer.canWriteGeometry(FShape.MULTI)); |
198 |
} |
199 |
|
200 |
public int getSelectedGeometryType() |
201 |
{ |
202 |
if (getJRadioButtonPoint().isSelected())
|
203 |
return FShape.POINT;
|
204 |
if (getJRadioButtonMultiPoint().isSelected())
|
205 |
return FShape.MULTIPOINT;
|
206 |
if (getJRadioButtonLine().isSelected())
|
207 |
return FShape.LINE;
|
208 |
if (getJRadioButtonPolygon().isSelected())
|
209 |
return FShape.POLYGON;
|
210 |
if (getJRadioButtonMulti().isSelected())
|
211 |
return FShape.MULTI;
|
212 |
|
213 |
return -1; |
214 |
} |
215 |
|
216 |
/**
|
217 |
* This method initializes jTextLayerName
|
218 |
*
|
219 |
* @return javax.swing.JTextField
|
220 |
*/
|
221 |
private JTextField getJTextFieldLayerName() { |
222 |
if (jTextFieldLayerName == null) { |
223 |
jTextFieldLayerName = new JTextField(); |
224 |
jTextFieldLayerName.setBounds(new java.awt.Rectangle(13,36,323,20)); |
225 |
jTextFieldLayerName.setText("layer1"); //PluginServices.getText(this,"new_layer")); |
226 |
jTextFieldLayerName.setHorizontalAlignment(javax.swing.JTextField.LEFT); |
227 |
jTextFieldLayerName.addCaretListener(new MyInputEventListener());
|
228 |
} |
229 |
return jTextFieldLayerName;
|
230 |
} |
231 |
|
232 |
public String getLayerName() { |
233 |
return getJTextFieldLayerName().getText();
|
234 |
} |
235 |
|
236 |
public String getSelectedDriver() { |
237 |
return driverName;
|
238 |
} |
239 |
|
240 |
|
241 |
|
242 |
} // @jve:decl-index=0:visual-constraint="10,10"
|