Revision 17626
trunk/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/wizard/servicearea/ServiceAreaPage0.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.graph.gui.wizard.servicearea; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.GridBagConstraints; |
|
6 |
import java.awt.GridBagLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
import javax.swing.ButtonGroup; |
|
12 |
import javax.swing.JButton; |
|
13 |
import javax.swing.JComboBox; |
|
14 |
import javax.swing.JLabel; |
|
15 |
import javax.swing.JOptionPane; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.JRadioButton; |
|
18 |
import javax.swing.JScrollPane; |
|
19 |
import javax.swing.JTabbedPane; |
|
20 |
import javax.swing.JTable; |
|
21 |
import javax.swing.border.TitledBorder; |
|
22 |
import javax.swing.table.AbstractTableModel; |
|
23 |
import javax.swing.table.TableColumnModel; |
|
24 |
|
|
25 |
import jwizardcomponent.JWizardPanel; |
|
26 |
|
|
27 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
28 |
import com.hardcode.gdbms.engine.values.Value; |
|
29 |
import com.iver.andami.PluginServices; |
|
30 |
import com.iver.andami.plugins.IExtension; |
|
31 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
32 |
import com.iver.cit.gvsig.AddLayer; |
|
33 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
34 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
35 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
|
36 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
37 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
38 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
39 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
|
40 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionListener; |
|
41 |
import com.iver.cit.gvsig.fmap.layers.LayerPositionEvent; |
|
42 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
43 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
|
44 |
import com.iver.cit.gvsig.graph.core.Network; |
|
45 |
import com.iver.cit.gvsig.graph.gui.wizard.servicearea.AbstractPointsModel.InvalidCostFieldException; |
|
46 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
47 |
|
|
48 |
public class ServiceAreaPage0 extends JWizardPanel implements ActionListener, LayerCollectionListener{ |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
*/ |
|
53 |
private static final long serialVersionUID = -5424586431273891364L; |
|
54 |
|
|
55 |
private Logger logger; |
|
56 |
private MapContext mc; |
|
57 |
private ServiceAreaWizard owner; |
|
58 |
private PreviewFLyerVectPointsModel layerModel; |
|
59 |
private PreviewNetworkPointsModel networkModel; |
|
60 |
private Network network; |
|
61 |
|
|
62 |
private JPanel contentPane; |
|
63 |
|
|
64 |
private GridBagLayout gridbagSelection; |
|
65 |
private GridBagConstraints cSelection; |
|
66 |
private JPanel panelSourcePointsSelection; |
|
67 |
private TitledBorder borderSourcePointsSelection; |
|
68 |
private JLabel labelSourcePointsSelection; |
|
69 |
private JRadioButton radioSourcePointsSelectionFromLayer; |
|
70 |
private JRadioButton radioSourcePointsSelectionFromNetwork; |
|
71 |
private ButtonGroup groupSourcePointsSelection; |
|
72 |
|
|
73 |
private JPanel panelSelection; |
|
74 |
private JTabbedPane tabbedSelection; |
|
75 |
|
|
76 |
private JPanel panelSourcePointsSelectionFromLayer; |
|
77 |
private JPanel panelSourcePointsSelectionFromLayerCombos; |
|
78 |
private JPanel panelSourcePointsSelectionFromLayerPreview; |
|
79 |
private TitledBorder borderSourcePointsSelecionFromLayer; |
|
80 |
private JLabel labelSourcePointsSelectionFromLayerName; |
|
81 |
private JComboBox comboSourcePointsSelectionFromLayerName; |
|
82 |
private JButton buttonSourcePointsSelectionFromLayerAdd; |
|
83 |
private JLabel labelSourcePointsSelectionFromLayerMainCostField; |
|
84 |
private JComboBox comboSourcePointsSelectionFromLayerMainCostField; |
|
85 |
private JLabel labelSourcePointsSelectionFromLayerSecondaryCostField; |
|
86 |
private JComboBox comboSourcePointsSelectionFromLayerSecondaryCostField; |
|
87 |
private JLabel labelSourcePointsSelectionFromLayerPreview; |
|
88 |
private JTable tableSourcePointsSelectionFromLayerPreview; |
|
89 |
private JScrollPane scrollSourcePointsSelectionFromLayerPreview; |
|
90 |
|
|
91 |
private JPanel panelSourcePointsSelectionFromNetwork; |
|
92 |
private TitledBorder borderSourcePointsSelectionFromNetwork; |
|
93 |
private JLabel labelSourcePointsSelectionFromNetworkList; |
|
94 |
private JScrollPane scrollSourcePointsSelectionFromNetworkList; |
|
95 |
private JTable tableSourcePointsSelectionFromNetworkList; |
|
96 |
private JLabel labelSourcePointsSelectionFromNetworkNote; |
|
97 |
|
|
98 |
private static final int BORDER_HGAP = 7; |
|
99 |
private static final int BORDER_VGAP = 7; |
|
100 |
private static final int COMPONENT_HGAP = 4; |
|
101 |
private static final int COMPONENT_VGAP = 4; |
|
102 |
private static final int PREFERRED_HEIGHT = 23; |
|
103 |
private static final int PREFERRED_WIDTH = 120; |
|
104 |
|
|
105 |
public ServiceAreaPage0(ServiceAreaWizard wizard){ |
|
106 |
super(wizard.getWizardComponents()); |
|
107 |
|
|
108 |
this.logger=Logger.getLogger(this.getClass().getName()); |
|
109 |
|
|
110 |
this.owner=wizard; |
|
111 |
|
|
112 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
|
113 |
this.mc=null; |
|
114 |
if(window instanceof View){ |
|
115 |
this.mc=((View)window).getMapControl().getMapContext(); |
|
116 |
} |
|
117 |
|
|
118 |
this.layerModel=null; |
|
119 |
this.networkModel=null; |
|
120 |
|
|
121 |
this.initialize(); |
|
122 |
|
|
123 |
if(this.mc!=null){ |
|
124 |
int layersCount=this.mc.getLayers().getLayersCount(); |
|
125 |
this.comboSourcePointsSelectionFromLayerName.removeAllItems(); |
|
126 |
FLayer layer; |
|
127 |
for (int i = 0; i < layersCount; i++) { |
|
128 |
this.mc.getLayers().addLayerCollectionListener(this); |
|
129 |
layer=this.mc.getLayers().getLayer(i); |
|
130 |
if(layer instanceof FLyrVect){ |
|
131 |
try { |
|
132 |
if(((FLyrVect)layer).getShapeType()==FShape.POINT){ |
|
133 |
this.comboSourcePointsSelectionFromLayerName.addItem(layer.getName()); |
|
134 |
} |
|
135 |
} catch (ReadDriverException except) { |
|
136 |
this.logger.warning(except.getMessage()); |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
this.comboSourcePointsSelectionFromLayerName.addActionListener(this); |
|
143 |
if(this.comboSourcePointsSelectionFromLayerName.getItemCount()>0) this.comboSourcePointsSelectionFromLayerName.setSelectedIndex(0); |
|
144 |
} |
|
145 |
|
|
146 |
private void initialize(){ |
|
147 |
this.contentPane=new JPanel(); |
|
148 |
|
|
149 |
this.gridbagSelection=new GridBagLayout(); |
|
150 |
this.cSelection=new GridBagConstraints(); |
|
151 |
this.panelSourcePointsSelection=new JPanel(); |
|
152 |
this.borderSourcePointsSelection=new TitledBorder("Fuente de los puntos"); |
|
153 |
this.panelSourcePointsSelection.setBorder(this.borderSourcePointsSelection); |
|
154 |
this.labelSourcePointsSelection=new JLabel("Obtener puntos a partir de:"); |
|
155 |
this.groupSourcePointsSelection=new ButtonGroup(); |
|
156 |
this.radioSourcePointsSelectionFromLayer=new JRadioButton("Capa de puntos"); |
|
157 |
this.radioSourcePointsSelectionFromNetwork=new JRadioButton("Gestor de paradas"); |
|
158 |
this.groupSourcePointsSelection.add(this.radioSourcePointsSelectionFromLayer); |
|
159 |
this.groupSourcePointsSelection.add(this.radioSourcePointsSelectionFromNetwork); |
|
160 |
this.radioSourcePointsSelectionFromLayer.addActionListener(this); |
|
161 |
this.radioSourcePointsSelectionFromNetwork.addActionListener(this); |
|
162 |
this.radioSourcePointsSelectionFromLayer.setSelected(true); |
|
163 |
|
|
164 |
this.panelSelection=new JPanel(); |
|
165 |
this.panelSelection.setLayout(new BorderLayout(7, 7)); |
|
166 |
this.tabbedSelection=new JTabbedPane(); |
|
167 |
this.panelSelection.add(this.tabbedSelection, BorderLayout.CENTER); |
|
168 |
|
|
169 |
this.panelSourcePointsSelectionFromLayer=new JPanel(); |
|
170 |
this.panelSourcePointsSelectionFromLayerCombos=new JPanel(); |
|
171 |
this.panelSourcePointsSelectionFromLayerPreview=new JPanel(); |
|
172 |
this.borderSourcePointsSelecionFromLayer=new TitledBorder("Desde una capa"); |
|
173 |
this.panelSourcePointsSelectionFromLayer.setBorder(this.borderSourcePointsSelecionFromLayer); |
|
174 |
this.labelSourcePointsSelectionFromLayerName=new JLabel("Capa:", JLabel.RIGHT); |
|
175 |
this.comboSourcePointsSelectionFromLayerName=new JComboBox(); |
|
176 |
this.comboSourcePointsSelectionFromLayerName.setPreferredSize(new Dimension(30, 23)); |
|
177 |
this.buttonSourcePointsSelectionFromLayerAdd=new JButton(PluginServices.getIconTheme().get("layer-add")); |
|
178 |
this.buttonSourcePointsSelectionFromLayerAdd.addActionListener(this); |
|
179 |
this.labelSourcePointsSelectionFromLayerMainCostField=new JLabel("Coste primario:", JLabel.RIGHT); |
|
180 |
this.comboSourcePointsSelectionFromLayerMainCostField=new JComboBox(); |
|
181 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField=new JLabel("Coste secundario:", JLabel.RIGHT); |
|
182 |
this.comboSourcePointsSelectionFromLayerSecondaryCostField=new JComboBox(); |
|
183 |
this.comboSourcePointsSelectionFromLayerMainCostField.setPreferredSize(new Dimension(30, 23)); |
|
184 |
this.labelSourcePointsSelectionFromLayerPreview=new JLabel("Vista previa", JLabel.LEFT); |
|
185 |
this.scrollSourcePointsSelectionFromLayerPreview=new JScrollPane(); |
|
186 |
this.tableSourcePointsSelectionFromLayerPreview=new JTable(); |
|
187 |
this.scrollSourcePointsSelectionFromLayerPreview.getViewport().add(this.tableSourcePointsSelectionFromLayerPreview); |
|
188 |
this.scrollSourcePointsSelectionFromLayerPreview.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
189 |
this.scrollSourcePointsSelectionFromLayerPreview.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
190 |
|
|
191 |
this.panelSourcePointsSelectionFromNetwork=new JPanel(); |
|
192 |
this.panelSourcePointsSelectionFromNetwork.setLayout(new BorderLayout(BORDER_HGAP, BORDER_VGAP)); |
|
193 |
this.borderSourcePointsSelectionFromNetwork=new TitledBorder("Desde el gestor de paradas"); |
|
194 |
this.panelSourcePointsSelectionFromNetwork.setBorder(this.borderSourcePointsSelectionFromNetwork); |
|
195 |
this.labelSourcePointsSelectionFromNetworkList=new JLabel("Lista de paradas", JLabel.CENTER); |
|
196 |
this.scrollSourcePointsSelectionFromNetworkList=new JScrollPane(); |
|
197 |
this.tableSourcePointsSelectionFromNetworkList=new JTable(); |
|
198 |
this.scrollSourcePointsSelectionFromNetworkList.getViewport().add(this.tableSourcePointsSelectionFromNetworkList); |
|
199 |
this.scrollSourcePointsSelectionFromNetworkList.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
200 |
this.scrollSourcePointsSelectionFromNetworkList.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
201 |
this.labelSourcePointsSelectionFromNetworkNote=new JLabel("<html><p>NOTA: Las paradas se podr?n gestionar en el siguiente paso</p></html>"); |
|
202 |
|
|
203 |
this.contentPane.setLayout(new BorderLayout(7, 7)); |
|
204 |
|
|
205 |
this.panelSourcePointsSelection.setLayout(this.gridbagSelection); |
|
206 |
|
|
207 |
this.cSelection.fill=GridBagConstraints.NONE; |
|
208 |
this.cSelection.weightx=1.0; |
|
209 |
this.cSelection.gridwidth=GridBagConstraints.REMAINDER; |
|
210 |
|
|
211 |
this.gridbagSelection.setConstraints(this.labelSourcePointsSelection, this.cSelection); |
|
212 |
this.cSelection.gridwidth=GridBagConstraints.RELATIVE; |
|
213 |
this.gridbagSelection.setConstraints(this.radioSourcePointsSelectionFromLayer, this.cSelection); |
|
214 |
this.cSelection.gridwidth=GridBagConstraints.REMAINDER; |
|
215 |
this.gridbagSelection.setConstraints(this.radioSourcePointsSelectionFromLayer, this.cSelection); |
|
216 |
|
|
217 |
this.panelSourcePointsSelection.add(this.labelSourcePointsSelection); |
|
218 |
this.panelSourcePointsSelection.add(this.radioSourcePointsSelectionFromLayer); |
|
219 |
this.panelSourcePointsSelection.add(this.radioSourcePointsSelectionFromNetwork); |
|
220 |
|
|
221 |
this.contentPane.add(this.panelSourcePointsSelection, BorderLayout.NORTH); |
|
222 |
this.contentPane.add(this.panelSelection, BorderLayout.CENTER); |
|
223 |
|
|
224 |
this.panelSourcePointsSelectionFromLayerCombos.setLayout(null); |
|
225 |
this.panelSourcePointsSelectionFromLayerCombos.setSize(0, 30*3); |
|
226 |
this.panelSourcePointsSelectionFromLayerCombos.setPreferredSize(new Dimension(0, 30*3)); |
|
227 |
|
|
228 |
this.labelSourcePointsSelectionFromLayerName.setSize(this.labelSourcePointsSelectionFromLayerName.getFontMetrics(this.labelSourcePointsSelectionFromLayerName.getFont()).stringWidth(this.labelSourcePointsSelectionFromLayerName.getText()), PREFERRED_HEIGHT); |
|
229 |
this.labelSourcePointsSelectionFromLayerMainCostField.setSize(this.labelSourcePointsSelectionFromLayerMainCostField.getFontMetrics(this.labelSourcePointsSelectionFromLayerMainCostField.getFont()).stringWidth(this.labelSourcePointsSelectionFromLayerMainCostField.getText()), PREFERRED_HEIGHT); |
|
230 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField.setSize(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getFontMetrics(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getFont()).stringWidth(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getText()), PREFERRED_HEIGHT); |
|
231 |
|
|
232 |
if(this.labelSourcePointsSelectionFromLayerName.getWidth()>this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()){ |
|
233 |
if(this.labelSourcePointsSelectionFromLayerName.getWidth()>this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()){ |
|
234 |
//Label Name has the biggest width |
|
235 |
|
|
236 |
this.labelSourcePointsSelectionFromLayerName.setLocation(BORDER_HGAP, BORDER_VGAP); |
|
237 |
this.labelSourcePointsSelectionFromLayerMainCostField.setLocation((this.labelSourcePointsSelectionFromLayerName.getWidth()-this.labelSourcePointsSelectionFromLayerMainCostField.getWidth())+BORDER_HGAP, this.labelSourcePointsSelectionFromLayerName.getY()+this.labelSourcePointsSelectionFromLayerName.getHeight()+COMPONENT_VGAP); |
|
238 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField.setLocation(this.labelSourcePointsSelectionFromLayerName.getWidth()-this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()+BORDER_HGAP, this.labelSourcePointsSelectionFromLayerMainCostField.getY()+this.labelSourcePointsSelectionFromLayerMainCostField.getHeight()+COMPONENT_VGAP); |
|
239 |
} |
|
240 |
else{ |
|
241 |
//Label Secondary Cost has the biggest width |
|
242 |
|
|
243 |
this.labelSourcePointsSelectionFromLayerName.setLocation(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()-this.labelSourcePointsSelectionFromLayerName.getWidth()+BORDER_HGAP, BORDER_VGAP); |
|
244 |
this.labelSourcePointsSelectionFromLayerMainCostField.setLocation(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()-this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()+BORDER_HGAP, this.labelSourcePointsSelectionFromLayerSecondaryCostField.getY()+this.labelSourcePointsSelectionFromLayerSecondaryCostField.getHeight()+COMPONENT_VGAP); |
|
245 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField.setLocation(BORDER_HGAP, this.labelSourcePointsSelectionFromLayerName.getY()+this.labelSourcePointsSelectionFromLayerName.getHeight()+COMPONENT_VGAP); |
|
246 |
} |
|
247 |
} |
|
248 |
else{ |
|
249 |
if(this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()>this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()){ |
|
250 |
//Label Main Cost has the biggest width |
|
251 |
|
|
252 |
this.labelSourcePointsSelectionFromLayerName.setLocation(this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()-this.labelSourcePointsSelectionFromLayerName.getWidth()+BORDER_HGAP, BORDER_VGAP); |
|
253 |
this.labelSourcePointsSelectionFromLayerMainCostField.setLocation(BORDER_HGAP, this.labelSourcePointsSelectionFromLayerName.getY()+this.labelSourcePointsSelectionFromLayerName.getHeight()+COMPONENT_VGAP); |
|
254 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField.setLocation(this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()-this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()+BORDER_HGAP, this.labelSourcePointsSelectionFromLayerMainCostField.getY()+this.labelSourcePointsSelectionFromLayerMainCostField.getHeight()+COMPONENT_VGAP); |
|
255 |
} |
|
256 |
else{ |
|
257 |
//Label Secondary Cost has the biggest width |
|
258 |
|
|
259 |
this.labelSourcePointsSelectionFromLayerName.setLocation(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()-this.labelSourcePointsSelectionFromLayerName.getWidth()+BORDER_HGAP, BORDER_VGAP); |
|
260 |
this.labelSourcePointsSelectionFromLayerMainCostField.setLocation(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()-this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()+BORDER_HGAP, this.labelSourcePointsSelectionFromLayerName.getY()+this.labelSourcePointsSelectionFromLayerName.getHeight()+COMPONENT_VGAP); |
|
261 |
this.labelSourcePointsSelectionFromLayerSecondaryCostField.setLocation(BORDER_HGAP, this.labelSourcePointsSelectionFromLayerMainCostField.getY()+this.labelSourcePointsSelectionFromLayerMainCostField.getHeight()+COMPONENT_VGAP); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
this.comboSourcePointsSelectionFromLayerName.setBounds(this.labelSourcePointsSelectionFromLayerName.getX()+this.labelSourcePointsSelectionFromLayerName.getWidth()+COMPONENT_HGAP, this.labelSourcePointsSelectionFromLayerName.getY(), PREFERRED_WIDTH, PREFERRED_HEIGHT); |
|
266 |
this.comboSourcePointsSelectionFromLayerMainCostField.setBounds(this.labelSourcePointsSelectionFromLayerMainCostField.getX()+this.labelSourcePointsSelectionFromLayerMainCostField.getWidth()+4, this.labelSourcePointsSelectionFromLayerMainCostField.getY(), PREFERRED_WIDTH, PREFERRED_HEIGHT); |
|
267 |
this.comboSourcePointsSelectionFromLayerSecondaryCostField.setBounds(this.labelSourcePointsSelectionFromLayerSecondaryCostField.getX()+this.labelSourcePointsSelectionFromLayerSecondaryCostField.getWidth()+COMPONENT_HGAP, this.labelSourcePointsSelectionFromLayerSecondaryCostField.getY(), PREFERRED_WIDTH, PREFERRED_HEIGHT); |
|
268 |
this.buttonSourcePointsSelectionFromLayerAdd.setBounds(this.comboSourcePointsSelectionFromLayerName.getX()+this.comboSourcePointsSelectionFromLayerName.getWidth()+4, this.labelSourcePointsSelectionFromLayerName.getY(), 23, PREFERRED_HEIGHT); |
|
269 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.labelSourcePointsSelectionFromLayerName); |
|
270 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.comboSourcePointsSelectionFromLayerName); |
|
271 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.labelSourcePointsSelectionFromLayerMainCostField); |
|
272 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.comboSourcePointsSelectionFromLayerMainCostField); |
|
273 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.labelSourcePointsSelectionFromLayerSecondaryCostField); |
|
274 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.comboSourcePointsSelectionFromLayerSecondaryCostField); |
|
275 |
this.panelSourcePointsSelectionFromLayerCombos.add(this.buttonSourcePointsSelectionFromLayerAdd); |
|
276 |
|
|
277 |
this.panelSourcePointsSelectionFromLayerPreview.setLayout(new BorderLayout(BORDER_HGAP, BORDER_VGAP)); |
|
278 |
this.panelSourcePointsSelectionFromLayerPreview.add(this.labelSourcePointsSelectionFromLayerPreview, BorderLayout.NORTH); |
|
279 |
this.panelSourcePointsSelectionFromLayerPreview.add(this.scrollSourcePointsSelectionFromLayerPreview, BorderLayout.CENTER); |
|
280 |
|
|
281 |
this.panelSourcePointsSelectionFromLayer.setLayout(new BorderLayout(BORDER_HGAP, BORDER_VGAP)); |
|
282 |
this.panelSourcePointsSelectionFromLayer.add(this.panelSourcePointsSelectionFromLayerCombos, BorderLayout.NORTH); |
|
283 |
this.panelSourcePointsSelectionFromLayer.add(this.panelSourcePointsSelectionFromLayerPreview, BorderLayout.CENTER); |
|
284 |
|
|
285 |
this.panelSourcePointsSelectionFromNetwork.add(this.labelSourcePointsSelectionFromNetworkList, BorderLayout.NORTH); |
|
286 |
this.panelSourcePointsSelectionFromNetwork.add(this.scrollSourcePointsSelectionFromNetworkList, BorderLayout.CENTER); |
|
287 |
this.panelSourcePointsSelectionFromNetwork.add(this.labelSourcePointsSelectionFromNetworkNote, BorderLayout.SOUTH); |
|
288 |
|
|
289 |
this.setLayout(new BorderLayout(BORDER_HGAP, BORDER_VGAP)); |
|
290 |
this.add(this.contentPane, BorderLayout.CENTER); |
|
291 |
|
|
292 |
this.tabbedSelection.addTab("Desde una capa", this.panelSourcePointsSelectionFromLayer); |
|
293 |
} |
|
294 |
|
|
295 |
public void next(){ |
|
296 |
AbstractPointsModel model=this.owner.getController().getModel(); |
|
297 |
if(this.radioSourcePointsSelectionFromLayer.isSelected()){ |
|
298 |
try { |
|
299 |
FLayer layer; |
|
300 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
|
301 |
if(window instanceof View){ |
|
302 |
layer=((View)window).getMapControl().getMapContext().getLayers().getLayer(String.valueOf(this.comboSourcePointsSelectionFromLayerName.getSelectedItem())); |
|
303 |
if(layer!=null && layer instanceof FLyrVect){ |
|
304 |
if(model==null || !(model instanceof FLyrVectPointsModel) || (model instanceof FLyrVectPointsModel && ((FLyrVectPointsModel)model).getLayer()==((FLyrVect)layer))){ |
|
305 |
model=new FLyrVectPointsModel((FLyrVect)layer); |
|
306 |
((FLyrVectPointsModel)model).setCostFields( |
|
307 |
String.valueOf(this.comboSourcePointsSelectionFromLayerMainCostField.getSelectedItem()), |
|
308 |
String.valueOf(this.comboSourcePointsSelectionFromLayerSecondaryCostField.getSelectedItem()) |
|
309 |
); |
|
310 |
this.owner.getController().setModel(model); |
|
311 |
} |
|
312 |
super.next(); |
|
313 |
} |
|
314 |
else{ |
|
315 |
JOptionPane.showMessageDialog(this, "No se ha podido obtener una capa de puntos v?lida", "Error", JOptionPane.ERROR_MESSAGE); |
|
316 |
} |
|
317 |
} |
|
318 |
else{ |
|
319 |
JOptionPane.showMessageDialog(this, "No se ha podido obtener una capa de puntos v?lida", "Error", JOptionPane.ERROR_MESSAGE); |
|
320 |
} |
|
321 |
} |
|
322 |
catch (InvalidCostFieldException except) { |
|
323 |
JOptionPane.showMessageDialog(this, except.getMessage(), "Campo no v?lido", JOptionPane.ERROR_MESSAGE); |
|
324 |
} |
|
325 |
catch (ReadDriverException except) { |
|
326 |
JOptionPane.showMessageDialog(this, "Se ha producido un error en la lectura de la informaci?n de la capa", "Error", JOptionPane.ERROR_MESSAGE); |
|
327 |
} |
|
328 |
} |
|
329 |
else if(this.radioSourcePointsSelectionFromNetwork.isSelected()){ |
|
330 |
//OJO: SI SE QUITA EL ACTIONLISTENER AL RADIOBUTTON |
|
331 |
//QUE DICE QUE LOS PUNTOS VIENEN DE UNA RED ESTO VA |
|
332 |
//A PETAR PORQUE LA RED SE OBTIENE EN ESE EVENTO |
|
333 |
model=new NetworkPointsModel(this.network); |
|
334 |
this.owner.getController().setModel(model); |
|
335 |
super.next(); |
|
336 |
} |
|
337 |
else{ |
|
338 |
JOptionPane.showMessageDialog(this, "No se ha encontrado un modelo de datos v?lido", "Error", JOptionPane.ERROR_MESSAGE ); |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
public void actionPerformed(ActionEvent e) { |
|
343 |
if(e.getSource()==this.radioSourcePointsSelectionFromLayer){ |
|
344 |
this.tabbedSelection.removeAll(); |
|
345 |
this.tabbedSelection.addTab("Desde una capa", this.panelSourcePointsSelectionFromLayer); |
|
346 |
} |
|
347 |
else if(e.getSource()==this.radioSourcePointsSelectionFromNetwork){ |
|
348 |
this.tabbedSelection.removeAll(); |
|
349 |
|
|
350 |
if(this.networkModel==null){ |
|
351 |
if(this.network==null){ |
|
352 |
IWindow win = PluginServices.getMDIManager().getActiveWindow(); |
|
353 |
boolean flagNetworkLayer=false; |
|
354 |
if (win instanceof View) { |
|
355 |
View view = (View) win; |
|
356 |
FLayers fLayers=view.getMapControl().getMapContext().getLayers(); |
|
357 |
FLayer[] layers = fLayers.getVisibles(); |
|
358 |
for (int i = 0; i < layers.length; i++) { |
|
359 |
if(!flagNetworkLayer && layers[i].isActive() && (this.network=(Network)layers[i].getProperty("network"))!=null){ |
|
360 |
flagNetworkLayer=true; |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
if(this.network!=null){ |
|
365 |
this.networkModel=new PreviewNetworkPointsModel(this.tableSourcePointsSelectionFromNetworkList, this.network); |
|
366 |
} |
|
367 |
else{ |
|
368 |
JOptionPane.showMessageDialog(this, "No hay ninguna capa que contenta una red", "Advertencia", JOptionPane.WARNING_MESSAGE); |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
this.tabbedSelection.addTab("Desde el gestor de paradas", this.panelSourcePointsSelectionFromNetwork); |
|
374 |
} |
|
375 |
else if(e.getSource()==this.comboSourcePointsSelectionFromLayerName){ |
|
376 |
FLayer layer=this.mc.getLayers().getLayer(String.valueOf(this.comboSourcePointsSelectionFromLayerName.getSelectedItem())); |
|
377 |
if(layer instanceof FLyrVect){ |
|
378 |
try { |
|
379 |
String[] fieldsName=((FLyrVect)layer).getRecordset().getFieldNames(); |
|
380 |
this.comboSourcePointsSelectionFromLayerMainCostField.removeAllItems(); |
|
381 |
this.comboSourcePointsSelectionFromLayerSecondaryCostField.removeAllItems(); |
|
382 |
for (int i = 0; i < fieldsName.length; i++) { |
|
383 |
this.comboSourcePointsSelectionFromLayerMainCostField.addItem(fieldsName[i]); |
|
384 |
this.comboSourcePointsSelectionFromLayerSecondaryCostField.addItem(fieldsName[i]); |
|
385 |
} |
|
386 |
if(this.comboSourcePointsSelectionFromLayerSecondaryCostField.getItemCount()>1) |
|
387 |
this.comboSourcePointsSelectionFromLayerSecondaryCostField.setSelectedIndex(1); |
|
388 |
|
|
389 |
if(this.layerModel==null){ |
|
390 |
this.layerModel=new PreviewFLyerVectPointsModel(this.tableSourcePointsSelectionFromLayerPreview, (FLyrVect)layer); |
|
391 |
} |
|
392 |
else{ |
|
393 |
this.layerModel.setFLyrVect((FLyrVect)layer); |
|
394 |
} |
|
395 |
} catch (ReadDriverException except) { |
|
396 |
JOptionPane.showMessageDialog(this, "Ha sido imposible obtener los campos de la capa "+layer.getName(), "Error", JOptionPane.ERROR_MESSAGE); |
|
397 |
} |
|
398 |
} |
|
399 |
} |
|
400 |
else if(e.getSource()==this.buttonSourcePointsSelectionFromLayerAdd){ |
|
401 |
IExtension ext=PluginServices.getExtension(AddLayer.class); |
|
402 |
if(ext!=null){ |
|
403 |
ext.execute(""); |
|
404 |
} |
|
405 |
else{ |
|
406 |
JOptionPane.showMessageDialog(this, "Imposible a?adir capas", "Error", JOptionPane.ERROR_MESSAGE); |
|
407 |
} |
|
408 |
} |
|
409 |
} |
|
410 |
|
|
411 |
public void layerAdded(LayerCollectionEvent e) { |
|
412 |
this.comboSourcePointsSelectionFromLayerName.addItem(e.getAffectedLayer().getName()); |
|
413 |
this.comboSourcePointsSelectionFromLayerName.setSelectedIndex(this.comboSourcePointsSelectionFromLayerName.getItemCount()-1); |
|
414 |
} |
|
415 |
|
|
416 |
public void layerAdding(LayerCollectionEvent e) throws CancelationException { |
|
417 |
|
|
418 |
} |
|
419 |
|
|
420 |
public void layerMoved(LayerPositionEvent e) { |
|
421 |
|
|
422 |
} |
|
423 |
|
|
424 |
public void layerMoving(LayerPositionEvent e) throws CancelationException { |
|
425 |
|
|
426 |
} |
|
427 |
|
|
428 |
public void layerRemoved(LayerCollectionEvent e) { |
|
429 |
this.comboSourcePointsSelectionFromLayerName.removeItem(e.getAffectedLayer().getName()); |
|
430 |
} |
|
431 |
|
|
432 |
public void layerRemoving(LayerCollectionEvent e) throws CancelationException { |
|
433 |
|
|
434 |
} |
|
435 |
|
|
436 |
public void visibilityChanged(LayerCollectionEvent e) throws CancelationException { |
|
437 |
if(e.getAffectedLayer().isVisible()){ |
|
438 |
this.comboSourcePointsSelectionFromLayerName.addItem(e.getAffectedLayer().getName()); |
|
439 |
} |
|
440 |
else{ |
|
441 |
this.comboSourcePointsSelectionFromLayerName.removeItem(e.getAffectedLayer().getName()); |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
class PreviewNetworkPointsModel extends AbstractTableModel{ |
|
446 |
/** |
|
447 |
* |
|
448 |
*/ |
|
449 |
private static final long serialVersionUID = 9021109614225441795L; |
|
450 |
private JTable solutionTable; |
|
451 |
private Network network; |
|
452 |
|
|
453 |
public PreviewNetworkPointsModel(JTable table, Network network){ |
|
454 |
this.solutionTable=table; |
|
455 |
this.solutionTable.setModel(this); |
|
456 |
this.network=network; |
|
457 |
|
|
458 |
//this.solutionTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); |
|
459 |
TableColumnModel cm = this.solutionTable.getColumnModel(); |
|
460 |
|
|
461 |
int tablePreferredWidth = (int) this.solutionTable.getPreferredSize().getWidth(); |
|
462 |
int colSize = this.solutionTable.getFontMetrics(this.solutionTable.getFont()).stringWidth(this.solutionTable.getModel().getColumnName(0)) * 2; |
|
463 |
cm.getColumn(0).setPreferredWidth((int) (colSize)); |
|
464 |
cm.getColumn(0).setMinWidth((int) (colSize)); |
|
465 |
cm.getColumn(0).setMaxWidth((int) (colSize)); |
|
466 |
tablePreferredWidth -= colSize; |
|
467 |
//cm.getColumn(1).setPreferredWidth((int)(tablePreferredWidth * 0.7)); |
|
468 |
} |
|
469 |
|
|
470 |
public int getColumnCount() { |
|
471 |
return 2; |
|
472 |
} |
|
473 |
|
|
474 |
public int getRowCount() { |
|
475 |
return this.network.getFlagsCount(); |
|
476 |
} |
|
477 |
|
|
478 |
@SuppressWarnings("unchecked") |
|
479 |
public Class getColumnClass(int columnIndex) { |
|
480 |
switch (columnIndex){ |
|
481 |
case 0: |
|
482 |
return Integer.class; |
|
483 |
case 1: |
|
484 |
return String.class; |
|
485 |
default: |
|
486 |
return String.class; |
|
487 |
} |
|
488 |
} |
|
489 |
|
|
490 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
491 |
try{ |
|
492 |
switch(columnIndex){ |
|
493 |
case 0: |
|
494 |
return ((GvFlag)this.network.getOriginaFlags().get(rowIndex)).getIdFlag(); |
|
495 |
case 1: |
|
496 |
return ((GvFlag)this.network.getOriginaFlags().get(rowIndex)).getDescription(); |
|
497 |
default: |
|
498 |
return null; |
|
499 |
} |
|
500 |
} |
|
501 |
catch(IndexOutOfBoundsException except){ |
|
502 |
return null; |
|
503 |
} |
|
504 |
} |
|
505 |
|
|
506 |
public String getColumnName(int column) { |
|
507 |
switch(column){ |
|
508 |
case 0: |
|
509 |
return "Id"; |
|
510 |
case 1: |
|
511 |
return "Descripci?n"; |
|
512 |
default: |
|
513 |
return String.valueOf((char)(65+column)); //ASCII |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
@Override |
|
518 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
519 |
return false; |
|
520 |
} |
|
521 |
|
|
522 |
@Override |
|
523 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
524 |
//Ninguna celda es editable |
|
525 |
} |
|
526 |
} |
|
527 |
|
|
528 |
class PreviewFLyerVectPointsModel extends AbstractTableModel{ |
|
529 |
|
|
530 |
/** |
|
531 |
* |
|
532 |
*/ |
|
533 |
private static final long serialVersionUID = 6363515496824845366L; |
|
534 |
private JTable solutionTable; |
|
535 |
private FLyrVect layer; |
|
536 |
private SelectableDataSource recordset; |
|
537 |
|
|
538 |
private int tempRowIndex; |
|
539 |
private Value[] tempRow; |
|
540 |
|
|
541 |
private Logger logger; |
|
542 |
|
|
543 |
@SuppressWarnings("static-access") |
|
544 |
public PreviewFLyerVectPointsModel(JTable table, FLyrVect layer) throws ReadDriverException{ |
|
545 |
this.logger.getLogger(this.getClass().getName()); |
|
546 |
|
|
547 |
this.solutionTable=table; |
|
548 |
this.setFLyrVect(layer); |
|
549 |
this.solutionTable.setAutoCreateColumnsFromModel(true); |
|
550 |
this.solutionTable.setModel(this); |
|
551 |
|
|
552 |
this.tempRowIndex=-1; |
|
553 |
this.tempRow=null; |
|
554 |
|
|
555 |
/*this.solutionTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); |
|
556 |
TableColumnModel cm = this.solutionTable.getColumnModel(); |
|
557 |
|
|
558 |
int tablePreferredWidth = (int) this.solutionTable.getPreferredSize() |
|
559 |
.getWidth(); |
|
560 |
int colSize = Double.valueOf(this.solutionTable.getFontMetrics(this.solutionTable.getFont()).stringWidth(this.solutionTable.getModel().getColumnName(0)) * 1.5).intValue(); |
|
561 |
cm.getColumn(0).setPreferredWidth((int) (colSize)); |
|
562 |
cm.getColumn(0).setMinWidth((int) (colSize)); |
|
563 |
cm.getColumn(0).setMaxWidth((int) (colSize)); |
|
564 |
tablePreferredWidth -= colSize; |
|
565 |
cm.getColumn(1) |
|
566 |
.setPreferredWidth((int) (tablePreferredWidth * 0.9));*/ |
|
567 |
} |
|
568 |
|
|
569 |
public void setFLyrVect(FLyrVect layer) throws ReadDriverException{ |
|
570 |
this.tempRow=null; |
|
571 |
this.tempRowIndex=-1; |
|
572 |
this.layer=layer; |
|
573 |
this.recordset=this.layer.getRecordset(); |
|
574 |
this.fireTableStructureChanged(); |
|
575 |
} |
|
576 |
|
|
577 |
public int getColumnCount() { |
|
578 |
try { |
|
579 |
return this.recordset.getFieldCount(); |
|
580 |
} |
|
581 |
catch (ReadDriverException except) { |
|
582 |
this.logger.warning(except.getMessage()); |
|
583 |
return 0; |
|
584 |
} |
|
585 |
} |
|
586 |
|
|
587 |
public int getRowCount() { |
|
588 |
try { |
|
589 |
return (int)this.recordset.getRowCount(); |
|
590 |
} |
|
591 |
catch (ReadDriverException except) { |
|
592 |
this.logger.warning(except.getMessage()); |
|
593 |
return 0; |
|
594 |
} |
|
595 |
} |
|
596 |
|
|
597 |
@SuppressWarnings("unchecked") |
|
598 |
public Class getColumnClass(int columnIndex) { |
|
599 |
return String.class; |
|
600 |
} |
|
601 |
|
|
602 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
603 |
try { |
|
604 |
if(tempRowIndex==rowIndex){ |
|
605 |
if(columnIndex>tempRow.length) return null; |
|
606 |
return tempRow[columnIndex].toString(); |
|
607 |
} |
|
608 |
else{ |
|
609 |
Value[] values=this.recordset.getRow(rowIndex); |
|
610 |
this.tempRow=values; |
|
611 |
this.tempRowIndex=rowIndex; |
|
612 |
if(columnIndex>values.length) return null; |
|
613 |
return values[columnIndex].toString(); |
|
614 |
} |
|
615 |
} |
|
616 |
catch (ReadDriverException except) { |
|
617 |
this.logger.warning(except.getMessage()); |
|
618 |
} |
|
619 |
|
|
620 |
return null; |
|
621 |
} |
|
622 |
|
|
623 |
public String getColumnName(int column) { |
|
624 |
try { |
|
625 |
return this.recordset.getFieldName(column); |
|
626 |
} |
|
627 |
catch (ReadDriverException except) { |
|
628 |
this.logger.warning(except.getMessage()); |
|
629 |
} |
|
630 |
catch(Exception except){ |
|
631 |
this.logger.warning(except.getMessage()); |
|
632 |
} |
|
633 |
|
|
634 |
return String.valueOf((char)(65+column)); //ASCII |
|
635 |
} |
|
636 |
|
|
637 |
@Override |
|
638 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
639 |
return false; |
|
640 |
} |
|
641 |
|
|
642 |
@Override |
|
643 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
644 |
//Ninguna celda es editable |
|
645 |
} |
|
646 |
} |
|
647 |
} |
trunk/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/wizard/servicearea/NetworkPointsModel.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.graph.gui.wizard.servicearea; |
|
2 |
|
|
3 |
import java.util.logging.Logger; |
|
4 |
|
|
5 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
|
6 |
import com.iver.cit.gvsig.graph.core.Network; |
|
7 |
|
|
8 |
public class NetworkPointsModel extends AbstractPointsModel { |
|
9 |
/** |
|
10 |
* |
|
11 |
*/ |
|
12 |
private static final long serialVersionUID = 1694526796604795043L; |
|
13 |
|
|
14 |
private Network network; |
|
15 |
|
|
16 |
@SuppressWarnings("unused") |
|
17 |
private Logger logger; |
|
18 |
|
|
19 |
public NetworkPointsModel(Network network){ |
|
20 |
super(); |
|
21 |
|
|
22 |
this.logger=Logger.getLogger(this.getClass().getName()); |
|
23 |
|
|
24 |
this.network=network; |
|
25 |
this.mainCosts=new String[this.getRowCount()]; |
|
26 |
this.secondaryCosts=new String[this.getRowCount()]; |
|
27 |
this.bitsetEnabled.set(0, this.getRowCount()); |
|
28 |
} |
|
29 |
|
|
30 |
public int getColumnCount() { |
|
31 |
return 5; |
|
32 |
} |
|
33 |
|
|
34 |
public int getRowCount() { |
|
35 |
return this.network.getFlagsCount(); |
|
36 |
} |
|
37 |
|
|
38 |
@SuppressWarnings("unchecked") |
|
39 |
public Class getColumnClass(int columnIndex) { |
|
40 |
switch(columnIndex){ |
|
41 |
case 0: |
|
42 |
return Boolean.class; |
|
43 |
case 1: |
|
44 |
return Integer.class; |
|
45 |
case 2: |
|
46 |
return String.class; |
|
47 |
case 3: |
|
48 |
return String.class; |
|
49 |
case 4: |
|
50 |
return String.class; |
|
51 |
default: |
|
52 |
return String.class; |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
57 |
switch(columnIndex){ |
|
58 |
case 0: |
|
59 |
return this.bitsetEnabled.get(rowIndex); |
|
60 |
case 1: |
|
61 |
if(this.getRowCount()>rowIndex) |
|
62 |
return Integer.valueOf(((GvFlag)this.network.getOriginaFlags().get(rowIndex)).getIdFlag()); |
|
63 |
else |
|
64 |
return null; |
|
65 |
case 2: |
|
66 |
if(rowIndex<this.getRowCount()) |
|
67 |
return ((GvFlag)this.network.getOriginaFlags().get(rowIndex)).getDescription(); |
|
68 |
else |
|
69 |
return "<Error en la obtenci?n>"; |
|
70 |
case 3: |
|
71 |
if(this.isUniqueMainCostEnabled()){ |
|
72 |
return this.uniqueMainCosts; |
|
73 |
} |
|
74 |
else{ |
|
75 |
if(rowIndex<this.mainCosts.length){ |
|
76 |
if(this.mainCosts[rowIndex]!=null){ |
|
77 |
try{ |
|
78 |
return this.getTotalCosts(this.mainCosts[rowIndex]); |
|
79 |
} |
|
80 |
catch(NumberFormatException except){ |
|
81 |
return ""; |
|
82 |
} |
|
83 |
} |
|
84 |
else |
|
85 |
return ""; |
|
86 |
} |
|
87 |
else{ |
|
88 |
return "<Error en la obtenci?n>"; |
|
89 |
} |
|
90 |
} |
|
91 |
case 4: |
|
92 |
if(this.isUniqueSecondaryCostEnabled()){ |
|
93 |
return this.uniqueSecondaryCosts; |
|
94 |
} |
|
95 |
else{ |
|
96 |
if(rowIndex<this.secondaryCosts.length){ |
|
97 |
if(this.secondaryCosts[rowIndex]!=null){ |
|
98 |
try{ |
|
99 |
return this.getTotalCosts(this.secondaryCosts[rowIndex]); |
|
100 |
} |
|
101 |
catch(NumberFormatException except){ |
|
102 |
return ""; |
|
103 |
} |
|
104 |
} |
|
105 |
else |
|
106 |
return ""; |
|
107 |
} |
|
108 |
else{ |
|
109 |
return "<Error en la obtenci?n>"; |
|
110 |
} |
|
111 |
} |
|
112 |
default: |
|
113 |
return null; |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
public String getColumnName(int column) { |
|
118 |
switch(column){ |
|
119 |
case 0: |
|
120 |
return "Habilitado"; |
|
121 |
case 1: |
|
122 |
return "Id"; |
|
123 |
case 2: |
|
124 |
return "Descripci?n"; |
|
125 |
case 3: |
|
126 |
return "Coste principal"; |
|
127 |
case 4: |
|
128 |
return "Coste secundario"; |
|
129 |
default: |
|
130 |
return String.valueOf((char)(65+column)); //ASCII |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
136 |
switch(columnIndex){ |
|
137 |
case 0: |
|
138 |
return true; |
|
139 |
case 1: |
|
140 |
return false; |
|
141 |
case 2: |
|
142 |
return true; |
|
143 |
case 3: |
|
144 |
return false; |
|
145 |
case 4: |
|
146 |
return false; |
|
147 |
default: |
|
148 |
return false; |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
154 |
switch(columnIndex){ |
|
155 |
case 0:{ |
|
156 |
this.bitsetEnabled.set(rowIndex, ((Boolean)aValue).booleanValue()); |
|
157 |
break; |
|
158 |
} |
|
159 |
case 2:{ |
|
160 |
if(rowIndex<this.getRowCount()) |
|
161 |
((GvFlag)this.network.getOriginaFlags().get(rowIndex)).setDescription(String.valueOf(aValue)); |
|
162 |
|
|
163 |
break; |
|
164 |
} |
|
165 |
case 3:{ |
|
166 |
if(rowIndex<this.mainCosts.length) |
|
167 |
this.mainCosts[rowIndex]=String.valueOf(aValue); |
|
168 |
break; |
|
169 |
} |
|
170 |
case 4:{ |
|
171 |
if(rowIndex<this.secondaryCosts.length) |
|
172 |
this.secondaryCosts[rowIndex]=String.valueOf(aValue); |
|
173 |
break; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
public String toString(){ |
|
179 |
return "Modelo: Red # N?mero de flags: "+this.network.getOriginaFlags().size()+" #"; |
|
180 |
} |
|
181 |
} |
trunk/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/wizard/servicearea/ServiceAreaPage1.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.graph.gui.wizard.servicearea; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Component; |
|
6 |
import java.awt.Dimension; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.awt.event.ComponentEvent; |
|
10 |
import java.awt.event.ComponentListener; |
|
11 |
import java.awt.event.KeyEvent; |
|
12 |
import java.awt.event.KeyListener; |
|
13 |
import java.awt.event.MouseEvent; |
|
14 |
import java.awt.event.MouseListener; |
|
15 |
|
|
16 |
import javax.swing.ImageIcon; |
|
17 |
import javax.swing.JCheckBox; |
|
18 |
import javax.swing.JLabel; |
|
19 |
import javax.swing.JOptionPane; |
|
20 |
import javax.swing.JPanel; |
|
21 |
import javax.swing.JScrollPane; |
|
22 |
import javax.swing.JTable; |
|
23 |
import javax.swing.JTextArea; |
|
24 |
import javax.swing.border.TitledBorder; |
|
25 |
import javax.swing.table.TableCellRenderer; |
|
26 |
|
|
27 |
import jwizardcomponent.JWizardPanel; |
|
28 |
|
|
29 |
import com.iver.andami.PluginServices; |
|
30 |
import com.iver.cit.gvsig.graph.NetworkUtils; |
|
31 |
import com.iver.cit.gvsig.graph.gui.wizard.servicearea.AbstractPointsModel.InvalidCostException; |
|
32 |
|
|
33 |
public class ServiceAreaPage1 extends JWizardPanel implements KeyListener, MouseListener, ComponentListener, ActionListener{ |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
38 |
private static final long serialVersionUID = 7051194740312102283L; |
|
39 |
|
|
40 |
private ServiceAreaWizard owner; |
|
41 |
|
|
42 |
private int selectedRowIndex; |
|
43 |
|
|
44 |
private JPanel contentpane; |
|
45 |
private JPanel panelNorth; |
|
46 |
private JLabel labelTitle; |
|
47 |
private JLabel labelAreaMainCost; |
|
48 |
private JLabel labelErrorMainCosts; |
|
49 |
private ImageIcon iconErrorCost; |
|
50 |
private JScrollPane scrollAreaMainCosts; |
|
51 |
private JTextArea textAreaMainCosts; |
|
52 |
private JLabel labelAreaSecondaryCosts; |
|
53 |
private JLabel labelErrorSecondaryCosts; |
|
54 |
private JScrollPane scrollAreaSecondaryCosts; |
|
55 |
private JTextArea textAreaSecondaryCosts; |
|
56 |
private JCheckBox checkSameCosts; |
|
57 |
private TitledBorder borderPanelPoints; |
|
58 |
private JPanel panelTable; |
|
59 |
private JScrollPane scrollPoints; |
|
60 |
//private JTable tablePoints; |
|
61 |
private ColoredTable tablePoints; |
|
62 |
|
|
63 |
private static final int BORDER_HGAP = 7; |
|
64 |
private static final int BORDER_VGAP = 7; |
|
65 |
private static final int COMPONENT_HGAP = 4; |
|
66 |
private static final int COMPONENT_VGAP = 4; |
|
67 |
private static final int PREFERRED_HEIGHT = 23; |
|
68 |
private static final int PREFERRED_WIDTH = 120; |
|
69 |
|
|
70 |
public ServiceAreaPage1(ServiceAreaWizard wizard){ |
|
71 |
super(wizard.getWizardComponents()); |
|
72 |
this.owner=wizard; |
|
73 |
this.selectedRowIndex=-1; |
|
74 |
this.initialize(); |
|
75 |
} |
|
76 |
|
|
77 |
private void initialize(){ |
|
78 |
this.addComponentListener(this); |
|
79 |
|
|
80 |
this.contentpane=new JPanel(); |
|
81 |
this.panelNorth=new JPanel(); |
|
82 |
this.labelTitle=new JLabel("<html><b>Edici?n de costes de cada ?rea</b></html>"); |
|
83 |
this.labelAreaMainCost=new JLabel("<html>Costes <b>primarios</b> de ?rea:</html>"); |
|
84 |
this.labelErrorMainCosts=new JLabel(); |
|
85 |
this.labelErrorMainCosts.setOpaque(true); |
|
86 |
this.iconErrorCost=PluginServices.getIconTheme().get("service_area_wrong_costs"); |
|
87 |
this.scrollAreaMainCosts=new JScrollPane(); |
|
88 |
this.scrollAreaMainCosts.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
|
89 |
this.scrollAreaMainCosts.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
90 |
this.textAreaMainCosts=new JTextArea(); |
|
91 |
this.textAreaMainCosts.setRows(4); |
|
92 |
this.textAreaMainCosts.setLineWrap(true); |
|
93 |
this.textAreaMainCosts.addKeyListener(this); |
|
94 |
this.scrollAreaMainCosts.getViewport().add(this.textAreaMainCosts); |
|
95 |
this.labelAreaSecondaryCosts=new JLabel("<html>Costes <b>secundarios</b> de ?rea:</html>"); |
|
96 |
this.labelErrorSecondaryCosts=new JLabel(); |
|
97 |
this.labelErrorSecondaryCosts.setOpaque(true); |
|
98 |
this.scrollAreaSecondaryCosts=new JScrollPane(); |
|
99 |
this.scrollAreaSecondaryCosts.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
100 |
this.scrollAreaSecondaryCosts.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
101 |
this.textAreaSecondaryCosts=new JTextArea(); |
|
102 |
this.textAreaSecondaryCosts.setRows(4); |
|
103 |
this.textAreaSecondaryCosts.setLineWrap(true); |
|
104 |
this.textAreaSecondaryCosts.addKeyListener(this); |
|
105 |
this.scrollAreaSecondaryCosts.getViewport().add(this.textAreaSecondaryCosts); |
|
106 |
this.checkSameCosts=new JCheckBox("<html><p align='left'>Utilizar los costes del</p><p align='left'>punto seleccionado</p><p align='left'>para el resto</p><p align='left'>de puntos</p></html>"); |
|
107 |
this.checkSameCosts.addActionListener(this); |
|
108 |
this.panelTable=new JPanel(); |
|
109 |
this.borderPanelPoints=new TitledBorder("Gestor de paradas"); |
|
110 |
this.panelTable.setBorder(this.borderPanelPoints); |
|
111 |
this.scrollPoints=new JScrollPane(); |
|
112 |
//this.tablePoints=new JTable(); |
|
113 |
this.tablePoints=new ColoredTable(); |
|
114 |
this.tablePoints.enablePijamaEffect(Color.white, new Color(229, 251, 252)); |
|
115 |
//this.tablePoints.setModel(this.owner.getModel()); |
|
116 |
this.tablePoints.addMouseListener(this); |
|
117 |
this.scrollPoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
118 |
this.scrollPoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
119 |
this.scrollPoints.getViewport().add(this.tablePoints); |
|
120 |
|
|
121 |
this.panelNorth.setLayout(null); |
|
122 |
this.labelTitle.setBounds(BORDER_HGAP, BORDER_VGAP, this.labelTitle.getFontMetrics(this.labelTitle.getFont()).stringWidth(this.labelTitle.getText()), PREFERRED_HEIGHT); |
|
123 |
this.labelAreaMainCost.setBounds(BORDER_HGAP, this.labelTitle.getY()+this.labelTitle.getHeight()+COMPONENT_VGAP, this.labelAreaMainCost.getFontMetrics(this.labelAreaMainCost.getFont()).stringWidth(this.labelAreaMainCost.getText()), 23); |
|
124 |
this.labelErrorMainCosts.setBounds(this.labelAreaMainCost.getWidth()+this.labelAreaMainCost.getX()+COMPONENT_HGAP, this.labelAreaMainCost.getY(), 23, 23); |
|
125 |
this.scrollAreaMainCosts.setBounds(BORDER_HGAP, this.labelAreaMainCost.getY()+this.labelAreaMainCost.getHeight()+COMPONENT_VGAP, 200, 70); |
|
126 |
this.checkSameCosts.setBounds(this.scrollAreaMainCosts.getX()+this.scrollAreaMainCosts.getWidth()+BORDER_HGAP, this.scrollAreaMainCosts.getY(), this.checkSameCosts.getFontMetrics(this.checkSameCosts.getFont()).stringWidth(this.checkSameCosts.getText()), this.scrollAreaMainCosts.getHeight()); |
|
127 |
this.labelAreaSecondaryCosts.setBounds(BORDER_HGAP, this.scrollAreaMainCosts.getY()+this.scrollAreaMainCosts.getHeight()+COMPONENT_VGAP, this.labelAreaSecondaryCosts.getFontMetrics(this.labelAreaSecondaryCosts.getFont()).stringWidth(this.labelAreaSecondaryCosts.getText()), PREFERRED_HEIGHT); |
|
128 |
this.labelErrorSecondaryCosts.setBounds(this.labelAreaSecondaryCosts.getWidth()+this.labelAreaSecondaryCosts.getX()+COMPONENT_HGAP, this.labelAreaSecondaryCosts.getY(), 23, 23); |
|
129 |
this.scrollAreaSecondaryCosts.setBounds(BORDER_HGAP, this.labelAreaSecondaryCosts.getY()+this.labelAreaSecondaryCosts.getHeight()+BORDER_VGAP, 200, 70); |
|
130 |
|
|
131 |
this.panelNorth.setPreferredSize(new Dimension(0, |
|
132 |
this.labelTitle.getHeight() + |
|
133 |
this.labelAreaMainCost.getHeight() + |
|
134 |
this.scrollAreaMainCosts.getHeight() + |
|
135 |
this.labelAreaSecondaryCosts.getHeight() + |
|
136 |
this.scrollAreaSecondaryCosts.getHeight() + 40)); |
|
137 |
|
|
138 |
this.panelNorth.add(this.labelTitle); |
|
139 |
this.panelNorth.add(this.labelAreaMainCost); |
|
140 |
this.panelNorth.add(this.labelErrorMainCosts); |
|
141 |
this.panelNorth.add(this.scrollAreaMainCosts); |
|
142 |
this.panelNorth.add(this.checkSameCosts); |
|
143 |
this.panelNorth.add(this.labelAreaSecondaryCosts); |
|
144 |
this.panelNorth.add(this.labelErrorSecondaryCosts); |
|
145 |
this.panelNorth.add(this.scrollAreaSecondaryCosts); |
|
146 |
|
|
147 |
this.panelTable.setLayout(new BorderLayout(7, 7)); |
|
148 |
this.panelTable.add(this.scrollPoints, BorderLayout.CENTER); |
|
149 |
|
|
150 |
this.contentpane.setLayout(new BorderLayout(7, 7)); |
|
151 |
this.contentpane.add(this.panelNorth, BorderLayout.NORTH); |
|
152 |
this.contentpane.add(this.panelTable, BorderLayout.CENTER); |
|
153 |
|
|
154 |
this.setLayout(new BorderLayout(7, 7)); |
|
155 |
this.add(this.contentpane, BorderLayout.CENTER); |
|
156 |
} |
|
157 |
|
|
158 |
public void next(){ |
|
159 |
AbstractPointsModel model=this.owner.getController().getModel(); |
|
160 |
|
|
161 |
if(model.getEnabledRowsCount()>0){ |
|
162 |
if(!model.isUniqueMainCostEnabled() || !model.isUniqueSecondaryCostEnabled()){ |
|
163 |
boolean flag=true; |
|
164 |
int rowCount=model.getRowCount(); |
|
165 |
int i=0; |
|
166 |
|
|
167 |
for (i = 0; i < rowCount && flag; i++) { |
|
168 |
if(model.isRowEnabled(i)){ |
|
169 |
if(String.valueOf(model.getValueAt(i, 3)).trim().equals("") || String.valueOf(model.getValueAt(i, 4)).trim().equals("")){ |
|
170 |
flag=false; |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
if(flag){ |
|
176 |
super.next(); |
|
177 |
} |
|
178 |
else{ |
|
179 |
JOptionPane.showMessageDialog(this, "La fila con ID "+Integer.valueOf(String.valueOf(model.getValueAt(i, 1)))+" no tiene todos los costes asignados", "Costes no asignados", JOptionPane.WARNING_MESSAGE); |
|
180 |
} |
|
181 |
} |
|
182 |
else{ |
|
183 |
super.next(); |
|
184 |
} |
|
185 |
} |
|
186 |
else{ |
|
187 |
JOptionPane.showMessageDialog(this, "No hay ninguna fila habilitada", "Advertencia", JOptionPane.WARNING_MESSAGE); |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
public void keyPressed(KeyEvent e) { |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public void keyReleased(KeyEvent e) { |
|
196 |
|
|
197 |
} |
|
198 |
|
|
199 |
public void keyTyped(KeyEvent e) { |
|
200 |
if(e.getSource()==this.textAreaMainCosts){ |
|
201 |
try{ |
|
202 |
AbstractPointsModel model=this.owner.getController().getModel(); |
|
203 |
double[] costs=NetworkUtils.string2doubleArray(this.textAreaMainCosts.getText()+e.getKeyChar(), model.COSTS_SEPARATOR); |
|
204 |
this.labelErrorMainCosts.setIcon(null); |
|
205 |
this.labelErrorMainCosts.setToolTipText(""); |
|
206 |
this.textAreaMainCosts.setBackground(Color.white); |
|
207 |
if(this.selectedRowIndex>=0 && this.selectedRowIndex<this.owner.getController().getModel().getRowCount()){ |
|
208 |
String s=""; |
|
209 |
for (int i = 0; i < costs.length; i++) { |
|
210 |
s+=costs[i]+model.COSTS_SEPARATOR; |
|
211 |
} |
|
212 |
s=s.trim(); |
|
213 |
if(s.endsWith(model.COSTS_SEPARATOR)) s=s.substring(0, s.length()-1); |
|
214 |
this.owner.getController().getModel().setValueAt(s, this.selectedRowIndex, 3); |
|
215 |
this.tablePoints.updateUI(); |
|
216 |
} |
|
217 |
} |
|
218 |
catch(NumberFormatException except){ |
|
219 |
this.labelErrorMainCosts.setIcon(this.iconErrorCost); |
|
220 |
this.labelErrorMainCosts.setToolTipText("Hay un error en los costes primarios"); |
|
221 |
this.textAreaMainCosts.setBackground(new Color(255, 210, 210)); |
|
222 |
} |
|
223 |
} |
|
224 |
else if(e.getSource()==this.textAreaSecondaryCosts){ |
|
225 |
try{ |
|
226 |
AbstractPointsModel model=this.owner.getController().getModel(); |
|
227 |
double[] costs=NetworkUtils.string2doubleArray(this.textAreaSecondaryCosts.getText()+e.getKeyChar(), model.COSTS_SEPARATOR); |
|
228 |
this.labelErrorSecondaryCosts.setIcon(null); |
|
229 |
this.labelErrorSecondaryCosts.setToolTipText(""); |
|
230 |
this.textAreaSecondaryCosts.setBackground(Color.white); |
|
231 |
if(this.selectedRowIndex>=0 && this.selectedRowIndex<this.owner.getController().getModel().getRowCount()){ |
|
232 |
String s=""; |
|
233 |
for (int i = 0; i < costs.length; i++) { |
|
234 |
s+=costs[i]+model.COSTS_SEPARATOR; |
|
235 |
} |
|
236 |
s=s.trim(); |
|
237 |
if(s.endsWith(model.COSTS_SEPARATOR)) s=s.substring(0, s.length()-1); |
|
238 |
this.owner.getController().getModel().setValueAt(s, this.selectedRowIndex, 4); |
|
239 |
this.tablePoints.updateUI(); |
|
240 |
} |
|
241 |
} |
|
242 |
catch(NumberFormatException except){ |
|
243 |
this.labelErrorSecondaryCosts.setIcon(this.iconErrorCost); |
|
244 |
this.labelErrorSecondaryCosts.setToolTipText("Hay un error en los costes secundarios"); |
|
245 |
this.textAreaSecondaryCosts.setBackground(new Color(255, 210, 210)); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
public void mouseClicked(MouseEvent e) { |
|
251 |
if(e.getSource()==this.tablePoints){ |
|
252 |
this.selectedRowIndex=this.tablePoints.getSelectedRow(); |
|
253 |
if(this.selectedRowIndex>=0 && this.selectedRowIndex<this.owner.getController().getModel().getRowCount()){ |
|
254 |
String s=String.valueOf(this.owner.getController().getModel().getValueAt(this.selectedRowIndex, 3)); |
|
255 |
this.textAreaMainCosts.setText(s.trim()); |
|
256 |
s=String.valueOf(this.owner.getController().getModel().getValueAt(this.selectedRowIndex, 4)); |
|
257 |
this.textAreaSecondaryCosts.setText(s.trim()); |
|
258 |
} |
|
259 |
|
|
260 |
this.textAreaMainCosts.setBackground(Color.white); |
|
261 |
this.textAreaSecondaryCosts.setBackground(Color.white); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
public void mouseEntered(MouseEvent e) { |
|
266 |
} |
|
267 |
|
|
268 |
public void mouseExited(MouseEvent e) { |
|
269 |
} |
|
270 |
|
|
271 |
public void mousePressed(MouseEvent e) { |
|
272 |
} |
|
273 |
|
|
274 |
public void mouseReleased(MouseEvent e) { |
|
275 |
} |
|
276 |
|
|
277 |
public void componentHidden(ComponentEvent e) { |
|
278 |
} |
|
279 |
|
|
280 |
public void componentMoved(ComponentEvent e) { |
|
281 |
} |
|
282 |
|
|
283 |
public void componentResized(ComponentEvent e) { |
|
284 |
} |
|
285 |
|
|
286 |
public void componentShown(ComponentEvent e) { |
|
287 |
this.tablePoints.setModel(this.owner.getController().getModel()); |
|
288 |
//this.textAreaMainCosts.setText(""); |
|
289 |
//this.textAreaSecondaryCosts.setText(""); |
|
290 |
} |
|
291 |
|
|
292 |
public void actionPerformed(ActionEvent e) { |
|
293 |
if(e.getSource()==this.checkSameCosts){ |
|
294 |
AbstractPointsModel model=this.owner.getController().getModel(); |
|
295 |
|
|
296 |
if(this.checkSameCosts.isSelected()){ |
|
297 |
if(this.tablePoints.getSelectedRowCount()>0){ |
|
298 |
String mainCosts=String.valueOf(model.getValueAt(this.tablePoints.getSelectedRow(), 3)), |
|
299 |
secondaryCosts=String.valueOf(model.getValueAt(this.tablePoints.getSelectedRow(),4)); |
|
300 |
if(!mainCosts.trim().equals("") && !secondaryCosts.trim().equals("")){ |
|
301 |
try { |
|
302 |
model.enableUniqueMainCost(String.valueOf(model.getValueAt(this.tablePoints.getSelectedRow(), 3))); |
|
303 |
model.enableUniqueSecondaryCost(String.valueOf(model.getValueAt(this.tablePoints.getSelectedRow(), 4))); |
|
304 |
this.tablePoints.setRowBackground(this.tablePoints.getSelectedRow(), new Color(237, 240, 184)); |
|
305 |
this.tablePoints.updateUI(); |
|
306 |
} catch (InvalidCostException except) { |
|
307 |
JOptionPane.showMessageDialog(this, except.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); |
|
308 |
} |
|
309 |
} |
|
310 |
else if(mainCosts.trim().equals("")){ |
|
311 |
JOptionPane.showMessageDialog(this, "El coste primario de la fila seleccionada no es correcto", "Coste incorrecto", JOptionPane.ERROR_MESSAGE); |
|
312 |
this.checkSameCosts.setSelected(false); |
|
313 |
} |
|
314 |
else if(secondaryCosts.trim().equals("")){ |
|
315 |
JOptionPane.showMessageDialog(this, "El coste secundario de la fila seleccionada no es correcto", "Coste incorrecto", JOptionPane.ERROR_MESSAGE); |
|
316 |
this.checkSameCosts.setSelected(false); |
|
317 |
} |
|
318 |
} |
|
319 |
else{ |
|
320 |
JOptionPane.showMessageDialog(this, "No se puede asginar un coste ?nico porque no hay ninguna fila seleccionada"); |
|
321 |
this.checkSameCosts.setSelected(false); |
|
322 |
} |
|
323 |
} |
|
324 |
else{ |
|
325 |
model.disableUniqueMainCost(); |
|
326 |
model.disableUniqueSecondaryCost(); |
|
327 |
this.tablePoints.clearColoredRow(); |
|
328 |
this.tablePoints.updateUI(); |
|
329 |
} |
|
330 |
} |
|
331 |
} |
|
332 |
|
|
333 |
class ColoredTable extends JTable{ |
|
334 |
|
|
335 |
/** |
|
336 |
* |
|
337 |
*/ |
|
338 |
private static final long serialVersionUID = -8283898126306207443L; |
|
339 |
private Color rowColor; |
|
340 |
private int coloredRowIndex = -1; |
|
341 |
|
|
342 |
private boolean pijamaEffectEnabled=false; |
|
343 |
private Color pijamaColor1; |
|
344 |
private Color pijamaColor2; |
|
345 |
|
|
346 |
public void setRowBackground(int rowIndex, Color color) throws IndexOutOfBoundsException{ |
|
347 |
if(this.getModel().getRowCount()>rowIndex){ |
|
348 |
this.rowColor=color; |
|
349 |
this.coloredRowIndex=rowIndex; |
|
350 |
} |
|
351 |
else{ |
|
352 |
throw new IndexOutOfBoundsException("La fila "+rowIndex+" no existe"); |
|
353 |
} |
|
354 |
} |
|
355 |
|
|
356 |
public void clearColoredRow(){ |
|
357 |
this.coloredRowIndex=-1; |
|
358 |
} |
|
359 |
|
|
360 |
public void enablePijamaEffect(Color color1, Color color2){ |
|
361 |
this.pijamaColor1=color1; |
|
362 |
this.pijamaColor2=color2; |
|
363 |
this.pijamaEffectEnabled=true; |
|
364 |
} |
|
365 |
|
|
366 |
public void disablePijamaEffect(){ |
|
367 |
this.pijamaEffectEnabled=false; |
|
368 |
} |
|
369 |
|
|
370 |
public boolean isPijamaEffectEnabled(){ |
|
371 |
return this.pijamaEffectEnabled; |
|
372 |
} |
|
373 |
|
|
374 |
public Component prepareRenderer(TableCellRenderer renderer, int row, int column){ |
|
375 |
Component returnComp = super.prepareRenderer(renderer, row, column); |
|
376 |
|
|
377 |
if (!returnComp.getBackground().equals(getSelectionBackground()) && this.coloredRowIndex==row){ |
|
378 |
returnComp .setBackground(rowColor); |
|
379 |
} |
|
380 |
|
|
381 |
if(this.pijamaEffectEnabled && !returnComp.getBackground().equals(getSelectionBackground()) && row!=coloredRowIndex){ |
|
382 |
if(row%2==0){ |
|
383 |
returnComp.setBackground(this.pijamaColor1); |
|
384 |
} |
|
385 |
else{ |
|
386 |
returnComp.setBackground(this.pijamaColor2); |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
return returnComp; |
|
391 |
} |
|
392 |
} |
|
393 |
} |
trunk/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/wizard/servicearea/ServiceAreaPage2.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.graph.gui.wizard.servicearea; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.GridLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.event.MouseEvent; |
|
9 |
import java.awt.event.MouseListener; |
|
10 |
|
|
11 |
import javax.swing.ButtonGroup; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.JPanel; |
|
14 |
import javax.swing.JRadioButton; |
|
15 |
import javax.swing.border.TitledBorder; |
|
16 |
|
|
17 |
import jwizardcomponent.JWizardPanel; |
|
18 |
|
|
19 |
import com.iver.andami.PluginServices; |
|
20 |
|
|
21 |
public class ServiceAreaPage2 extends JWizardPanel implements ActionListener, MouseListener{ |
|
22 |
|
|
23 |
private JLabel labelChooseArea; |
|
24 |
private JPanel panelAreaTypes; |
|
25 |
private ButtonGroup groupAreaTypes; |
|
26 |
private JPanel panelAreaTypesCompact; |
|
27 |
private TitledBorder titledBorderAreaTypesCompact; |
|
28 |
private JRadioButton radioAreaTypesCompact; |
|
29 |
private JPanel panelAreaTypesCompactPicture; |
|
30 |
private JLabel labelAreaTypesCompactPicture; |
|
31 |
private JPanel panelAreaTypesConvex; |
|
32 |
private TitledBorder titledBorderAreaTypesConvex; |
|
33 |
private JRadioButton radioAreaTypesConvex; |
|
34 |
private JPanel panelAreaTypesConvexPicture; |
|
35 |
private JLabel labelAreaTypesConvexPicture; |
|
36 |
|
|
37 |
/** |
|
38 |
* |
|
39 |
*/ |
|
40 |
private static final long serialVersionUID = 5139067753651358490L; |
|
41 |
|
|
42 |
private ServiceAreaWizard owner; |
|
43 |
|
|
44 |
public ServiceAreaPage2(ServiceAreaWizard wizard){ |
|
45 |
super(wizard.getWizardComponents()); |
|
46 |
this.owner=wizard; |
|
47 |
this.initialize(); |
|
48 |
} |
|
49 |
|
|
50 |
private void initialize(){ |
|
51 |
this.labelChooseArea=new JLabel("<html><b>Escoge el tipo de ?rea:</b></html>", JLabel.LEFT); |
|
52 |
this.panelAreaTypes=new JPanel(); |
|
53 |
this.groupAreaTypes=new ButtonGroup(); |
|
54 |
this.panelAreaTypesCompact=new JPanel(); |
|
55 |
this.titledBorderAreaTypesCompact=new TitledBorder("?rea compacta"); |
|
56 |
this.panelAreaTypesCompact.setBorder(this.titledBorderAreaTypesCompact); |
|
57 |
this.radioAreaTypesCompact=new JRadioButton("<html>El ?rea compacta se caracteriza por mantener a sus crias dentro de su madriguera durante sus primeros <b>30 a?os de vida</b>. En su mayor parte estos animalitos acaban dedicandose a la inform?tica en su edad adulta</html>"); |
|
58 |
this.radioAreaTypesCompact.addActionListener(this); |
|
59 |
this.radioAreaTypesCompact.setSelected(true); |
|
60 |
this.groupAreaTypes.add(this.radioAreaTypesCompact); |
|
61 |
this.panelAreaTypesCompactPicture=new JPanel(); |
|
62 |
this.labelAreaTypesCompactPicture=new JLabel(); |
|
63 |
this.labelAreaTypesCompactPicture.setOpaque(true); |
|
64 |
this.labelAreaTypesCompactPicture.setIcon(PluginServices.getIconTheme().get("service_area_compact")); |
|
65 |
this.labelAreaTypesCompactPicture.setEnabled(true); |
|
66 |
this.labelAreaTypesCompactPicture.addMouseListener(this); |
|
67 |
this.panelAreaTypesConvex=new JPanel(); |
|
68 |
this.titledBorderAreaTypesConvex=new TitledBorder("?rea convexa"); |
|
69 |
this.panelAreaTypesConvex.setBorder(this.titledBorderAreaTypesConvex); |
|
70 |
this.radioAreaTypesConvex=new JRadioButton("<html>El ?rea convexa no tiene rabo porque Bill Gates se lo ha cortado. <b>Refranero OpenSource</b></html>"); |
|
71 |
this.radioAreaTypesConvex.addActionListener(this); |
|
72 |
this.groupAreaTypes.add(this.radioAreaTypesConvex); |
|
73 |
this.panelAreaTypesConvexPicture=new JPanel(); |
|
74 |
this.labelAreaTypesConvexPicture=new JLabel(); |
|
75 |
this.labelAreaTypesConvexPicture.setOpaque(true); |
|
76 |
this.labelAreaTypesConvexPicture.setBackground(Color.BLUE); |
|
77 |
this.labelAreaTypesConvexPicture.setIcon(PluginServices.getIconTheme().get("service_area_convex")); |
|
78 |
this.labelAreaTypesConvexPicture.setEnabled(false); |
|
79 |
this.labelAreaTypesConvexPicture.addMouseListener(this); |
|
80 |
|
|
81 |
this.labelAreaTypesCompactPicture.setSize(this.labelAreaTypesCompactPicture.getIcon().getIconWidth(), this.labelAreaTypesCompactPicture.getIcon().getIconHeight()); |
|
82 |
this.panelAreaTypesCompactPicture.add(this.labelAreaTypesCompactPicture); |
|
83 |
this.panelAreaTypesCompactPicture.setSize(this.labelAreaTypesCompactPicture.getSize()); |
|
84 |
this.panelAreaTypesCompact.setLayout(new GridLayout(2, 1, 7, 7)); |
|
85 |
this.panelAreaTypesCompact.add(this.radioAreaTypesCompact); |
|
86 |
this.panelAreaTypesCompact.add(this.panelAreaTypesCompactPicture); |
|
87 |
|
|
88 |
this.labelAreaTypesConvexPicture.setSize(this.labelAreaTypesConvexPicture.getIcon().getIconWidth(), this.labelAreaTypesConvexPicture.getIcon().getIconHeight()); |
|
89 |
this.panelAreaTypesConvexPicture.add(this.labelAreaTypesConvexPicture); |
|
90 |
this.panelAreaTypesConvexPicture.setSize(this.labelAreaTypesConvexPicture.getSize()); |
|
91 |
this.panelAreaTypesConvex.setLayout(new GridLayout(2, 1, 7, 7)); |
|
92 |
this.panelAreaTypesConvex.add(this.radioAreaTypesConvex); |
|
93 |
this.panelAreaTypesConvex.add(this.panelAreaTypesConvexPicture); |
|
94 |
|
|
95 |
this.panelAreaTypes.setLayout(new GridLayout(2, 1, 7, 7)); |
|
96 |
this.panelAreaTypes.add(this.panelAreaTypesCompact); |
|
97 |
this.panelAreaTypes.add(this.panelAreaTypesConvex); |
|
98 |
|
|
99 |
this.setLayout(new BorderLayout(7, 7)); |
|
100 |
this.add(this.labelChooseArea, BorderLayout.NORTH); |
|
101 |
this.add(this.panelAreaTypes, BorderLayout.CENTER); |
|
102 |
|
|
103 |
this.radioAreaTypesCompact.doClick(); |
|
104 |
} |
|
105 |
|
|
106 |
public void next(){ |
|
107 |
super.next(); |
|
108 |
} |
|
109 |
|
|
110 |
public void actionPerformed(ActionEvent e) { |
|
111 |
if(e.getSource()==this.radioAreaTypesCompact){ |
|
112 |
this.labelAreaTypesCompactPicture.setEnabled(true); |
|
113 |
this.labelAreaTypesConvexPicture.setEnabled(false); |
|
114 |
this.owner.getController().setCompactAreas(true); |
|
115 |
} |
|
116 |
else if(e.getSource()==this.radioAreaTypesConvex){ |
|
117 |
this.labelAreaTypesCompactPicture.setEnabled(false); |
|
118 |
this.labelAreaTypesConvexPicture.setEnabled(true); |
|
119 |
this.owner.getController().setCompactAreas(false); |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
public void mouseClicked(MouseEvent e) { |
|
124 |
if(e.getSource()==this.labelAreaTypesCompactPicture){ |
|
125 |
this.radioAreaTypesCompact.setSelected(true); |
|
126 |
this.radioAreaTypesCompact.doClick(); |
|
127 |
} |
|
128 |
else if(e.getSource()==this.labelAreaTypesConvexPicture){ |
|
129 |
this.radioAreaTypesConvex.setSelected(true); |
|
130 |
this.radioAreaTypesConvex.doClick(); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
public void mouseEntered(MouseEvent e) { |
|
135 |
} |
|
136 |
|
|
137 |
public void mouseExited(MouseEvent e) { |
|
138 |
} |
|
139 |
|
|
140 |
public void mousePressed(MouseEvent e) { |
|
141 |
} |
|
142 |
|
|
143 |
public void mouseReleased(MouseEvent e) { |
|
144 |
} |
|
145 |
} |
trunk/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/wizard/servicearea/ServiceAreaPage3.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.graph.gui.wizard.servicearea; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.GridLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.event.MouseEvent; |
|
9 |
import java.awt.event.MouseListener; |
|
10 |
|
|
11 |
import javax.swing.ButtonGroup; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.JPanel; |
|
14 |
import javax.swing.JRadioButton; |
|
15 |
import javax.swing.border.TitledBorder; |
|
16 |
|
|
17 |
import jwizardcomponent.JWizardPanel; |
|
18 |
|
|
19 |
import com.iver.andami.PluginServices; |
|
20 |
|
|
21 |
public class ServiceAreaPage3 extends JWizardPanel implements ActionListener, MouseListener{ |
|
22 |
private JLabel labelChooseArea; |
|
23 |
private JPanel panelAreaTypes; |
|
24 |
private ButtonGroup groupAreaTypes; |
|
25 |
private JPanel panelAreaTypesFusioned; |
|
26 |
private TitledBorder titledBorderAreaTypesFusioned; |
|
27 |
private JRadioButton radioAreaTypesFusioned; |
|
28 |
private JPanel panelAreaTypesFusionedPicture; |
|
29 |
private JLabel labelAreaTypesFusionedPicture; |
|
30 |
private JPanel panelAreaTypesNonFusioned; |
|
31 |
private TitledBorder titledBorderAreaTypesNonFusioned; |
|
32 |
private JRadioButton radioAreaTypesNonFusioned; |
|
33 |
private JPanel panelAreaTypesNonFusionedPicture; |
|
34 |
private JLabel labelAreaTypesNonFusionedPicture; |
|
35 |
|
|
36 |
/** |
|
37 |
* |
|
38 |
*/ |
|
39 |
private static final long serialVersionUID = 5139067753651358490L; |
|
40 |
|
|
41 |
private ServiceAreaWizard owner; |
|
42 |
|
|
43 |
public ServiceAreaPage3(ServiceAreaWizard wizard){ |
|
44 |
super(wizard.getWizardComponents()); |
|
45 |
this.owner=wizard; |
|
46 |
this.initialize(); |
|
47 |
} |
|
48 |
|
|
49 |
private void initialize(){ |
|
50 |
this.labelChooseArea=new JLabel("<html><b>Fusion de ?reas:</b></html>", JLabel.LEFT); |
|
51 |
this.panelAreaTypes=new JPanel(); |
|
52 |
this.groupAreaTypes=new ButtonGroup(); |
|
53 |
this.panelAreaTypesFusioned=new JPanel(); |
|
54 |
this.titledBorderAreaTypesFusioned=new TitledBorder("Fusionar ?reas"); |
|
55 |
this.panelAreaTypesFusioned.setBorder(this.titledBorderAreaTypesFusioned); |
|
56 |
this.radioAreaTypesFusioned=new JRadioButton("<html>Las ?reas de servicio que se solapen se <b>fusionar?n</b> en una sola teniendo en cuenta los costes</html>"); |
|
57 |
this.radioAreaTypesFusioned.addActionListener(this); |
|
58 |
this.radioAreaTypesFusioned.setSelected(true); |
|
59 |
this.groupAreaTypes.add(this.radioAreaTypesFusioned); |
|
60 |
this.panelAreaTypesFusionedPicture=new JPanel(); |
|
61 |
this.labelAreaTypesFusionedPicture=new JLabel(); |
|
62 |
this.labelAreaTypesFusionedPicture.setOpaque(true); |
|
63 |
this.labelAreaTypesFusionedPicture.setIcon(PluginServices.getIconTheme().get("service_area_fusion")); |
|
64 |
this.labelAreaTypesFusionedPicture.setEnabled(true); |
|
65 |
this.labelAreaTypesFusionedPicture.addMouseListener(this); |
|
66 |
this.panelAreaTypesNonFusioned=new JPanel(); |
|
67 |
this.titledBorderAreaTypesNonFusioned=new TitledBorder("No fusionar ?reas"); |
|
68 |
this.panelAreaTypesNonFusioned.setBorder(this.titledBorderAreaTypesNonFusioned); |
|
69 |
this.radioAreaTypesNonFusioned=new JRadioButton("<html>Las ?reas de servicio que ocupen un mismo lugar se solapar?n</html>"); |
|
70 |
this.radioAreaTypesNonFusioned.addActionListener(this); |
|
71 |
this.groupAreaTypes.add(this.radioAreaTypesNonFusioned); |
|
72 |
this.panelAreaTypesNonFusionedPicture=new JPanel(); |
|
73 |
this.labelAreaTypesNonFusionedPicture=new JLabel(); |
|
74 |
this.labelAreaTypesNonFusionedPicture.setOpaque(true); |
|
75 |
this.labelAreaTypesNonFusionedPicture.setBackground(Color.BLUE); |
|
76 |
this.labelAreaTypesNonFusionedPicture.setIcon(PluginServices.getIconTheme().get("service_area_non_fusion")); |
|
77 |
this.labelAreaTypesNonFusionedPicture.setEnabled(false); |
|
78 |
this.labelAreaTypesNonFusionedPicture.addMouseListener(this); |
|
79 |
|
|
80 |
this.labelAreaTypesFusionedPicture.setSize(this.labelAreaTypesFusionedPicture.getIcon().getIconWidth(), this.labelAreaTypesFusionedPicture.getIcon().getIconHeight()); |
|
81 |
this.panelAreaTypesFusionedPicture.add(this.labelAreaTypesFusionedPicture); |
|
82 |
this.panelAreaTypesFusionedPicture.setSize(this.labelAreaTypesFusionedPicture.getSize()); |
|
83 |
this.panelAreaTypesFusioned.setLayout(new GridLayout(2, 1, 7, 7)); |
|
84 |
this.panelAreaTypesFusioned.add(this.radioAreaTypesFusioned); |
|
85 |
this.panelAreaTypesFusioned.add(this.panelAreaTypesFusionedPicture); |
|
86 |
|
|
87 |
this.labelAreaTypesNonFusionedPicture.setSize(this.labelAreaTypesNonFusionedPicture.getIcon().getIconWidth(), this.labelAreaTypesNonFusionedPicture.getIcon().getIconHeight()); |
|
88 |
this.panelAreaTypesNonFusionedPicture.add(this.labelAreaTypesNonFusionedPicture); |
|
89 |
this.panelAreaTypesNonFusionedPicture.setSize(this.labelAreaTypesNonFusionedPicture.getSize()); |
|
90 |
this.panelAreaTypesNonFusioned.setLayout(new GridLayout(2, 1, 7, 7)); |
|
91 |
this.panelAreaTypesNonFusioned.add(this.radioAreaTypesNonFusioned); |
|
92 |
this.panelAreaTypesNonFusioned.add(this.panelAreaTypesNonFusionedPicture); |
|
93 |
|
|
94 |
this.panelAreaTypes.setLayout(new GridLayout(2, 1, 7, 7)); |
|
95 |
this.panelAreaTypes.add(this.panelAreaTypesFusioned); |
|
96 |
this.panelAreaTypes.add(this.panelAreaTypesNonFusioned); |
|
97 |
|
|
98 |
this.setLayout(new BorderLayout(7, 7)); |
|
99 |
this.add(this.labelChooseArea, BorderLayout.NORTH); |
|
100 |
this.add(this.panelAreaTypes, BorderLayout.CENTER); |
|
101 |
|
|
102 |
this.radioAreaTypesFusioned.doClick(); |
|
103 |
} |
|
104 |
|
|
105 |
public void next(){ |
|
106 |
super.next(); |
|
107 |
} |
|
108 |
|
Also available in: Unified diff