gvsig-geoprocess / org.gvsig.sextante / trunk / org.gvsig.sextante.app / org.gvsig.sextante.app.algorithm / org.gvsig.sextante.app.algorithm.convexhull / src / main / java / org / gvsig / sextante / app / algorithm / convexhull / ConvexHullParametersPanel.java @ 28
History | View | Annotate | Download (3.75 KB)
1 |
package org.gvsig.sextante.app.algorithm.convexhull; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Insets; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.util.ArrayList; |
10 |
import java.util.Iterator; |
11 |
import java.util.List; |
12 |
|
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JComboBox; |
15 |
|
16 |
import org.cresques.cts.IProjection; |
17 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
18 |
import org.gvsig.fmap.crs.CRSFactory; |
19 |
import org.gvsig.fmap.dal.DALLocator; |
20 |
import org.gvsig.fmap.dal.DataManager; |
21 |
import org.gvsig.fmap.dal.DataStoreParameters; |
22 |
import org.gvsig.fmap.dal.exception.InitializeException; |
23 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
24 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
25 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor; |
26 |
|
27 |
import es.unex.sextante.core.GeoAlgorithm; |
28 |
import es.unex.sextante.core.Sextante; |
29 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
30 |
|
31 |
/**
|
32 |
* @deprecated
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
34 |
*/
|
35 |
public class ConvexHullParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener { |
36 |
private GeoAlgorithm m_Algorithm = null; |
37 |
private JComboBox combo = null; |
38 |
private JButton button = null; |
39 |
private ArrayList<DataStoreParameters> paramList = new ArrayList<DataStoreParameters>(); |
40 |
|
41 |
public ConvexHullParametersPanel() {
|
42 |
super();
|
43 |
} |
44 |
|
45 |
public void init(GeoAlgorithm algorithm) { |
46 |
m_Algorithm = algorithm; |
47 |
initGUI(); |
48 |
} |
49 |
|
50 |
private void initGUI() { |
51 |
GridBagLayout gbl = new GridBagLayout(); |
52 |
this.setLayout(gbl);
|
53 |
|
54 |
GridBagConstraints gbc = new GridBagConstraints(); |
55 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
56 |
gbc.weightx = 1.0;
|
57 |
gbc.gridx = 0;
|
58 |
gbc.gridy = 0;
|
59 |
gbc.insets = new Insets(0, 2, 0, 0); |
60 |
this.add(getCombo(), gbc);
|
61 |
|
62 |
gbc.fill = GridBagConstraints.NONE;
|
63 |
gbc.weightx = 0;
|
64 |
gbc.gridx = 1;
|
65 |
gbc.insets = new Insets(0, 5, 0, 2); |
66 |
this.add(getButton(), gbc);
|
67 |
} |
68 |
|
69 |
/**
|
70 |
* Gets a ComboBox
|
71 |
* @return
|
72 |
*/
|
73 |
public JComboBox getCombo() { |
74 |
if(combo == null) { |
75 |
combo = new JComboBox(); |
76 |
loadProviderList(combo, paramList); |
77 |
combo.addActionListener(this);
|
78 |
combo.setPreferredSize(new Dimension(0, 18)); |
79 |
} |
80 |
return combo;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* Gets a JButton
|
85 |
* @return
|
86 |
*/
|
87 |
public JButton getButton() { |
88 |
if(button == null) { |
89 |
button = new JButton("..."); |
90 |
button.setPreferredSize(new Dimension(60, 18)); |
91 |
button.addActionListener(this);
|
92 |
} |
93 |
return button;
|
94 |
} |
95 |
|
96 |
@Override
|
97 |
public boolean assignParameters() { |
98 |
return false; |
99 |
} |
100 |
|
101 |
@Override
|
102 |
public void setOutputValue(String arg0, String arg1) { |
103 |
|
104 |
} |
105 |
|
106 |
@Override
|
107 |
public void setParameterValue(String arg0, String arg1) { |
108 |
|
109 |
} |
110 |
|
111 |
private void loadProviderList(JComboBox c, ArrayList<DataStoreParameters> paramList) { |
112 |
try {
|
113 |
DataManager manager = DALLocator.getDataManager(); |
114 |
List list = manager.getStoreProviders();
|
115 |
Iterator it = list.iterator();
|
116 |
c.removeAllItems(); |
117 |
paramList.clear(); |
118 |
while(it.hasNext()) {
|
119 |
try {
|
120 |
String provider = it.next().toString();
|
121 |
DataStoreParameters param = manager.createStoreParameters(provider); |
122 |
c.addItem(provider); |
123 |
paramList.add(param); |
124 |
} catch (InitializeException e1) {
|
125 |
Sextante.addErrorToLog(e1); |
126 |
} catch (ProviderNotRegisteredException e1) {
|
127 |
Sextante.addErrorToLog(e1); |
128 |
} |
129 |
} |
130 |
}catch(Exception e){} |
131 |
} |
132 |
|
133 |
public void actionPerformed(ActionEvent e) { |
134 |
if(e.getSource() == getButton()) {
|
135 |
int index = getCombo().getSelectedIndex();
|
136 |
|
137 |
DynObjectEditor editor = new DynObjectEditor(paramList.get(index),
|
138 |
DynObjectEditor.SHOW_ALL, null, true, false); |
139 |
editor.editObject(true);
|
140 |
} |
141 |
|
142 |
if(e.getSource() == getCombo()) {
|
143 |
|
144 |
} |
145 |
} |
146 |
} |