Revision 2604
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/PanelLegendBreaks.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.gui.thememanager.legendmanager.panels; |
42 | 42 |
|
43 |
import javax.swing.DefaultComboBoxModel; |
|
44 |
import javax.swing.JOptionPane; |
|
45 |
import javax.swing.JPanel; |
|
46 |
import javax.swing.JLabel; |
|
47 |
|
|
48 | 43 |
import com.hardcode.gdbms.engine.data.DataSource; |
49 | 44 |
import com.hardcode.gdbms.engine.values.DateValue; |
50 | 45 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
... | ... | |
53 | 48 |
import com.hardcode.gdbms.engine.values.LongValue; |
54 | 49 |
import com.hardcode.gdbms.engine.values.NullValue; |
55 | 50 |
import com.hardcode.gdbms.engine.values.Value; |
51 |
|
|
56 | 52 |
import com.iver.andami.PluginServices; |
57 |
import javax.swing.JComboBox; |
|
58 |
import javax.swing.JTextField; |
|
59 | 53 |
|
60 | 54 |
import com.iver.cit.gvsig.fmap.DriverException; |
61 | 55 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
... | ... | |
70 | 64 |
import com.iver.cit.gvsig.fmap.rendering.VectorialIntervalLegend; |
71 | 65 |
import com.iver.cit.gvsig.gui.Panels.ColorChooserPanel; |
72 | 66 |
|
67 |
import org.apache.log4j.Logger; |
|
68 |
|
|
69 |
import java.awt.BorderLayout; |
|
73 | 70 |
import java.awt.Color; |
74 |
import javax.swing.JCheckBox; |
|
75 |
import java.awt.BorderLayout; |
|
76 | 71 |
import java.awt.event.ActionEvent; |
77 | 72 |
import java.awt.event.ActionListener; |
73 |
|
|
78 | 74 |
import java.text.NumberFormat; |
75 |
|
|
79 | 76 |
import java.util.ArrayList; |
80 | 77 |
|
78 |
import javax.swing.DefaultComboBoxModel; |
|
81 | 79 |
import javax.swing.JButton; |
80 |
import javax.swing.JCheckBox; |
|
81 |
import javax.swing.JComboBox; |
|
82 |
import javax.swing.JLabel; |
|
83 |
import javax.swing.JOptionPane; |
|
84 |
import javax.swing.JPanel; |
|
85 |
import javax.swing.JTextField; |
|
82 | 86 |
|
83 |
import org.apache.log4j.Logger; |
|
84 | 87 |
|
88 |
/** |
|
89 |
* DOCUMENT ME! |
|
90 |
* |
|
91 |
* @author Vicente Caballero Navarro |
|
92 |
*/ |
|
85 | 93 |
public class PanelLegendBreaks extends JPanel { |
86 |
private static Logger logger = Logger.getLogger(PanelLegendBreaks.class.getName()); |
|
87 |
private JPanel panelN = null; |
|
88 |
private JLabel lblField = null; |
|
89 |
private JComboBox cmbField = null; |
|
90 |
private JLabel lblNumIntervals = null; |
|
91 |
private JTextField txtNumIntervals = null; |
|
92 |
private JLabel lblInitColor = null; |
|
93 |
private JLabel lblEndColor = null; |
|
94 |
private ColorChooserPanel colorChooserPanel = null; |
|
95 |
private ColorChooserPanel colorChooserPanel1 = null; |
|
96 |
private JCheckBox chkdefaultvalues = null; |
|
97 |
private JLabel lblType = null; |
|
98 |
private JComboBox cmbFieldType = null; |
|
99 |
private JPanel panelS = null; |
|
100 |
private JButton bintervals = null; |
|
101 |
private JButton bInsert = null; |
|
102 |
private JButton bDelAll = null; |
|
103 |
private JButton bDel = null; |
|
104 |
private int count = 0; |
|
105 |
private ClassifiableVectorial m_lyr; |
|
106 |
private VectorialIntervalLegend m_Renderer; |
|
107 |
private VectorialIntervalLegend auxLegend=null; |
|
108 |
private FSymbolTable m_symbolTable = new FSymbolTable("intervals"); |
|
109 |
private MyListener listener = new MyListener(); |
|
110 |
private JPanel panelC = null; |
|
111 |
/** |
|
112 |
* This is the default constructor |
|
113 |
*/ |
|
114 |
public PanelLegendBreaks() { |
|
115 |
super(); |
|
116 |
initialize(); |
|
117 |
} |
|
94 |
private static Logger logger = Logger.getLogger(PanelLegendBreaks.class.getName()); |
|
95 |
private JPanel panelN = null; |
|
96 |
private JLabel lblField = null; |
|
97 |
private JComboBox cmbField = null; |
|
98 |
private JLabel lblNumIntervals = null; |
|
99 |
private JTextField txtNumIntervals = null; |
|
100 |
private JLabel lblInitColor = null; |
|
101 |
private JLabel lblEndColor = null; |
|
102 |
private ColorChooserPanel colorChooserPanel = null; |
|
103 |
private ColorChooserPanel colorChooserPanel1 = null; |
|
104 |
private JCheckBox chkdefaultvalues = null; |
|
105 |
private JLabel lblType = null; |
|
106 |
private JComboBox cmbFieldType = null; |
|
107 |
private JPanel panelS = null; |
|
108 |
private JButton bintervals = null; |
|
109 |
private JButton bInsert = null; |
|
110 |
private JButton bDelAll = null; |
|
111 |
private JButton bDel = null; |
|
112 |
private int count = 0; |
|
113 |
private ClassifiableVectorial m_lyr; |
|
114 |
private VectorialIntervalLegend m_Renderer; |
|
115 |
private VectorialIntervalLegend auxLegend = null; |
|
116 |
private FSymbolTable m_symbolTable = new FSymbolTable("intervals"); |
|
117 |
private MyListener listener = new MyListener(); |
|
118 |
private JPanel panelC = null; |
|
118 | 119 |
|
119 |
/** |
|
120 |
* This method initializes this |
|
121 |
* |
|
122 |
* @return void |
|
123 |
*/ |
|
124 |
private void initialize() { |
|
125 |
this.setLayout(new BorderLayout()); |
|
126 |
this.setSize(490, 300); |
|
127 |
this.add(getPanelN(), java.awt.BorderLayout.NORTH); |
|
128 |
this.add(getPanelS(), java.awt.BorderLayout.SOUTH); |
|
129 |
this.add(getPanelC(), java.awt.BorderLayout.CENTER); |
|
130 |
} |
|
120 |
/** |
|
121 |
* This is the default constructor |
|
122 |
*/ |
|
123 |
public PanelLegendBreaks() { |
|
124 |
super(); |
|
125 |
initialize(); |
|
126 |
} |
|
131 | 127 |
|
132 |
/** |
|
133 |
* This method initializes panelN |
|
134 |
* |
|
135 |
* @return javax.swing.JPanel |
|
136 |
*/ |
|
137 |
private JPanel getPanelN() { |
|
138 |
if (panelN == null) { |
|
139 |
lblType = new JLabel(); |
|
140 |
lblType.setBounds(new java.awt.Rectangle(3,27,112,20)); |
|
141 |
lblType.setText(PluginServices.getText(this,"tipo_de_intervalo")); |
|
142 |
lblEndColor = new JLabel(); |
|
143 |
lblEndColor.setBounds(new java.awt.Rectangle(143,51,77,20)); |
|
144 |
lblEndColor.setText(PluginServices.getText(this, "Color_final")); |
|
145 |
lblInitColor = new JLabel(); |
|
146 |
lblInitColor.setBounds(new java.awt.Rectangle(4,51,77,20)); |
|
147 |
lblInitColor.setText(PluginServices.getText(this, "Color_inicio")); |
|
148 |
lblNumIntervals = new JLabel(); |
|
149 |
lblNumIntervals.setBounds(new java.awt.Rectangle(282,51,127,20)); |
|
150 |
lblNumIntervals.setText(PluginServices.getText(this,"No_de_intervalos")); |
|
151 |
lblField = new JLabel(); |
|
152 |
lblField.setBounds(new java.awt.Rectangle(4,1,160,20)); |
|
153 |
lblField.setText(PluginServices.getText(this,"Campo_de_clasificacion")); |
|
154 |
panelN = new JPanel(); |
|
155 |
panelN.setLayout(null); |
|
156 |
panelN.setPreferredSize(new java.awt.Dimension(450,75)); |
|
157 |
panelN.add(lblField, null); |
|
158 |
panelN.add(getJComboBox(), null); |
|
159 |
panelN.add(lblNumIntervals, null); |
|
160 |
panelN.add(getTxtNumIntervals(), null); |
|
161 |
panelN.add(lblInitColor, null); |
|
162 |
panelN.add(lblEndColor, null); |
|
163 |
panelN.add(getColorChooserPanel(), null); |
|
164 |
panelN.add(getColorChooserPanel1(), null); |
|
165 |
panelN.add(getChkdefaultvalues(), null); |
|
166 |
panelN.add(lblType, null); |
|
167 |
panelN.add(getJComboBox1(), null); |
|
168 |
} |
|
169 |
return panelN; |
|
170 |
} |
|
128 |
/** |
|
129 |
* This method initializes this |
|
130 |
*/ |
|
131 |
private void initialize() { |
|
132 |
this.setLayout(new BorderLayout()); |
|
133 |
this.setSize(490, 300); |
|
134 |
this.add(getPanelN(), java.awt.BorderLayout.NORTH); |
|
135 |
this.add(getPanelS(), java.awt.BorderLayout.SOUTH); |
|
136 |
this.add(getPanelC(), java.awt.BorderLayout.CENTER); |
|
137 |
} |
|
171 | 138 |
|
172 |
/** |
|
173 |
* This method initializes jComboBox |
|
174 |
* |
|
175 |
* @return javax.swing.JComboBox |
|
176 |
*/ |
|
177 |
private JComboBox getJComboBox() { |
|
178 |
if (cmbField == null) { |
|
179 |
cmbField = new JComboBox(); |
|
180 |
cmbField.setBounds(new java.awt.Rectangle(168,1,282,20)); |
|
181 |
cmbField.setActionCommand("FIELD_SELECTED"); |
|
182 |
cmbField.addActionListener(listener); |
|
183 |
cmbField.setVisible(true); |
|
184 |
} |
|
185 |
return cmbField; |
|
186 |
} |
|
139 |
/** |
|
140 |
* This method initializes panelN |
|
141 |
* |
|
142 |
* @return javax.swing.JPanel |
|
143 |
*/ |
|
144 |
private JPanel getPanelN() { |
|
145 |
if (panelN == null) { |
|
146 |
lblType = new JLabel(); |
|
147 |
lblType.setBounds(new java.awt.Rectangle(3, 27, 112, 20)); |
|
148 |
lblType.setText(PluginServices.getText(this, "tipo_de_intervalo")); |
|
149 |
lblEndColor = new JLabel(); |
|
150 |
lblEndColor.setBounds(new java.awt.Rectangle(143, 51, 77, 20)); |
|
151 |
lblEndColor.setText(PluginServices.getText(this, "Color_final")); |
|
152 |
lblInitColor = new JLabel(); |
|
153 |
lblInitColor.setBounds(new java.awt.Rectangle(4, 51, 77, 20)); |
|
154 |
lblInitColor.setText(PluginServices.getText(this, "Color_inicio")); |
|
155 |
lblNumIntervals = new JLabel(); |
|
156 |
lblNumIntervals.setBounds(new java.awt.Rectangle(282, 51, 127, 20)); |
|
157 |
lblNumIntervals.setText(PluginServices.getText(this, |
|
158 |
"No_de_intervalos")); |
|
159 |
lblField = new JLabel(); |
|
160 |
lblField.setBounds(new java.awt.Rectangle(4, 1, 160, 20)); |
|
161 |
lblField.setText(PluginServices.getText(this, |
|
162 |
"Campo_de_clasificacion")); |
|
163 |
panelN = new JPanel(); |
|
164 |
panelN.setLayout(null); |
|
165 |
panelN.setPreferredSize(new java.awt.Dimension(450, 75)); |
|
166 |
panelN.add(lblField, null); |
|
167 |
panelN.add(getJComboBox(), null); |
|
168 |
panelN.add(lblNumIntervals, null); |
|
169 |
panelN.add(getTxtNumIntervals(), null); |
|
170 |
panelN.add(lblInitColor, null); |
|
171 |
panelN.add(lblEndColor, null); |
|
172 |
panelN.add(getColorChooserPanel(), null); |
|
173 |
panelN.add(getColorChooserPanel1(), null); |
|
174 |
panelN.add(getChkdefaultvalues(), null); |
|
175 |
panelN.add(lblType, null); |
|
176 |
panelN.add(getJComboBox1(), null); |
|
177 |
} |
|
187 | 178 |
|
188 |
/** |
|
189 |
* This method initializes txtNumIntervals |
|
190 |
* |
|
191 |
* @return javax.swing.JTextField |
|
192 |
*/ |
|
193 |
private JTextField getTxtNumIntervals() { |
|
194 |
if (txtNumIntervals == null) { |
|
195 |
txtNumIntervals = new JTextField(); |
|
196 |
txtNumIntervals.setText("5"); |
|
197 |
txtNumIntervals.setBounds(new java.awt.Rectangle(408,51,37,20)); |
|
198 |
} |
|
199 |
return txtNumIntervals; |
|
200 |
} |
|
179 |
return panelN; |
|
180 |
} |
|
201 | 181 |
|
202 |
/** |
|
203 |
* This method initializes colorChooserPanel |
|
204 |
* |
|
205 |
* @return com.iver.cit.gvsig.gui.Panels.ColorChooserPanel |
|
206 |
*/ |
|
207 |
private ColorChooserPanel getColorChooserPanel() { |
|
208 |
if (colorChooserPanel == null) { |
|
209 |
colorChooserPanel = new ColorChooserPanel(); |
|
210 |
colorChooserPanel.setBounds(new java.awt.Rectangle(85,51,54,20)); |
|
211 |
colorChooserPanel.setAlpha(255); |
|
212 |
colorChooserPanel.setColor(Color.red); |
|
213 |
} |
|
214 |
return colorChooserPanel; |
|
215 |
} |
|
182 |
/** |
|
183 |
* This method initializes jComboBox |
|
184 |
* |
|
185 |
* @return javax.swing.JComboBox |
|
186 |
*/ |
|
187 |
private JComboBox getJComboBox() { |
|
188 |
if (cmbField == null) { |
|
189 |
cmbField = new JComboBox(); |
|
190 |
cmbField.setBounds(new java.awt.Rectangle(168, 1, 282, 20)); |
|
191 |
cmbField.setActionCommand("FIELD_SELECTED"); |
|
192 |
cmbField.addActionListener(listener); |
|
193 |
cmbField.setVisible(true); |
|
194 |
} |
|
216 | 195 |
|
217 |
/** |
|
218 |
* This method initializes colorChooserPanel1 |
|
219 |
* |
|
220 |
* @return com.iver.cit.gvsig.gui.Panels.ColorChooserPanel |
|
221 |
*/ |
|
222 |
private ColorChooserPanel getColorChooserPanel1() { |
|
223 |
if (colorChooserPanel1 == null) { |
|
224 |
colorChooserPanel1 = new ColorChooserPanel(); |
|
225 |
colorChooserPanel1.setBounds(new java.awt.Rectangle(224,51,54,20)); |
|
226 |
colorChooserPanel1.setAlpha(255); |
|
227 |
colorChooserPanel1.setColor(Color.blue); |
|
228 |
} |
|
229 |
return colorChooserPanel1; |
|
230 |
} |
|
196 |
return cmbField; |
|
197 |
} |
|
231 | 198 |
|
232 |
/** |
|
233 |
* This method initializes chkdefaultvalues |
|
234 |
* |
|
235 |
* @return javax.swing.JCheckBox |
|
236 |
*/ |
|
237 |
private JCheckBox getChkdefaultvalues() { |
|
238 |
if (chkdefaultvalues == null) { |
|
239 |
chkdefaultvalues = new JCheckBox(); |
|
240 |
chkdefaultvalues.setText(PluginServices.getText(this,"resto_valores")); |
|
241 |
chkdefaultvalues.setBounds(new java.awt.Rectangle(341,27,109,20)); |
|
242 |
} |
|
243 |
return chkdefaultvalues; |
|
244 |
} |
|
199 |
/** |
|
200 |
* This method initializes txtNumIntervals |
|
201 |
* |
|
202 |
* @return javax.swing.JTextField |
|
203 |
*/ |
|
204 |
private JTextField getTxtNumIntervals() { |
|
205 |
if (txtNumIntervals == null) { |
|
206 |
txtNumIntervals = new JTextField(); |
|
207 |
txtNumIntervals.setText("5"); |
|
208 |
txtNumIntervals.setBounds(new java.awt.Rectangle(408, 51, 37, 20)); |
|
209 |
} |
|
245 | 210 |
|
246 |
/** |
|
247 |
* This method initializes jComboBox1 |
|
248 |
* |
|
249 |
* @return javax.swing.JComboBox |
|
250 |
*/ |
|
251 |
private JComboBox getJComboBox1() { |
|
252 |
if (cmbFieldType == null) { |
|
253 |
cmbFieldType = new JComboBox(); |
|
254 |
cmbFieldType.setBounds(new java.awt.Rectangle(116,27,212,20)); |
|
255 |
cmbFieldType.setActionCommand("INTERVAL_TYPE"); |
|
256 |
cmbFieldType.addActionListener(listener); |
|
257 |
cmbFieldType.addItem(PluginServices.getText(this,"equal_intervals")); |
|
258 |
cmbFieldType.addItem(PluginServices.getText(this,"natural_intervals")); |
|
259 |
cmbFieldType.addItem(PluginServices.getText(this,"quantile_intervals")); |
|
260 |
cmbFieldType.setVisible(true); |
|
261 |
} |
|
262 |
return cmbFieldType; |
|
263 |
} |
|
211 |
return txtNumIntervals; |
|
212 |
} |
|
264 | 213 |
|
265 |
/** |
|
266 |
* This method initializes panelS |
|
267 |
* |
|
268 |
* @return javax.swing.JPanel |
|
269 |
*/ |
|
270 |
private JPanel getPanelS() { |
|
271 |
if (panelS == null) { |
|
272 |
panelS = new JPanel(); |
|
273 |
panelS.setPreferredSize(new java.awt.Dimension(417,32)); |
|
274 |
panelS.add(getBintervals(), null); |
|
275 |
panelS.add(getBInsert(), null); |
|
276 |
panelS.add(getBDelAll(), null); |
|
277 |
panelS.add(getBDel(), null); |
|
278 |
} |
|
279 |
return panelS; |
|
280 |
} |
|
214 |
/** |
|
215 |
* This method initializes colorChooserPanel |
|
216 |
* |
|
217 |
* @return com.iver.cit.gvsig.gui.Panels.ColorChooserPanel |
|
218 |
*/ |
|
219 |
private ColorChooserPanel getColorChooserPanel() { |
|
220 |
if (colorChooserPanel == null) { |
|
221 |
colorChooserPanel = new ColorChooserPanel(); |
|
222 |
colorChooserPanel.setBounds(new java.awt.Rectangle(85, 51, 54, 20)); |
|
223 |
colorChooserPanel.setAlpha(255); |
|
224 |
colorChooserPanel.setColor(Color.red); |
|
225 |
} |
|
281 | 226 |
|
282 |
/** |
|
283 |
* This method initializes bintervals |
|
284 |
* |
|
285 |
* @return javax.swing.JButton |
|
286 |
*/ |
|
287 |
private JButton getBintervals() { |
|
288 |
if (bintervals == null) { |
|
289 |
bintervals = new JButton(); |
|
290 |
bintervals.setActionCommand("ADD_ALL_VALUES"); |
|
291 |
bintervals.addActionListener(listener); |
|
292 |
bintervals.setText(PluginServices.getText(this,"Calcular_intervalos")); |
|
293 |
} |
|
294 |
return bintervals; |
|
295 |
} |
|
227 |
return colorChooserPanel; |
|
228 |
} |
|
296 | 229 |
|
297 |
/** |
|
298 |
* This method initializes bInsert |
|
299 |
* |
|
300 |
* @return javax.swing.JButton |
|
301 |
*/ |
|
302 |
private JButton getBInsert() { |
|
303 |
if (bInsert == null) { |
|
304 |
bInsert = new JButton(); |
|
305 |
bInsert.setActionCommand("ADD_VALUE"); |
|
306 |
bInsert.addActionListener(listener); |
|
307 |
bInsert.setText(PluginServices.getText(this, "Anadir")); |
|
308 |
} |
|
309 |
return bInsert; |
|
310 |
} |
|
230 |
/** |
|
231 |
* This method initializes colorChooserPanel1 |
|
232 |
* |
|
233 |
* @return com.iver.cit.gvsig.gui.Panels.ColorChooserPanel |
|
234 |
*/ |
|
235 |
private ColorChooserPanel getColorChooserPanel1() { |
|
236 |
if (colorChooserPanel1 == null) { |
|
237 |
colorChooserPanel1 = new ColorChooserPanel(); |
|
238 |
colorChooserPanel1.setBounds(new java.awt.Rectangle(224, 51, 54, 20)); |
|
239 |
colorChooserPanel1.setAlpha(255); |
|
240 |
colorChooserPanel1.setColor(Color.blue); |
|
241 |
} |
|
311 | 242 |
|
312 |
/** |
|
313 |
* This method initializes bDelAll |
|
314 |
* |
|
315 |
* @return javax.swing.JButton |
|
316 |
*/ |
|
317 |
private JButton getBDelAll() { |
|
318 |
if (bDelAll == null) { |
|
319 |
bDelAll = new JButton(); |
|
320 |
bDelAll.setActionCommand("REMOVE_ALL"); |
|
321 |
bDelAll.addActionListener(listener); |
|
322 |
bDelAll.setText(PluginServices.getText(this, "Quitar_todos")); |
|
323 |
} |
|
324 |
return bDelAll; |
|
325 |
} |
|
243 |
return colorChooserPanel1; |
|
244 |
} |
|
326 | 245 |
|
327 |
/** |
|
328 |
* This method initializes bDel |
|
329 |
* |
|
330 |
* @return javax.swing.JButton |
|
331 |
*/ |
|
332 |
private JButton getBDel() { |
|
333 |
if (bDel == null) { |
|
334 |
bDel = new JButton(); |
|
335 |
bDel.setText(PluginServices.getText(this, "Quitar")); |
|
336 |
bDel.setActionCommand("REMOVE"); |
|
337 |
bDel.addActionListener(listener); |
|
338 |
} |
|
339 |
return bDel; |
|
340 |
} |
|
341 |
class MyListener implements ActionListener { |
|
342 |
//private FLyrShp m_layer; |
|
343 |
// private FPanelLegendValues m_Parent; |
|
344 |
public MyListener() { // FPanelLegendValues p) { |
|
246 |
/** |
|
247 |
* This method initializes chkdefaultvalues |
|
248 |
* |
|
249 |
* @return javax.swing.JCheckBox |
|
250 |
*/ |
|
251 |
private JCheckBox getChkdefaultvalues() { |
|
252 |
if (chkdefaultvalues == null) { |
|
253 |
chkdefaultvalues = new JCheckBox(); |
|
254 |
chkdefaultvalues.setText(PluginServices.getText(this, |
|
255 |
"resto_valores")); |
|
256 |
chkdefaultvalues.setBounds(new java.awt.Rectangle(341, 27, 109, 20)); |
|
257 |
} |
|
345 | 258 |
|
346 |
// m_Parent = p;
|
|
347 |
}
|
|
259 |
return chkdefaultvalues;
|
|
260 |
}
|
|
348 | 261 |
|
349 |
/** |
|
350 |
* DOCUMENT ME! |
|
351 |
* |
|
352 |
* @param e DOCUMENT ME! |
|
353 |
*/ |
|
354 |
public void actionPerformed(ActionEvent e) { |
|
355 |
// rellenarValue(); |
|
356 |
System.out.println("ActionEvent con " + e.getActionCommand()); |
|
262 |
/** |
|
263 |
* This method initializes jComboBox1 |
|
264 |
* |
|
265 |
* @return javax.swing.JComboBox |
|
266 |
*/ |
|
267 |
private JComboBox getJComboBox1() { |
|
268 |
if (cmbFieldType == null) { |
|
269 |
cmbFieldType = new JComboBox(); |
|
270 |
cmbFieldType.setBounds(new java.awt.Rectangle(116, 27, 212, 20)); |
|
271 |
cmbFieldType.setActionCommand("INTERVAL_TYPE"); |
|
272 |
cmbFieldType.addActionListener(listener); |
|
273 |
cmbFieldType.addItem(PluginServices.getText(this, "equal_intervals")); |
|
274 |
cmbFieldType.addItem(PluginServices.getText(this, |
|
275 |
"natural_intervals")); |
|
276 |
cmbFieldType.addItem(PluginServices.getText(this, |
|
277 |
"quantile_intervals")); |
|
278 |
cmbFieldType.setVisible(true); |
|
279 |
} |
|
357 | 280 |
|
358 |
//modificar el combobox de valor |
|
359 |
if (e.getActionCommand() == "FIELD_SELECTED") { |
|
360 |
JComboBox cb = (JComboBox) e.getSource(); |
|
361 |
String fieldName = (String) cb.getSelectedItem(); |
|
362 |
System.out.println("Nombre del campo: " + fieldName); |
|
363 |
m_symbolTable.removeAllItems(); |
|
281 |
return cmbFieldType; |
|
282 |
} |
|
364 | 283 |
|
365 |
m_Renderer.setFieldName(fieldName); |
|
366 |
} else if (e.getActionCommand() == "INTERVAL_TYPE") { |
|
367 |
JComboBox cb = (JComboBox) e.getSource(); |
|
368 |
|
|
369 |
if (m_Renderer!=null && cb.getSelectedIndex() != m_Renderer.getIntervalType()) { |
|
370 |
m_Renderer.setIntervalType(cb.getSelectedIndex()); |
|
371 |
m_symbolTable.removeAllItems(); |
|
372 |
} |
|
373 |
|
|
374 |
} |
|
284 |
/** |
|
285 |
* This method initializes panelS |
|
286 |
* |
|
287 |
* @return javax.swing.JPanel |
|
288 |
*/ |
|
289 |
private JPanel getPanelS() { |
|
290 |
if (panelS == null) { |
|
291 |
panelS = new JPanel(); |
|
292 |
panelS.setPreferredSize(new java.awt.Dimension(417, 32)); |
|
293 |
panelS.add(getBintervals(), null); |
|
294 |
panelS.add(getBInsert(), null); |
|
295 |
panelS.add(getBDelAll(), null); |
|
296 |
panelS.add(getBDel(), null); |
|
297 |
} |
|
375 | 298 |
|
376 |
//A?adir todos los elementos por valor |
|
377 |
if (e.getActionCommand() == "ADD_ALL_VALUES") { |
|
378 |
fillTableValues(); |
|
379 |
} |
|
299 |
return panelS; |
|
300 |
} |
|
380 | 301 |
|
381 |
//A?adir un ?nico elemento
|
|
382 |
if (e.getActionCommand() == "ADD_VALUE") {
|
|
383 |
try {
|
|
384 |
m_symbolTable.addTableRecord(new FSymbol(m_lyr.getShapeType()),new FInterval(0,0),"0 - 0");
|
|
385 |
} catch (DriverException e1) {
|
|
386 |
e1.printStackTrace();
|
|
387 |
}
|
|
388 |
|
|
389 |
/* a?adir("Nuevo_Valor");
|
|
390 |
aceptar.setEnabled(true);
|
|
391 |
quitartodo.setEnabled(true);
|
|
392 |
quitar.setEnabled(true); */
|
|
393 |
}
|
|
302 |
/**
|
|
303 |
* This method initializes bintervals
|
|
304 |
*
|
|
305 |
* @return javax.swing.JButton
|
|
306 |
*/
|
|
307 |
private JButton getBintervals() {
|
|
308 |
if (bintervals == null) {
|
|
309 |
bintervals = new JButton(); |
|
310 |
bintervals.setActionCommand("ADD_ALL_VALUES");
|
|
311 |
bintervals.addActionListener(listener);
|
|
312 |
bintervals.setText(PluginServices.getText(this,
|
|
313 |
"Calcular_intervalos"));
|
|
314 |
}
|
|
394 | 315 |
|
395 |
//Vacia la tabla |
|
396 |
if (e.getActionCommand() == "REMOVE_ALL") { |
|
397 |
m_symbolTable.removeAllItems(); |
|
316 |
return bintervals; |
|
317 |
} |
|
398 | 318 |
|
399 |
// aceptar.setEnabled(false); |
|
400 |
} |
|
319 |
/** |
|
320 |
* This method initializes bInsert |
|
321 |
* |
|
322 |
* @return javax.swing.JButton |
|
323 |
*/ |
|
324 |
private JButton getBInsert() { |
|
325 |
if (bInsert == null) { |
|
326 |
bInsert = new JButton(); |
|
327 |
bInsert.setActionCommand("ADD_VALUE"); |
|
328 |
bInsert.addActionListener(listener); |
|
329 |
bInsert.setText(PluginServices.getText(this, "Anadir")); |
|
330 |
} |
|
401 | 331 |
|
402 |
//Quitar solo el elemento seleccionado |
|
403 |
if (e.getActionCommand() == "REMOVE") { |
|
404 |
m_symbolTable.removeSelectedRows(); |
|
405 |
} |
|
406 |
} |
|
407 |
} |
|
408 |
/** |
|
409 |
* Damos una primera pasada para saber los l?mites inferior y superior y |
|
410 |
* rellenar un array con los valores. Luego dividimos ese array en |
|
411 |
* intervalos. |
|
412 |
*/ |
|
413 |
private void fillTableValues() { |
|
414 |
FInterval[] arrayIntervalos = null; |
|
415 |
DataSource elRs; |
|
416 |
m_symbolTable.removeAllItems(); |
|
332 |
return bInsert; |
|
333 |
} |
|
417 | 334 |
|
418 |
try { |
|
419 |
elRs = ((AlphanumericData) m_lyr).getRecordset(); |
|
420 |
logger.debug("elRs.start()"); |
|
421 |
elRs.start(); |
|
335 |
/** |
|
336 |
* This method initializes bDelAll |
|
337 |
* |
|
338 |
* @return javax.swing.JButton |
|
339 |
*/ |
|
340 |
private JButton getBDelAll() { |
|
341 |
if (bDelAll == null) { |
|
342 |
bDelAll = new JButton(); |
|
343 |
bDelAll.setActionCommand("REMOVE_ALL"); |
|
344 |
bDelAll.addActionListener(listener); |
|
345 |
bDelAll.setText(PluginServices.getText(this, "Quitar_todos")); |
|
346 |
} |
|
422 | 347 |
|
423 |
int idField = -1; |
|
424 |
int numIntervalos=1; |
|
425 |
try{ |
|
426 |
numIntervalos= Integer.parseInt(txtNumIntervals.getText()); |
|
427 |
}catch (NumberFormatException e) { |
|
428 |
System.out.println("Foramto de n?mero erroneo"); |
|
429 |
} |
|
430 |
String fieldName = (String) cmbField.getSelectedItem(); |
|
431 |
System.out.println("Nombre del campo de clasificaci?n: " + |
|
432 |
fieldName); |
|
433 |
m_Renderer.setFieldName(fieldName); |
|
348 |
return bDelAll; |
|
349 |
} |
|
434 | 350 |
|
435 |
String nomField = m_Renderer.getFieldName(); |
|
351 |
/** |
|
352 |
* This method initializes bDel |
|
353 |
* |
|
354 |
* @return javax.swing.JButton |
|
355 |
*/ |
|
356 |
private JButton getBDel() { |
|
357 |
if (bDel == null) { |
|
358 |
bDel = new JButton(); |
|
359 |
bDel.setText(PluginServices.getText(this, "Quitar")); |
|
360 |
bDel.setActionCommand("REMOVE"); |
|
361 |
bDel.addActionListener(listener); |
|
362 |
} |
|
436 | 363 |
|
437 |
// Cogemos el tipo de gradaci?n de colores que quiere el usuario y |
|
438 |
// Creamos el primer y ?ltimo color. |
|
439 |
Color startColor = colorChooserPanel.getColor(); |
|
440 |
m_Renderer.setStartColor(startColor); |
|
364 |
return bDel; |
|
365 |
} |
|
441 | 366 |
|
442 |
Color endColor = colorChooserPanel1.getColor(); |
|
443 |
m_Renderer.setEndColor(endColor); |
|
367 |
/** |
|
368 |
* Damos una primera pasada para saber los l?mites inferior y superior y |
|
369 |
* rellenar un array con los valores. Luego dividimos ese array en |
|
370 |
* intervalos. |
|
371 |
*/ |
|
372 |
private void fillTableValues() { |
|
373 |
FInterval[] arrayIntervalos = null; |
|
374 |
DataSource elRs; |
|
375 |
m_symbolTable.removeAllItems(); |
|
444 | 376 |
|
445 |
|
|
377 |
try { |
|
378 |
elRs = ((AlphanumericData) m_lyr).getRecordset(); |
|
379 |
logger.debug("elRs.start()"); |
|
380 |
elRs.start(); |
|
446 | 381 |
|
447 |
for (int i = 0; i < elRs.getFieldCount(); i++) {
|
|
448 |
String nomAux = elRs.getFieldName(i).trim();
|
|
382 |
int idField = -1;
|
|
383 |
int numIntervalos = 1;
|
|
449 | 384 |
|
450 |
if (nomField.compareToIgnoreCase(nomAux) == 0) { |
|
451 |
idField = i; |
|
385 |
try { |
|
386 |
numIntervalos = Integer.parseInt(txtNumIntervals.getText()); |
|
387 |
} catch (NumberFormatException e) { |
|
388 |
System.out.println("Foramto de n?mero erroneo"); |
|
389 |
} |
|
452 | 390 |
|
453 |
break; |
|
454 |
} |
|
455 |
} |
|
391 |
String fieldName = (String) cmbField.getSelectedItem(); |
|
392 |
System.out.println("Nombre del campo de clasificaci?n: " + |
|
393 |
fieldName); |
|
394 |
m_Renderer.setFieldName(fieldName); |
|
456 | 395 |
|
457 |
if (idField == -1) { |
|
458 |
System.err.println("Campo no reconocido " + nomField); |
|
396 |
String nomField = m_Renderer.getFieldName(); |
|
459 | 397 |
|
460 |
return; |
|
461 |
} |
|
398 |
// Cogemos el tipo de gradaci?n de colores que quiere el usuario y |
|
399 |
// Creamos el primer y ?ltimo color. |
|
400 |
Color startColor = colorChooserPanel.getColor(); |
|
401 |
m_Renderer.setStartColor(startColor); |
|
462 | 402 |
|
463 |
///m_symbolTable.removeAllItems(); |
|
464 |
///m_valuesCache = new Object[m_lyr.getSource().getShapeCount()]; |
|
465 |
int numSymbols = 0; |
|
466 |
FSymbol theSymbol; |
|
467 |
//Date valorDate; |
|
468 |
double minValue = Double.MAX_VALUE; |
|
469 |
double maxValue = Double.MIN_VALUE; |
|
470 |
//Date minValueDate = null; |
|
471 |
//Date maxValueDate = null; |
|
403 |
Color endColor = colorChooserPanel1.getColor(); |
|
404 |
m_Renderer.setEndColor(endColor); |
|
472 | 405 |
|
473 |
|
|
474 |
auxLegend = LegendFactory.createVectorialIntervalLegend(m_lyr.getShapeType());
|
|
406 |
for (int i = 0; i < elRs.getFieldCount(); i++) { |
|
407 |
String nomAux = elRs.getFieldName(i).trim();
|
|
475 | 408 |
|
476 |
Value clave; |
|
477 |
//Object resul; |
|
478 |
int symbolType = 0; |
|
479 |
count = 0; |
|
480 |
|
|
481 |
for (int j = 0; j < elRs.getRowCount(); j++) { |
|
482 |
clave = elRs.getFieldValue(j, idField); |
|
409 |
if (nomField.compareToIgnoreCase(nomAux) == 0) { |
|
410 |
idField = i; |
|
483 | 411 |
|
484 |
IInterval interval = auxLegend.getInterval(clave); |
|
412 |
break; |
|
413 |
} |
|
414 |
} |
|
485 | 415 |
|
486 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo. |
|
487 |
if (auxLegend.getSymbolByInterval(interval) == null) { |
|
488 |
//si no esta creado el simbolo se crea |
|
489 |
double valor = 0; |
|
490 |
symbolType = m_lyr.getShapeType(); |
|
416 |
if (idField == -1) { |
|
417 |
System.err.println("Campo no reconocido " + nomField); |
|
491 | 418 |
|
492 |
if (clave instanceof IntValue) { |
|
493 |
valor = ((IntValue) clave).getValue(); |
|
494 |
} else if (clave instanceof DoubleValue) { |
|
495 |
valor = ((DoubleValue) clave).getValue(); |
|
496 |
} else if (clave instanceof FloatValue) { |
|
497 |
valor = ((FloatValue) clave).getValue(); |
|
498 |
} else if (clave instanceof LongValue) { |
|
499 |
valor = ((LongValue) clave).getValue(); |
|
500 |
} else if (clave instanceof DateValue) { |
|
501 |
//TODO POR IMPLEMENTAR |
|
502 |
///valorDate = elRs.getFieldValueAsDate(idField); |
|
503 |
///if (valorDate.before(minValueDate)) minValueDate = valorDate; |
|
504 |
///if (valorDate.after(maxValueDate)) maxValueDate = valorDate; |
|
505 |
} else if (clave instanceof NullValue){ |
|
506 |
continue; |
|
507 |
} |
|
419 |
return; |
|
420 |
} |
|
508 | 421 |
|
509 |
if (valor < minValue) { |
|
510 |
minValue = (double) valor; |
|
511 |
} |
|
422 |
///m_symbolTable.removeAllItems(); |
|
423 |
///m_valuesCache = new Object[m_lyr.getSource().getShapeCount()]; |
|
424 |
int numSymbols = 0; |
|
425 |
FSymbol theSymbol; |
|
512 | 426 |
|
513 |
if (valor > maxValue) { |
|
514 |
maxValue = (double) valor; |
|
515 |
} |
|
516 |
} |
|
427 |
//Date valorDate; |
|
428 |
double minValue = Double.MAX_VALUE; |
|
429 |
double maxValue = Double.MIN_VALUE; |
|
517 | 430 |
|
518 |
count++; |
|
519 |
} |
|
431 |
//Date minValueDate = null; |
|
432 |
//Date maxValueDate = null; |
|
433 |
auxLegend = LegendFactory.createVectorialIntervalLegend(m_lyr.getShapeType()); |
|
520 | 434 |
|
521 |
switch (m_Renderer.getIntervalType()) { |
|
522 |
case VectorialIntervalLegend.EQUAL_INTERVALS: |
|
523 |
arrayIntervalos = calculateEqualIntervals(numIntervalos, |
|
524 |
minValue, maxValue,fieldName); |
|
435 |
Value clave; |
|
525 | 436 |
|
526 |
break; |
|
437 |
//Object resul; |
|
438 |
int symbolType = 0; |
|
439 |
count = 0; |
|
527 | 440 |
|
528 |
case VectorialIntervalLegend.NATURAL_INTERVALS: |
|
529 |
arrayIntervalos = calculateNaturalIntervals(numIntervalos, |
|
530 |
minValue, maxValue,fieldName); |
|
441 |
for (int j = 0; j < elRs.getRowCount(); j++) { |
|
442 |
clave = elRs.getFieldValue(j, idField); |
|
531 | 443 |
|
532 |
break;
|
|
444 |
IInterval interval = auxLegend.getInterval(clave);
|
|
533 | 445 |
|
534 |
case VectorialIntervalLegend.QUANTILE_INTERVALS: |
|
535 |
arrayIntervalos = calculateQuantileIntervals(numIntervalos, |
|
536 |
minValue, maxValue,fieldName); |
|
446 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo. |
|
447 |
if (auxLegend.getSymbolByInterval(interval) == null) { |
|
448 |
//si no esta creado el simbolo se crea |
|
449 |
double valor = 0; |
|
450 |
symbolType = m_lyr.getShapeType(); |
|
537 | 451 |
|
538 |
break; |
|
539 |
} |
|
452 |
if (clave instanceof IntValue) { |
|
453 |
valor = ((IntValue) clave).getValue(); |
|
454 |
} else if (clave instanceof DoubleValue) { |
|
455 |
valor = ((DoubleValue) clave).getValue(); |
|
456 |
} else if (clave instanceof FloatValue) { |
|
457 |
valor = ((FloatValue) clave).getValue(); |
|
458 |
} else if (clave instanceof LongValue) { |
|
459 |
valor = ((LongValue) clave).getValue(); |
|
460 |
} else if (clave instanceof DateValue) { |
|
461 |
//TODO POR IMPLEMENTAR |
|
462 |
///valorDate = elRs.getFieldValueAsDate(idField); |
|
463 |
///if (valorDate.before(minValueDate)) minValueDate = valorDate; |
|
464 |
///if (valorDate.after(maxValueDate)) maxValueDate = valorDate; |
|
465 |
} else if (clave instanceof NullValue) { |
|
466 |
continue; |
|
467 |
} |
|
540 | 468 |
|
541 |
//intervals = arrayIntervalos; |
|
469 |
if (valor < minValue) { |
|
470 |
minValue = (double) valor; |
|
471 |
} |
|
542 | 472 |
|
543 |
FInterval elIntervalo; |
|
544 |
NumberFormat.getInstance().setMaximumFractionDigits(2); |
|
545 |
m_Renderer.clear(); |
|
473 |
if (valor > maxValue) { |
|
474 |
maxValue = (double) valor; |
|
475 |
} |
|
476 |
} |
|
546 | 477 |
|
547 |
int r; |
|
548 |
int g; |
|
549 |
int b; |
|
550 |
int stepR; |
|
551 |
int stepG; |
|
552 |
int stepB; |
|
553 |
r = startColor.getRed(); |
|
554 |
g = startColor.getGreen(); |
|
555 |
b = startColor.getBlue(); |
|
556 |
stepR = (endColor.getRed() - r) / arrayIntervalos.length; |
|
557 |
stepG = (endColor.getGreen() - g) / arrayIntervalos.length; |
|
558 |
stepB = (endColor.getBlue() - b) / arrayIntervalos.length; |
|
559 |
if (chkdefaultvalues.isSelected()){ |
|
560 |
auxLegend.getDefaultSymbol().setDescription("Default"); |
|
561 |
auxLegend.addSymbol(new NullInterval(),auxLegend.getDefaultSymbol()); |
|
562 |
} |
|
563 |
for (int k = 0; k < arrayIntervalos.length; k++) { |
|
564 |
elIntervalo = arrayIntervalos[k]; |
|
478 |
count++; |
|
479 |
} |
|
565 | 480 |
|
566 |
// clave = elIntervalo; // elIntervalo.getMin() + " - " + elIntervalo.getMax(); |
|
567 |
// System.out.println("k = " + k + " clave = " + clave); |
|
568 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo. |
|
569 |
// if (!m_Renderer.m_symbolList.containsKey(elIntervalo)) { |
|
570 |
//si no esta creado el simbolo se crea |
|
571 |
theSymbol = new FSymbol(symbolType, new Color(r, g, b)); |
|
572 |
theSymbol.setDescription(NumberFormat.getInstance().format(elIntervalo.getMin()) + |
|
573 |
" - " + |
|
574 |
NumberFormat.getInstance().format(elIntervalo.getMax())); |
|
481 |
switch (m_Renderer.getIntervalType()) { |
|
482 |
case VectorialIntervalLegend.EQUAL_INTERVALS: |
|
483 |
arrayIntervalos = calculateEqualIntervals(numIntervalos, |
|
484 |
minValue, maxValue, fieldName); |
|
575 | 485 |
|
576 |
////////////////////////////////////// |
|
577 |
// CALCULAMOS UN COLOR APROPIADO |
|
578 |
r = r + stepR; |
|
579 |
g = g + stepG; |
|
580 |
b = b + stepB; |
|
486 |
break; |
|
581 | 487 |
|
582 |
///////////////////////////////// |
|
583 |
auxLegend.addSymbol(elIntervalo, theSymbol); |
|
584 |
System.out.println("addSymbol = " + elIntervalo + |
|
585 |
" theSymbol = " + theSymbol.getDescription()); |
|
586 |
numSymbols++; |
|
488 |
case VectorialIntervalLegend.NATURAL_INTERVALS: |
|
489 |
arrayIntervalos = calculateNaturalIntervals(numIntervalos, |
|
490 |
minValue, maxValue, fieldName); |
|
587 | 491 |
|
588 |
if (numSymbols > 100) { |
|
589 |
JOptionPane.showMessageDialog(this, |
|
590 |
"M?s 100 de s?mbolos no aportan informaci?n en un plano. Por favor, revise el campo seleccionado."); |
|
492 |
break; |
|
591 | 493 |
|
592 |
break; |
|
593 |
} |
|
494 |
case VectorialIntervalLegend.QUANTILE_INTERVALS: |
|
495 |
arrayIntervalos = calculateQuantileIntervals(numIntervalos, |
|
496 |
minValue, maxValue, fieldName); |
|
594 | 497 |
|
595 |
// }
|
|
596 |
} // for
|
|
498 |
break;
|
|
499 |
}
|
|
597 | 500 |
|
598 |
System.out.println("Num. Simbolos = " + |
|
599 |
auxLegend.getValues().length); |
|
600 |
m_symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
|
601 |
auxLegend.getValues(), auxLegend.getDescriptions()); |
|
602 |
elRs.stop(); |
|
603 |
} catch (DriverException e) { |
|
604 |
// TODO Auto-generated catch block |
|
605 |
e.printStackTrace(); |
|
606 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
607 |
e.printStackTrace(); |
|
608 |
} |
|
501 |
//intervals = arrayIntervalos; |
|
502 |
FInterval elIntervalo; |
|
503 |
NumberFormat.getInstance().setMaximumFractionDigits(2); |
|
504 |
m_Renderer.clear(); |
|
609 | 505 |
|
610 |
bDelAll.setEnabled(true); |
|
611 |
bDel.setEnabled(true); |
|
612 |
} |
|
613 |
/** |
|
614 |
* EQUAL INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
615 |
* quieren crear. Los intervalos se crean con un tama?o igual entre ellos. |
|
616 |
* |
|
617 |
* @param numIntervals n?mero de intervalos |
|
618 |
* @param minValue Valor m?nimo. |
|
619 |
* @param maxValue Valor m?ximo. |
|
620 |
* |
|
621 |
* @return Array con los intervalos. |
|
622 |
*/ |
|
623 |
FInterval[] calculateEqualIntervals(int numIntervals, |
|
624 |
double minValue, double maxValue,String fieldName) { |
|
625 |
FInterval[] theIntervalArray = new FInterval[numIntervals]; |
|
626 |
double step = (maxValue - minValue) / numIntervals; |
|
506 |
int r; |
|
507 |
int g; |
|
508 |
int b; |
|
509 |
int stepR; |
|
510 |
int stepG; |
|
511 |
int stepB; |
|
512 |
r = startColor.getRed(); |
|
513 |
g = startColor.getGreen(); |
|
514 |
b = startColor.getBlue(); |
|
515 |
stepR = (endColor.getRed() - r) / arrayIntervalos.length; |
|
516 |
stepG = (endColor.getGreen() - g) / arrayIntervalos.length; |
|
517 |
stepB = (endColor.getBlue() - b) / arrayIntervalos.length; |
|
627 | 518 |
|
628 |
if (numIntervals>1){ |
|
629 |
theIntervalArray[0] = new FInterval(minValue,minValue+step); |
|
630 |
for (int i = 1; i < numIntervals-1; i++) { |
|
631 |
theIntervalArray[i] = new FInterval(minValue + (i * step)+0.01, |
|
632 |
minValue + ((i + 1) * step)); |
|
633 |
} |
|
634 |
theIntervalArray[numIntervals-1] = new FInterval(minValue + ((numIntervals-1) * step)+0.01,maxValue); |
|
635 |
}else{ |
|
636 |
theIntervalArray[0] = new FInterval(minValue, maxValue); |
|
637 |
} |
|
638 |
return theIntervalArray; |
|
639 |
|
|
640 |
} |
|
519 |
if (chkdefaultvalues.isSelected()) { |
|
520 |
auxLegend.getDefaultSymbol().setDescription("Default"); |
|
521 |
auxLegend.addSymbol(new NullInterval(), |
|
522 |
auxLegend.getDefaultSymbol()); |
|
523 |
} |
|
641 | 524 |
|
642 |
/** |
|
643 |
* NATURAL INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
644 |
* quieren crear. Los intervalos se distribuyen de forma natural. |
|
645 |
* |
|
646 |
* @param numIntervals n?mero de intervalos |
|
647 |
* @param minValue Valor m?nimo. |
|
648 |
* @param maxValue Valor m?ximo. |
|
649 |
* |
|
650 |
* @return Array con los intervalos. |
|
651 |
*/ |
|
652 |
FInterval[] calculateNaturalIntervals(int numIntervals, double minValue, |
|
653 |
double maxValue,String fieldName) { |
|
654 |
|
|
655 |
NaturalIntervalGenerator intervalGenerator = new NaturalIntervalGenerator(((AlphanumericData) m_lyr),fieldName,numIntervals); |
|
525 |
for (int k = 0; k < arrayIntervalos.length; k++) { |
|
526 |
elIntervalo = arrayIntervalos[k]; |
|
656 | 527 |
|
657 |
try { |
|
658 |
intervalGenerator.generarIntervalos(); |
|
659 |
} catch (DriverException e) { |
|
660 |
e.printStackTrace(); |
|
661 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
662 |
e.printStackTrace(); |
|
663 |
} |
|
664 |
int numIntervalsGen=intervalGenerator.getNumIntervals()-1; |
|
665 |
if (numIntervalsGen==-1){ |
|
666 |
//TODO cuando no puede calcular los intervalos. |
|
667 |
numIntervalsGen=1; |
|
668 |
} |
|
669 |
FInterval[] theIntervalArray = new FInterval[numIntervalsGen]; |
|
670 |
if (numIntervalsGen>1){ |
|
671 |
|
|
672 |
theIntervalArray[0] = new FInterval(minValue, intervalGenerator.getValorRuptura(0)); |
|
673 |
for (int i = 1; i < numIntervalsGen-1; i++) { |
|
674 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit( |
|
675 |
i-1), intervalGenerator.getValorRuptura(i)); |
|
676 |
} |
|
677 |
|
|
678 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getValInit( |
|
679 |
numIntervalsGen-2), maxValue); |
|
680 |
}else{ |
|
681 |
theIntervalArray[numIntervalsGen-1] = new FInterval(minValue, maxValue); |
|
682 |
} |
|
683 |
return theIntervalArray; |
|
684 |
} |
|
528 |
// clave = elIntervalo; // elIntervalo.getMin() + " - " + elIntervalo.getMax(); |
|
529 |
// System.out.println("k = " + k + " clave = " + clave); |
|
530 |
////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo. |
|
531 |
// if (!m_Renderer.m_symbolList.containsKey(elIntervalo)) { |
|
532 |
//si no esta creado el simbolo se crea |
|
533 |
theSymbol = new FSymbol(symbolType, new Color(r, g, b)); |
|
534 |
theSymbol.setDescription(NumberFormat.getInstance().format(elIntervalo.getMin()) + |
|
535 |
" - " + |
|
536 |
NumberFormat.getInstance().format(elIntervalo.getMax())); |
|
685 | 537 |
|
686 |
/** |
|
687 |
* QUANTILE INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
688 |
* quieren crear. Los intervalos se distribuyen de forma quantile. |
|
689 |
* |
|
690 |
* @param numIntervals n?mero de intervalos |
|
691 |
* @param minValue Valor m?nimo. |
|
692 |
* @param maxValue Valor m?ximo. |
|
693 |
* |
|
694 |
* @return Array con los intervalos. |
|
695 |
*/ |
|
696 |
FInterval[] calculateQuantileIntervals(int numIntervals, double minValue, |
|
697 |
double maxValue,String fieldName) { |
|
698 |
QuantileIntervalGenerator intervalGenerator = new QuantileIntervalGenerator(((AlphanumericData) m_lyr),fieldName,numIntervals); |
|
538 |
////////////////////////////////////// |
|
539 |
// CALCULAMOS UN COLOR APROPIADO |
|
540 |
r = r + stepR; |
|
541 |
g = g + stepG; |
|
542 |
b = b + stepB; |
|
699 | 543 |
|
700 |
try { |
|
701 |
intervalGenerator.generarIntervalos(); |
|
702 |
} catch (DriverException e) { |
|
703 |
e.printStackTrace(); |
|
704 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
705 |
e.printStackTrace(); |
|
706 |
} |
|
707 |
int numIntervalsGen=intervalGenerator.getNumIntervalGen(); |
|
708 |
FInterval[] theIntervalArray = new FInterval[numIntervalsGen]; |
|
709 |
if (intervalGenerator.getNumIntervalGen()>1){ |
|
710 |
theIntervalArray[0] = new FInterval(minValue, intervalGenerator.getValRuptura(0)); |
|
711 |
for (int i = 1; i < numIntervalsGen-1; i++) { |
|
712 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit( |
|
713 |
i-1), intervalGenerator.getValRuptura(i)); |
|
714 |
} |
|
715 |
|
|
716 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getValInit( |
|
717 |
numIntervalsGen-2), maxValue); |
|
718 |
}else{ |
|
719 |
theIntervalArray[numIntervalsGen-1] = new FInterval(minValue, maxValue); |
|
720 |
} |
|
721 |
return theIntervalArray; |
|
722 |
|
|
723 |
|
|
724 |
/* double numQ = count / numIntervals; |
|
544 |
///////////////////////////////// |
|
545 |
auxLegend.addSymbol(elIntervalo, theSymbol); |
|
546 |
System.out.println("addSymbol = " + elIntervalo + |
|
547 |
" theSymbol = " + theSymbol.getDescription()); |
|
548 |
numSymbols++; |
|
725 | 549 |
|
726 |
for (int i = 0; i < count; i++) { |
|
727 |
} |
|
550 |
if (numSymbols > 100) { |
|
551 |
JOptionPane.showMessageDialog(this, |
|
552 |
"M?s 100 de s?mbolos no aportan informaci?n en un plano. Por favor, revise el campo seleccionado."); |
|
728 | 553 |
|
729 |
return theIntervalArray; |
|
730 |
*/ |
|
731 |
} |
|
732 |
/** |
|
733 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#setLayer(com.iver.cit.gvsig.fmap.layers.FLayer, |
|
734 |
* com.iver.cit.gvsig.fmap.rendering.Legend) |
|
735 |
*/ |
|
736 |
public void setLayer(FLayer lyr, Legend r) { |
|
737 |
// m_TOC = t; |
|
738 |
// OJO, COMPROBAR ANTES SI ES DE TIPO VECTORIAL |
|
739 |
// m_lyr = (FLyrVect) t.getFirstLyrVectSelected(); |
|
740 |
m_lyr = (ClassifiableVectorial) lyr; |
|
741 |
fillFieldNames(); |
|
554 |
break; |
|
555 |
} |
|
742 | 556 |
|
743 |
if (r instanceof VectorialIntervalLegend) { |
|
744 |
m_Renderer = (VectorialIntervalLegend) r; |
|
745 |
cmbField.getModel().setSelectedItem(m_Renderer.getFieldName()); |
|
746 |
m_symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(), |
|
747 |
m_Renderer.getValues(), m_Renderer.getDescriptions()); |
|
748 |
colorChooserPanel.setColor(m_Renderer.getStartColor()); |
|
749 |
colorChooserPanel1.setColor(m_Renderer.getEndColor()); |
|
750 |
colorChooserPanel.repaint(); |
|
751 |
colorChooserPanel1.repaint(); |
|
752 |
} else { |
|
753 |
try { |
|
754 |
// Si la capa viene con otro tipo de leyenda, creamos |
|
755 |
// una nueva del tipo que maneja este panel |
|
756 |
m_Renderer = new VectorialIntervalLegend(m_lyr.getShapeType()); |
|
757 |
} catch (DriverException e) { |
|
758 |
// TODO Auto-generated catch block |
|
759 |
e.printStackTrace(); |
|
760 |
} |
|
761 |
} |
|
762 |
cmbFieldType.setSelectedIndex(m_Renderer.getIntervalType()); |
|
763 |
} |
|
764 |
/** |
|
765 |
* DOCUMENT ME! |
|
766 |
*/ |
|
767 |
private void fillFieldNames() { |
|
768 |
DataSource rs = null; |
|
769 |
ArrayList nomFields = null; |
|
557 |
// } |
|
558 |
} // for |
|
770 | 559 |
|
771 |
try { |
|
772 |
rs = ((AlphanumericData) m_lyr).getRecordset(); |
|
773 |
logger.debug("rs.start()"); |
|
774 |
rs.start(); |
|
560 |
System.out.println("Num. Simbolos = " + |
|
561 |
auxLegend.getValues().length); |
|
562 |
m_symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(), |
|
563 |
auxLegend.getValues(), auxLegend.getDescriptions()); |
|
564 |
elRs.stop(); |
|
565 |
} catch (DriverException e) { |
|
566 |
// TODO Auto-generated catch block |
|
567 |
e.printStackTrace(); |
|
568 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
569 |
e.printStackTrace(); |
|
570 |
} |
|
775 | 571 |
|
776 |
nomFields = new ArrayList(); |
|
572 |
bDelAll.setEnabled(true); |
|
573 |
bDel.setEnabled(true); |
|
574 |
} |
|
777 | 575 |
|
778 |
Value val; |
|
576 |
/** |
|
577 |
* EQUAL INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
578 |
* quieren crear. Los intervalos se crean con un tama?o igual entre ellos. |
|
579 |
* |
|
580 |
* @param numIntervals n?mero de intervalos |
|
581 |
* @param minValue Valor m?nimo. |
|
582 |
* @param maxValue Valor m?ximo. |
|
583 |
* @param fieldName Nombre del campo |
|
584 |
* |
|
585 |
* @return Array con los intervalos. |
|
586 |
*/ |
|
587 |
FInterval[] calculateEqualIntervals(int numIntervals, double minValue, |
|
588 |
double maxValue, String fieldName) { |
|
589 |
FInterval[] theIntervalArray = new FInterval[numIntervals]; |
|
590 |
double step = (maxValue - minValue) / numIntervals; |
|
779 | 591 |
|
780 |
for (int i = 0; i < rs.getFieldCount(); i++) { |
|
781 |
//TODO deber?a de existir un getFieldType |
|
782 |
val = rs.getFieldValue(0, i); |
|
592 |
if (numIntervals > 1) { |
|
593 |
theIntervalArray[0] = new FInterval(minValue, minValue + step); |
|
783 | 594 |
|
784 |
if (val.getClass() == NullValue.class) { |
|
785 |
continue; |
|
786 |
} |
|
595 |
for (int i = 1; i < (numIntervals - 1); i++) { |
|
596 |
theIntervalArray[i] = new FInterval(minValue + (i * step) + |
|
597 |
0.01, minValue + ((i + 1) * step)); |
|
598 |
} |
|
787 | 599 |
|
788 |
if ((val.getClass() == IntValue.class) || |
|
789 |
(val.getClass() == DoubleValue.class) || |
|
790 |
(val.getClass() == FloatValue.class) || |
|
791 |
(val.getClass() == LongValue.class)) { |
|
792 |
nomFields.add(rs.getFieldName(i).trim()); |
|
793 |
} |
|
794 |
} |
|
600 |
theIntervalArray[numIntervals - 1] = new FInterval(minValue + |
|
601 |
((numIntervals - 1) * step) + 0.01, maxValue); |
|
602 |
} else { |
|
603 |
theIntervalArray[0] = new FInterval(minValue, maxValue); |
|
604 |
} |
|
795 | 605 |
|
796 |
rs.stop(); |
|
797 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e1) { |
|
798 |
e1.printStackTrace(); |
|
799 |
} catch (DriverException e) { |
|
800 |
e.printStackTrace(); |
|
801 |
} |
|
606 |
return theIntervalArray; |
|
607 |
} |
|
802 | 608 |
|
803 |
/* ArrayList nomFields = new ArrayList(); |
|
804 |
for (int i = 0; i < rs.getFieldsCount(); i++) { |
|
805 |
if ((rs.getFieldType(i) == FRecordset.INTEGER) || |
|
806 |
(rs.getFieldType(i) == FRecordset.DECIMAL) || |
|
807 |
(rs.getFieldType(i) == FRecordset.DATE)) |
|
808 |
{ |
|
809 |
nomFields.add(rs.getFieldName(i).trim()); |
|
810 |
} |
|
811 |
|
|
812 |
} |
|
813 |
*/ |
|
814 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields.toArray()); |
|
815 |
cmbField.setModel(cM); |
|
609 |
/** |
|
610 |
* NATURAL INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
611 |
* quieren crear. Los intervalos se distribuyen de forma natural. |
|
612 |
* |
|
613 |
* @param numIntervals n?mero de intervalos |
|
614 |
* @param minValue Valor m?nimo. |
|
615 |
* @param maxValue Valor m?ximo. |
|
616 |
* @param fieldName Nombre del campo |
|
617 |
* |
|
618 |
* @return Array con los intervalos. |
|
619 |
*/ |
|
620 |
FInterval[] calculateNaturalIntervals(int numIntervals, double minValue, |
|
621 |
double maxValue, String fieldName) { |
|
622 |
NaturalIntervalGenerator intervalGenerator = new NaturalIntervalGenerator(((AlphanumericData) m_lyr), |
|
623 |
fieldName, numIntervals); |
|
816 | 624 |
|
817 |
// fieldsListValor.setSelectedIndex(0); |
|
818 |
m_symbolTable.removeAllItems(); |
|
819 |
} |
|
625 |
try { |
|
626 |
intervalGenerator.generarIntervalos(); |
|
627 |
} catch (DriverException e) { |
|
628 |
e.printStackTrace(); |
|
629 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
630 |
e.printStackTrace(); |
|
631 |
} |
|
820 | 632 |
|
821 |
/** |
|
822 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend() |
|
823 |
*/ |
|
824 |
public Legend getLegend() { |
|
825 |
fillSymbolListFromTable(); |
|
826 |
if (auxLegend != null){ |
|
827 |
m_Renderer.setDefaultSymbol(auxLegend.getDefaultSymbol()); |
|
828 |
m_Renderer.useDefaultSymbol(chkdefaultvalues.isSelected()); |
|
829 |
} |
|
830 |
return m_Renderer; |
|
831 |
} |
|
832 |
/** |
|
833 |
* A partir de los registros de la tabla, regenera el FRenderer. (No solo |
|
834 |
* el symbolList, si no tambi?n el arrayKeys y el defaultRenderer |
|
835 |
*/ |
|
836 |
private void fillSymbolListFromTable() { |
|
837 |
//String clave; |
|
838 |
FSymbol theSymbol; |
|
839 |
IInterval theInterval = null; |
|
633 |
int numIntervalsGen = intervalGenerator.getNumIntervals() - 1; |
|
840 | 634 |
|
841 |
// Borramos las anteriores listas: |
|
842 |
m_Renderer.clear(); |
|
635 |
if (numIntervalsGen == -1) { |
|
636 |
//TODO cuando no puede calcular los intervalos. |
|
637 |
numIntervalsGen = 1; |
|
638 |
} |
|
843 | 639 |
|
844 |
//boolean bRestoValores = false; // PONERLO EN UN CHECKBOX |
|
845 |
//double from = 0; |
|
846 |
//double to = 0; |
|
847 |
//String[] arraySplit = new String[2]; |
|
848 |
//int hasta; |
|
849 |
String fieldName = (String) cmbField.getSelectedItem(); |
|
850 |
m_Renderer.setFieldName(fieldName); |
|
640 |
FInterval[] theIntervalArray = new FInterval[numIntervalsGen]; |
|
851 | 641 |
|
852 |
/*if (bRestoValores) { |
|
853 |
hasta = m_symbolTable.getRowCount() - 1; |
|
854 |
} else { |
|
855 |
hasta = m_symbolTable.getRowCount(); |
|
856 |
} |
|
857 |
*/ |
|
858 |
for (int row = 0; row < m_symbolTable.getRowCount(); row++) { |
|
859 |
// clave = m_symbolTable.getFieldValue(row,1); |
|
860 |
if (!(m_symbolTable.getFieldValue(row, 1) instanceof FInterval)){ |
|
861 |
theSymbol = (FSymbol) m_symbolTable.getFieldValue(row, 0); |
|
862 |
theSymbol.setDescription((String) m_symbolTable.getFieldValue(row, 2)); |
|
863 |
m_Renderer.addSymbol(new NullInterval(), theSymbol); |
|
864 |
}else{ |
|
865 |
theInterval = (IInterval) m_symbolTable.getFieldValue(row, 1); |
|
866 |
theSymbol = (FSymbol) m_symbolTable.getFieldValue(row, 0); |
|
867 |
theSymbol.setDescription((String) m_symbolTable.getFieldValue(row, 2)); |
|
868 |
m_Renderer.addSymbol(theInterval, theSymbol); |
|
869 |
} |
|
870 |
///m_Renderer.m_legendIntervals.add(theInterval); |
|
871 |
} |
|
642 |
if (numIntervalsGen > 1) { |
|
643 |
theIntervalArray[0] = new FInterval(minValue, |
|
644 |
intervalGenerator.getValorRuptura(0)); |
|
872 | 645 |
|
873 |
/* if (bRestoValores) { |
|
874 |
//m_Renderer.m_bUseDefaultSymbol = true; |
|
875 |
theSymbol = (FSymbol) m_symbolTable.getFieldValue(hasta, 0); |
|
876 |
m_Renderer.setDefaultSymbol(theSymbol); |
|
877 |
}*/ |
|
878 |
} |
|
646 |
for (int i = 1; i < (numIntervalsGen - 1); i++) { |
|
647 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit(i - |
|
648 |
1), intervalGenerator.getValorRuptura(i)); |
|
649 |
} |
|
879 | 650 |
|
880 |
/** |
|
881 |
* This method initializes panelC |
|
882 |
* |
|
883 |
* @return javax.swing.JPanel |
|
884 |
*/ |
|
885 |
private JPanel getPanelC() { |
|
886 |
if (panelC == null) { |
|
887 |
panelC = new JPanel(); |
|
888 |
panelC.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
|
889 |
panelC.setPreferredSize(new java.awt.Dimension(420,200)); |
|
890 |
panelC.add(m_symbolTable); |
|
891 |
} |
|
892 |
return panelC; |
|
893 |
} |
|
894 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
651 |
theIntervalArray[numIntervalsGen - 1] = new FInterval(intervalGenerator.getValInit(numIntervalsGen - |
|
652 |
2), maxValue); |
|
653 |
} else { |
|
654 |
theIntervalArray[numIntervalsGen - 1] = new FInterval(minValue, |
|
655 |
maxValue); |
|
656 |
} |
|
657 |
|
|
658 |
return theIntervalArray; |
|
659 |
} |
|
660 |
|
|
661 |
/** |
|
662 |
* QUANTILE INTERVAL Devuelve un Array con el n?mero de intervalos que se |
|
663 |
* quieren crear. Los intervalos se distribuyen de forma quantile. |
|
664 |
* |
|
665 |
* @param numIntervals n?mero de intervalos |
|
666 |
* @param minValue Valor m?nimo. |
|
667 |
* @param maxValue Valor m?ximo. |
|
668 |
* @param fieldName Nombre del campo |
|
669 |
* |
|
670 |
* @return Array con los intervalos. |
|
671 |
*/ |
|
672 |
FInterval[] calculateQuantileIntervals(int numIntervals, double minValue, |
|
673 |
double maxValue, String fieldName) { |
|
674 |
QuantileIntervalGenerator intervalGenerator = new QuantileIntervalGenerator(((AlphanumericData) m_lyr), |
|
675 |
fieldName, numIntervals); |
|
676 |
|
|
677 |
try { |
|
678 |
intervalGenerator.generarIntervalos(); |
|
679 |
} catch (DriverException e) { |
|
680 |
e.printStackTrace(); |
|
681 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
682 |
e.printStackTrace(); |
|
683 |
} |
|
684 |
|
|
685 |
int numIntervalsGen = intervalGenerator.getNumIntervalGen(); |
|
686 |
FInterval[] theIntervalArray = new FInterval[numIntervalsGen]; |
|
687 |
|
|
688 |
if (intervalGenerator.getNumIntervalGen() > 1) { |
|
689 |
theIntervalArray[0] = new FInterval(minValue, |
|
690 |
intervalGenerator.getValRuptura(0)); |
|
691 |
|
|
692 |
for (int i = 1; i < (numIntervalsGen - 1); i++) { |
|
693 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit(i - |
|
694 |
1), intervalGenerator.getValRuptura(i)); |
|
695 |
} |
|
696 |
|
|
697 |
theIntervalArray[numIntervalsGen - 1] = new FInterval(intervalGenerator.getValInit(numIntervalsGen - |
|
698 |
2), maxValue); |
|
699 |
} else { |
|
700 |
theIntervalArray[numIntervalsGen - 1] = new FInterval(minValue, |
|
701 |
maxValue); |
|
702 |
} |
|
703 |
|
|
704 |
return theIntervalArray; |
|
705 |
|
|
706 |
/* double numQ = count / numIntervals; |
|
707 |
for (int i = 0; i < count; i++) { |
|
708 |
} |
|
709 |
return theIntervalArray; |
|
710 |
*/ |
|
711 |
} |
|
712 |
|
|
713 |
/** |
|
714 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#setLayer(com.iver.cit.gvsig.fmap.layers.FLayer, |
|
715 |
* com.iver.cit.gvsig.fmap.rendering.Legend) |
|
716 |
*/ |
|
717 |
public void setLayer(FLayer lyr, Legend r) { |
|
718 |
// m_TOC = t; |
|
719 |
// OJO, COMPROBAR ANTES SI ES DE TIPO VECTORIAL |
|
720 |
// m_lyr = (FLyrVect) t.getFirstLyrVectSelected(); |
|
721 |
m_lyr = (ClassifiableVectorial) lyr; |
|
722 |
fillFieldNames(); |
|
723 |
|
|
724 |
if (r instanceof VectorialIntervalLegend) { |
|
725 |
m_Renderer = (VectorialIntervalLegend) r; |
|
726 |
cmbField.getModel().setSelectedItem(m_Renderer.getFieldName()); |
|
727 |
m_symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(), |
|
728 |
m_Renderer.getValues(), m_Renderer.getDescriptions()); |
|
729 |
colorChooserPanel.setColor(m_Renderer.getStartColor()); |
|
730 |
colorChooserPanel1.setColor(m_Renderer.getEndColor()); |
|
731 |
colorChooserPanel.repaint(); |
|
732 |
colorChooserPanel1.repaint(); |
|
733 |
} else { |
|
734 |
try { |
|
735 |
// Si la capa viene con otro tipo de leyenda, creamos |
|
736 |
// una nueva del tipo que maneja este panel |
|
737 |
m_Renderer = new VectorialIntervalLegend(m_lyr.getShapeType()); |
|
738 |
} catch (DriverException e) { |
|
739 |
// TODO Auto-generated catch block |
|
740 |
e.printStackTrace(); |
|
741 |
} |
|
742 |
} |
|
743 |
|
|
744 |
cmbFieldType.setSelectedIndex(m_Renderer.getIntervalType()); |
|
745 |
} |
|
746 |
|
|
747 |
/** |
|
748 |
* DOCUMENT ME! |
|
749 |
*/ |
|
750 |
private void fillFieldNames() { |
|
751 |
DataSource rs = null; |
|
752 |
ArrayList nomFields = null; |
|
753 |
|
|
754 |
try { |
|
755 |
rs = ((AlphanumericData) m_lyr).getRecordset(); |
|
756 |
logger.debug("rs.start()"); |
|
757 |
rs.start(); |
|
758 |
|
|
759 |
nomFields = new ArrayList(); |
|
760 |
|
|
761 |
Value val; |
|
762 |
|
|
763 |
for (int i = 0; i < rs.getFieldCount(); i++) { |
|
764 |
//TODO deber?a de existir un getFieldType |
|
765 |
val = rs.getFieldValue(0, i); |
|
766 |
|
|
767 |
if (val.getClass() == NullValue.class) { |
|
768 |
continue; |
|
769 |
} |
|
770 |
|
|
771 |
if ((val.getClass() == IntValue.class) || |
|
772 |
(val.getClass() == DoubleValue.class) || |
|
773 |
(val.getClass() == FloatValue.class) || |
|
774 |
(val.getClass() == LongValue.class)) { |
|
775 |
nomFields.add(rs.getFieldName(i).trim()); |
|
776 |
} |
|
777 |
} |
|
778 |
|
|
779 |
rs.stop(); |
|
780 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e1) { |
|
781 |
e1.printStackTrace(); |
|
782 |
} catch (DriverException e) { |
|
783 |
e.printStackTrace(); |
|
784 |
} |
|
785 |
|
|
786 |
/* ArrayList nomFields = new ArrayList(); |
|
787 |
for (int i = 0; i < rs.getFieldsCount(); i++) { |
|
788 |
if ((rs.getFieldType(i) == FRecordset.INTEGER) || |
|
789 |
(rs.getFieldType(i) == FRecordset.DECIMAL) || |
|
790 |
(rs.getFieldType(i) == FRecordset.DATE)) |
|
791 |
{ |
|
792 |
nomFields.add(rs.getFieldName(i).trim()); |
|
793 |
} |
|
794 |
|
|
795 |
} |
|
796 |
*/ |
|
797 |
DefaultComboBoxModel cM = new DefaultComboBoxModel(nomFields.toArray()); |
|
798 |
cmbField.setModel(cM); |
|
799 |
|
|
800 |
// fieldsListValor.setSelectedIndex(0); |
|
801 |
m_symbolTable.removeAllItems(); |
|
802 |
} |
|
803 |
|
|
804 |
/** |
|
805 |
* @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend() |
|
806 |
*/ |
Also available in: Unified diff