Revision 200

View differences:

org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/MANIFEST.MF
1
Manifest-Version: 1.0
2
Ant-Version: Apache Ant 1.7.1
3
Created-By: 20.1-b02 (Sun Microsystems Inc.)
4
Implementation-Version: 0.7
5
Built-Date: 2013-03-04 16:06:37
6

  
0 7

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/AlgorithmDialog.java
1
package es.unex.sextante.gui.algorithm;
2

  
3
import info.clearthought.layout.TableLayout;
4
import info.clearthought.layout.TableLayoutConstants;
5

  
6
import java.awt.Font;
7
import java.awt.event.ActionEvent;
8
import java.awt.event.ActionListener;
9
import java.util.ArrayList;
10

  
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JDialog;
14
import javax.swing.JOptionPane;
15
import javax.swing.JPanel;
16
import javax.swing.JTabbedPane;
17
import javax.swing.JTextField;
18

  
19
import es.unex.sextante.core.AnalysisExtent;
20
import es.unex.sextante.core.GeoAlgorithm;
21
import es.unex.sextante.core.OutputObjectsSet;
22
import es.unex.sextante.core.ParametersSet;
23
import es.unex.sextante.core.Sextante;
24
import es.unex.sextante.exceptions.WrongAnalysisExtentException;
25
import es.unex.sextante.exceptions.WrongInputException;
26
import es.unex.sextante.gui.core.IGUIFactory;
27
import es.unex.sextante.gui.core.SextanteGUI;
28
import es.unex.sextante.gui.exceptions.LayerCannotBeOverwrittenException;
29
import es.unex.sextante.gui.exceptions.OverwrittingNotAllowedException;
30
import es.unex.sextante.gui.exceptions.TooLargeGridExtentException;
31
import es.unex.sextante.gui.history.DateAndCommand;
32
import es.unex.sextante.gui.history.History;
33
import es.unex.sextante.outputs.Output;
34
import es.unex.sextante.outputs.Output3DRasterLayer;
35
import es.unex.sextante.outputs.OutputRasterLayer;
36
import es.unex.sextante.outputs.OutputTable;
37
import es.unex.sextante.outputs.OutputVectorLayer;
38
import es.unex.sextante.parameters.Parameter;
39

  
40

  
41
/**
42
 * A dialog used to introduce all the necessary input for a geoalgorithm (input parameters and raster extent if needed. see
43
 * {@link es.unex.sextante.core.GeoAlgorithm#getUserCanDefineAnalysisExtent()}) for a given algorithm
44
 * 
45
 * @author volaya
46
 * 
47
 */
48
public class AlgorithmDialog
49
         extends
50
            JDialog {
51

  
52
   protected GeoAlgorithm                  m_Algorithm;
53
   protected JTabbedPane                   jTabbedPane1;
54
   private JPanel                          jPanelButtons;
55
   private JPanel                          jMainPanel;
56
   protected JButton                       jButtonCancel;
57
   protected JButton                       jButtonOK;
58

  
59
   private int                             m_iDialogReturn;
60

  
61
   protected GeoAlgorithmParametersPanel   jPanelParametersMain = null;
62
   private AnalysisExtentPanel             jAnalysisExtentPanel;
63
   private JButton                         jButtonHelp;
64
   private String[]                        m_PreviousParameters;
65
   private String[]                        m_Extents;
66
   private JTextField                      jLabelCommand;
67
   private JButton                         jButtonPrevious;
68
   private JButton                         jButtonNext;
69
   private int                             m_iPreviousCommandIndex;
70
   private final ArrayList<DateAndCommand> m_sCommand;
71

  
72

  
73
   /**
74
    * Creates a new dialog for a given algorithm.
75
    * 
76
    * @param algorithm
77
    *                the algorithm
78
    * @param parent
79
    *                the parent dialog
80
    * @param panel
81
    *                the parameters panel to use. Doesn't have to be initialized using its init(Geoalgorithm) method. This
82
    *                constructor will initialize it
83
    * @param commands
84
    *                a list of DateAndCommand objects to use as previous parameters set. Must include both the "runalg" commands
85
    *                and the "extent" ones, in case you want them to be used for algorithms generating new raster layers. If null,
86
    *                all suitable commands from history are used
87
    */
88
   public AlgorithmDialog(final GeoAlgorithm algorithm,
89
                          final JDialog parent,
90
                          final GeoAlgorithmParametersPanel panel,
91
                          final ArrayList<DateAndCommand> commands) {
92

  
93
      super(parent, algorithm.getName(), true);
94

  
95
      setResizable(false);
96

  
97
      m_Algorithm = algorithm;
98
      m_sCommand = commands;
99

  
100
      jPanelParametersMain = panel;
101
      jPanelParametersMain.init(m_Algorithm);
102

  
103
      initGUI();
104
      setLocationRelativeTo(null);
105

  
106
   }
107

  
108

  
109
   /**
110
    * Creates a new dialog for a given algorithm. The main frame of the UI is used as the parent component
111
    * 
112
    * @param algorithm
113
    *                the algorithm
114
    * @param panel
115
    *                the parameters panel to use. Doesn't have to be initialized using its init(Geoalgorithm) method. This
116
    *                constructor will initialize it
117
    * @param comands
118
    *                a list of DateAndCommand objects to use as previous parameters set. Must include both the "runalg" commands
119
    *                and the "extent" ones, in case you want them to be used for algorithms generating new raster layers. If null,
120
    *                all suitable commands from history are used
121
    */
122
   public AlgorithmDialog(final GeoAlgorithm algorithm,
123
                          final GeoAlgorithmParametersPanel panel,
124
                          final ArrayList<DateAndCommand> commands) {
125

  
126
      super(SextanteGUI.getMainFrame(), algorithm.getName(), true);
127

  
128
      setResizable(false);
129

  
130
      m_sCommand = commands;
131
      m_Algorithm = algorithm;
132

  
133
      jPanelParametersMain = panel;
134
      jPanelParametersMain.init(m_Algorithm);
135

  
136
      initGUI();
137
      setLocationRelativeTo(null);
138

  
139
   }
140

  
141

  
142
   private void initGUI() {
143

  
144

  
145
      jMainPanel = new JPanel();
146

  
147
      this.add(jMainPanel);
148

  
149
      final TableLayout thisLayout = new TableLayout(new double[][] { { 10.0, TableLayoutConstants.FILL, 10. },
150
               { 1.0, 338.0, 37.0 } });
151
      jMainPanel.setLayout(thisLayout);
152
      this.setSize(696, 446);
153
      {
154
         jTabbedPane1 = new JTabbedPane();
155
         jMainPanel.add(jTabbedPane1, "1, 1");
156
         {
157
            jTabbedPane1.addTab(Sextante.getText("Parameters"), null, jPanelParametersMain, null);
158
         }
159
         {
160
            if (m_Algorithm.getUserCanDefineAnalysisExtent()) {
161
               jTabbedPane1.addTab(Sextante.getText("Raster_output"), null, getAnalysisExtentPanel(), null);
162
            }
163
         }
164
      }
165
      {
166
         jPanelButtons = new JPanel();
167
         final TableLayout jPanelButtonsLayout = new TableLayout(new double[][] {
168
                  { 5.0, 45.0, 120.0, 120.0, 45.0, TableLayoutConstants.FILL, 90.0, 90.0, 25.0, 15.0 },
169
                  { TableLayoutConstants.FILL, 25.0, TableLayoutConstants.FILL } });
170
         jPanelButtonsLayout.setHGap(5);
171
         jPanelButtonsLayout.setVGap(5);
172
         jPanelButtons.setLayout(jPanelButtonsLayout);
173
         jMainPanel.add(jPanelButtons, "1, 2");
174
         jPanelButtons.setFocusable(false);
175
         {
176
            jButtonOK = new JButton();
177
            jPanelButtons.add(jButtonOK, "6, 1");
178
            jButtonOK.setText(Sextante.getText("OK"));
179
            jButtonOK.addActionListener(new java.awt.event.ActionListener() {
180
               public void actionPerformed(final java.awt.event.ActionEvent e) {
181
                  executeAlgorithm();
182
               }
183
            });
184
         }
185
         {
186
            jButtonHelp = new JButton();
187
            jPanelButtons.add(jButtonHelp, "8, 1");
188
            jButtonHelp.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/info.gif")));
189
            jButtonHelp.setPreferredSize(new java.awt.Dimension(33, 0));
190
            jButtonHelp.addActionListener(new ActionListener() {
191
               public void actionPerformed(final ActionEvent evt) {
192
                  showHelp();
193
               }
194
            });
195
         }
196
         {
197
            jButtonCancel = new JButton();
198
            jPanelButtons.add(jButtonCancel, "7, 1");
199
            jButtonCancel.setText(Sextante.getText("Cancel"));
200
            jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
201
               public void actionPerformed(final java.awt.event.ActionEvent e) {
202
                  m_iDialogReturn = IGUIFactory.CANCEL;
203
                  dispose();
204
                  setVisible(false);
205
               }
206
            });
207
         }
208

  
209
      }
210

  
211
      retrievePreviouslyUsedParametersFromHistory();
212
      if (m_PreviousParameters != null) {
213
         try {
214
            {
215
               jButtonPrevious = new JButton();
216
               jPanelButtons.add(jButtonPrevious, "1, 1");
217
               jButtonPrevious.setText("<");
218
               jButtonPrevious.addActionListener(new ActionListener() {
219
                  public void actionPerformed(final ActionEvent evt) {
220
                     setPreviousSetOfPreviouslyUsedCommand();
221
                  }
222
               });
223
            }
224
            {
225
               jButtonNext = new JButton();
226
               jPanelButtons.add(jButtonNext, "4, 1");
227
               jButtonNext.setText(">");
228
               jButtonNext.addActionListener(new ActionListener() {
229
                  public void actionPerformed(final ActionEvent evt) {
230
                     setNextSetOfPreviouslyUsedCommand();
231
                  }
232
               });
233
            }
234
            {
235
               jLabelCommand = new JTextField();
236
               jLabelCommand.setFont(new Font("Monospaced", Font.PLAIN, 10));
237
               jLabelCommand.setEditable(false);
238
               jPanelButtons.add(jLabelCommand, "2, 1, 3, 1");
239
            }
240

  
241
            m_iPreviousCommandIndex = m_PreviousParameters.length - 1;
242
            setPreviouslyUsedParameters(m_iPreviousCommandIndex);
243
         }
244
         catch (final Exception e) {
245
            // do nothing
246
         }
247
      }
248

  
249
   }
250

  
251

  
252
   private void setPreviouslyUsedParameters(final int iIndex) {
253

  
254
      int i;
255
      Parameter param;
256
      String[] args;
257
      String sArg;
258

  
259
      jLabelCommand.setText("[" + Integer.toString(iIndex + 1) + "] " + m_PreviousParameters[iIndex]);
260
      args = m_PreviousParameters[iIndex].split("\"");
261

  
262
      for (int j = 0; j < 2; j++) { //twice to handle dependencies
263
         final ParametersSet ps = m_Algorithm.getParameters();
264
         for (i = 0; i < m_Algorithm.getNumberOfParameters(); i++) {
265
            param = ps.getParameter(i);
266
            sArg = args[i * 2 + 3];
267
            jPanelParametersMain.setParameterValue(param.getParameterName(), sArg.trim());
268
         }
269
         int iOutputIndex = i * 2 + 3;
270
         final OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
271
         for (i = 0; i < ooSet.getOutputObjectsCount(); i++) {
272
            final Output out = ooSet.getOutput(i);
273
            if ((out instanceof OutputRasterLayer) || (out instanceof Output3DRasterLayer) || (out instanceof OutputVectorLayer)
274
                || (out instanceof OutputTable)) {
275
               final String sValue = args[iOutputIndex].trim();
276
               jPanelParametersMain.setOutputValue(out.getName(), sValue);
277
               iOutputIndex += 2;
278
            }
279
         }
280
      }
281

  
282
      if (m_Algorithm.getUserCanDefineAnalysisExtent()) {
283
         String sExtent = m_Extents[iIndex];
284
         if (sExtent != null) {
285
            sExtent = sExtent.substring(sExtent.indexOf("(") + 1, sExtent.indexOf(")"));
286
            final AnalysisExtent ae = new AnalysisExtent();
287
            final String[] sCoords = sExtent.split(",");
288
            final double dCellSize = Double.parseDouble(sCoords[6]);
289
            final double dCellSizeZ = Double.parseDouble(sCoords[7]);
290
            ae.setCellSize(dCellSize);
291
            ae.setCellSizeZ(dCellSizeZ);
292
            final double xMin = Double.parseDouble(sCoords[0]);
293
            final double xMax = Double.parseDouble(sCoords[3]);
294
            ae.setXRange(xMin, xMax, true);
295
            final double yMin = Double.parseDouble(sCoords[1]);
296
            final double yMax = Double.parseDouble(sCoords[4]);
297
            ae.setYRange(yMin, yMax, true);
298
            final double zMin = Double.parseDouble(sCoords[2]);
299
            final double zMax = Double.parseDouble(sCoords[5]);
300
            ae.setZRange(zMin, zMax, true);
301
            getAnalysisExtentPanel().setExtent(ae);
302
         }
303
         else {
304
            getAnalysisExtentPanel().setAutoExtent();
305
         }
306
      }
307

  
308
   }
309

  
310

  
311
   private void retrievePreviouslyUsedParametersFromHistory() {
312

  
313
      ArrayList<DateAndCommand> dac;
314
      if (m_sCommand != null) {
315
         dac = m_sCommand;
316
      }
317
      else {
318
         dac = History.getHistory();
319
      }
320
      final ArrayList<String> previousParameters = new ArrayList<String>();
321
      final ArrayList<String> extents = new ArrayList<String>();
322
      for (int i = 0; i < dac.size(); i++) {
323
         String command = dac.get(i).getCommand();
324
         if (command.startsWith("runalg(\"" + m_Algorithm.getCommandLineName() + "\"")) {
325
            previousParameters.add(command);
326
            if (m_Algorithm.getUserCanDefineAnalysisExtent() && (i != 0)) {
327
               command = dac.get(i - 1).getCommand();
328
               if (command.startsWith("extent")) {
329
                  extents.add(command);
330
               }
331
               else {
332
                  extents.add(null);
333
               }
334
            }
335
         }
336
      }
337

  
338
      if (previousParameters.size() == 0) {
339
         m_PreviousParameters = null;
340
         m_Extents = null;
341
      }
342
      else {
343
         m_PreviousParameters = previousParameters.toArray(new String[0]);
344
         m_Extents = extents.toArray(new String[0]);
345

  
346
      }
347

  
348
   }
349

  
350

  
351
   public void setPreviousSetOfPreviouslyUsedCommand() {
352

  
353
      if (m_iPreviousCommandIndex <= 0) {
354
         //m_iPreviousCommandIndex = m_PreviousParameters.length - 1;
355
      }
356
      else {
357
         m_iPreviousCommandIndex--;
358
         setPreviouslyUsedParameters(m_iPreviousCommandIndex);
359
      }
360

  
361

  
362
   }
363

  
364

  
365
   public void setNextSetOfPreviouslyUsedCommand() {
366

  
367
      if (m_iPreviousCommandIndex >= m_PreviousParameters.length - 1) {
368
         //m_iPreviousCommandIndex = 0;
369
      }
370
      else {
371
         m_iPreviousCommandIndex++;
372
         setPreviouslyUsedParameters(m_iPreviousCommandIndex);
373
      }
374

  
375

  
376
   }
377

  
378

  
379
   protected void showHelp() {
380

  
381
      SextanteGUI.getGUIFactory().showHelpDialog(m_Algorithm);
382

  
383
   }
384

  
385

  
386
   protected void executeAlgorithm() {
387

  
388
      try {
389
         try {
390
            assignParameters();
391
         }
392
         catch (final TooLargeGridExtentException e) {
393
            final int iRet = JOptionPane.showConfirmDialog(null, e.getMessage(), Sextante.getText("Warning"),
394
                     JOptionPane.YES_NO_OPTION);
395
            if (iRet != JOptionPane.YES_OPTION) {
396
               this.jTabbedPane1.setSelectedIndex(1);
397
               return;
398
            }
399
         }
400

  
401
         m_iDialogReturn = IGUIFactory.OK;
402

  
403
         dispose();
404
         setVisible(false);
405

  
406
      }
407
      catch (final WrongInputException e) {
408
         JOptionPane.showMessageDialog(null, e.getMessage(), Sextante.getText("Warning"), JOptionPane.WARNING_MESSAGE);
409
         this.jTabbedPane1.setSelectedIndex(0);
410
      }
411
      catch (final WrongAnalysisExtentException e) {
412
         JOptionPane.showMessageDialog(null, e.getMessage(), Sextante.getText("Warning"), JOptionPane.WARNING_MESSAGE);
413
         this.jTabbedPane1.setSelectedIndex(1);
414
      }
415
      catch (final OverwrittingNotAllowedException e) {
416
         JOptionPane.showMessageDialog(null, e.getMessage(), Sextante.getText("Warning"), JOptionPane.WARNING_MESSAGE);
417
         this.jTabbedPane1.setSelectedIndex(0);
418
      }
419
      catch (final LayerCannotBeOverwrittenException e) {
420
         JOptionPane.showMessageDialog(null, e.getMessage(), Sextante.getText("Warning"), JOptionPane.WARNING_MESSAGE);
421
         this.jTabbedPane1.setSelectedIndex(0);
422
      }
423

  
424
   }
425

  
426

  
427
   protected void assignParameters() throws WrongInputException, OverwrittingNotAllowedException,
428
                                    LayerCannotBeOverwrittenException, WrongAnalysisExtentException, TooLargeGridExtentException {
429

  
430
      jPanelParametersMain.assignParameters();
431
      if (m_Algorithm.getUserCanDefineAnalysisExtent()) {
432
         getAnalysisExtentPanel().assignExtent();
433
      }
434

  
435
   }
436

  
437

  
438
   private AnalysisExtentPanel getAnalysisExtentPanel() {
439

  
440
      if (jAnalysisExtentPanel == null) {
441
         if (m_Algorithm.is3D()) {
442
            jAnalysisExtentPanel = new TridimensionalAnalysisExtentPanel(m_Algorithm);
443
         }
444
         else {
445
            jAnalysisExtentPanel = new AnalysisExtentPanel(m_Algorithm);
446
         }
447
      }
448
      return jAnalysisExtentPanel;
449

  
450
   }
451

  
452

  
453
   /**
454
    * Returns {@link es.unex.sextante.gui.core.IGUIFactory#OK} if the user selected "OK" and the algorithm should be executed
455
    * 
456
    * @return IGUIFactory.OK if the user selected "OK" and the algorithm should be executed
457
    */
458
   public int getDialogReturn() {
459

  
460
      return m_iDialogReturn;
461

  
462
   }
463

  
464

  
465
}
0 466

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/GeneralOptionsChannelSelectionPanel.java
1
package es.unex.sextante.gui.algorithm;
2

  
3
import info.clearthought.layout.TableLayout;
4

  
5
import java.awt.event.ActionListener;
6

  
7
import javax.swing.JButton;
8
import javax.swing.JPanel;
9

  
10
import es.unex.sextante.core.Sextante;
11
import es.unex.sextante.outputs.Output;
12
import es.unex.sextante.outputs.OutputVectorLayer;
13

  
14
public class GeneralOptionsChannelSelectionPanel
15
         extends
16
            JPanel {
17

  
18
   public static final String   OVERWRITE            = "OVERWRITE";
19
   public static final String   SAVE_TO_TEMP_FILE    = "SET_TEMP_FILE";
20
   public static final String   DO_NOT_CREATE_OUTPUT = "DO_NOT_CREATE_OUTPUT";
21

  
22
   private final ActionListener m_Listener;
23
   private JButton              jButtonSetTempFile;
24
   private JButton              jButtonSetOverwrite;
25
   private JButton              jButtonDoNotCreate;
26
   private final Output         m_Output;
27

  
28

  
29
   public GeneralOptionsChannelSelectionPanel(final Output output,
30
                                              final ActionListener listener) {
31

  
32
      super();
33

  
34
      m_Listener = listener;
35
      m_Output = output;
36

  
37
      initGUI();
38

  
39
   }
40

  
41

  
42
   private void initGUI() {
43

  
44
      this.setLayout(new TableLayout(new double[][] { { 50, TableLayout.FILL, 50 },
45
               { 50, TableLayout.MINIMUM, 50, TableLayout.MINIMUM, 50, TableLayout.MINIMUM, TableLayout.FILL } }));
46

  
47
      //this.setLayout(new FlowLayout());
48

  
49

  
50
      if (m_Output instanceof OutputVectorLayer) {
51
         if (((OutputVectorLayer) m_Output).canOverwrite()) {
52
            jButtonSetOverwrite = new JButton(Sextante.getText("Overwrite"));
53
            jButtonSetOverwrite.addActionListener(m_Listener);
54
            jButtonSetOverwrite.setActionCommand(OVERWRITE);
55
            this.add("1,5", jButtonSetOverwrite);
56
         }
57
      }
58
      jButtonSetTempFile = new JButton(Sextante.getText("Save_to_temp_file"));
59
      jButtonSetTempFile.addActionListener(m_Listener);
60
      jButtonSetTempFile.setActionCommand(SAVE_TO_TEMP_FILE);
61
      this.add("1,1", jButtonSetTempFile);
62

  
63
      jButtonDoNotCreate = new JButton(Sextante.getText("Do_not_create_output"));
64
      jButtonDoNotCreate.addActionListener(m_Listener);
65
      jButtonDoNotCreate.setActionCommand(DO_NOT_CREATE_OUTPUT);
66
      this.add("1,3", jButtonDoNotCreate);
67

  
68
   }
69

  
70

  
71
}
0 72

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/iterative/SingleFeatureVectorLayer.java
1
package es.unex.sextante.gui.algorithm.iterative;
2

  
3
import java.awt.geom.Rectangle2D;
4

  
5
import com.vividsolutions.jts.geom.Envelope;
6
import com.vividsolutions.jts.geom.Geometry;
7

  
8
import org.gvsig.tools.exception.BaseException;
9

  
10
import es.unex.sextante.dataObjects.AbstractVectorLayer;
11
import es.unex.sextante.dataObjects.IFeatureIterator;
12
import es.unex.sextante.dataObjects.IVectorLayer;
13
import es.unex.sextante.dataObjects.vectorFilters.IVectorLayerFilter;
14
import es.unex.sextante.outputs.IOutputChannel;
15

  
16
public class SingleFeatureVectorLayer
17
         extends
18
            AbstractVectorLayer {
19

  
20

  
21
   private String         m_sName;
22
   private Object[]       m_Record;
23
   private Geometry       m_Geometry;
24
   private final String[] m_sFields;
25
   private final Object   m_CRS;
26
   private IVectorLayer   m_OriginalLayer;
27
   private final int      m_iShapeType;
28
   private int      	  m_ID;
29

  
30

  
31
   public SingleFeatureVectorLayer(final IVectorLayer layer) {
32

  
33
      m_sFields = layer.getFieldNames();
34
      m_CRS = layer.getCRS();
35
      m_OriginalLayer = layer;
36
      m_sName = layer.getName();
37
      m_iShapeType = layer.getShapeType();
38

  
39
   }
40

  
41

  
42
   public void setFeature(final Geometry geometry,
43
                          final Object[] record) {
44

  
45
      m_Geometry = geometry;
46
      m_Record = record;
47

  
48
   }
49

  
50

  
51
   public void addFeature(final Geometry geometry,
52
                          final Object[] attributes) {}
53

  
54

  
55
   public int getFieldCount() {
56

  
57
      return m_Record.length;
58

  
59
   }
60

  
61

  
62
   public String getFieldName(final int iIndex) {
63

  
64
      return m_sFields[iIndex];
65

  
66
   }
67

  
68

  
69
   public Class getFieldType(final int iIndex) {
70

  
71
      return m_Record[iIndex].getClass();
72
   }
73

  
74

  
75
   public int getShapeType() {
76

  
77
      return m_iShapeType;
78

  
79
   }
80

  
81

  
82
   public IFeatureIterator iterator() {
83

  
84
      return new SingleFeatureIterator(m_Geometry, m_Record);
85

  
86
   }
87

  
88

  
89
   public Object getCRS() {
90

  
91
      return m_CRS;
92

  
93
   }
94

  
95

  
96
   @Override
97
   public Rectangle2D getFullExtent() {
98

  
99
      final Envelope env = m_Geometry.getEnvelopeInternal();
100
      return new Rectangle2D.Double(env.getMinX(), env.getMinY(), env.getWidth(), env.getHeight());
101

  
102
   }
103

  
104

  
105
   public void close() {}
106

  
107

  
108
   public IOutputChannel getOutputChannel() {
109

  
110
      return null;
111

  
112
   }
113

  
114

  
115
   public String getName() {
116

  
117
      return m_sName;
118

  
119
   }
120

  
121

  
122
   public void open() {}
123

  
124

  
125
   public void postProcess() throws Exception {}
126

  
127

  
128
   public void setName(final String sName) {
129

  
130
      m_sName = sName;
131

  
132
   }
133

  
134

  
135
   /*
136
    * Sets an internal ID. Useful for keeping external algorithm
137
    * providers such as GRASS informed which feature is being
138
    * processed by an iterative processor.
139
    * Use range 1..n.
140
    */
141
   public void setID (final int ID) {
142

  
143
	      m_ID = ID;
144

  
145
   }
146

  
147

  
148
   public int getID () {
149

  
150
	      return ( m_ID );
151

  
152
  }
153

  
154

  
155
   public IVectorLayer getOriginalLayer() {
156

  
157
      return m_OriginalLayer;
158

  
159
   }
160

  
161

  
162
   @Override
163
   public void addFilter(final IVectorLayerFilter filter) {}
164

  
165

  
166
   @Override
167
   public void removeFilters() {}
168

  
169

  
170
   @Override
171
   public Object getBaseDataObject() {
172

  
173
      return null;
174

  
175
   }
176

  
177

  
178
   public void free() {
179

  
180
      m_OriginalLayer = null;
181

  
182
   }
183

  
184

  
185
   public boolean canBeEdited() {
186

  
187
      return false;
188

  
189
   }
190

  
191

  
192
    /* (non-Javadoc)
193
     * @see es.unex.sextante.dataObjects.IVectorLayer#getSubType()
194
     */
195
    @Override
196
    public int getSubType() throws BaseException {
197
        return m_OriginalLayer.getSubType();
198
    }
199

  
200

  
201
}
0 202

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/iterative/IterativeAlgorithmMonitorableTask.java
1
package es.unex.sextante.gui.algorithm.iterative;
2

  
3
import java.util.ArrayList;
4
import java.util.HashMap;
5
import java.util.Iterator;
6
import java.util.Set;
7
import java.util.concurrent.ExecutorService;
8
import java.util.concurrent.Executors;
9
import java.util.concurrent.Future;
10

  
11
import javax.swing.JDialog;
12
import javax.swing.JOptionPane;
13
import javax.swing.JScrollPane;
14
import javax.swing.JTable;
15
import javax.swing.table.DefaultTableModel;
16

  
17
import es.unex.sextante.core.GeoAlgorithm;
18
import es.unex.sextante.core.ITaskMonitor;
19
import es.unex.sextante.core.ObjectAndDescription;
20
import es.unex.sextante.core.OutputObjectsSet;
21
import es.unex.sextante.core.Sextante;
22
import es.unex.sextante.dataObjects.IFeature;
23
import es.unex.sextante.dataObjects.IFeatureIterator;
24
import es.unex.sextante.dataObjects.IVectorLayer;
25
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
26
import es.unex.sextante.exceptions.NullParameterValueException;
27
import es.unex.sextante.exceptions.WrongParameterIDException;
28
import es.unex.sextante.exceptions.WrongParameterTypeException;
29
import es.unex.sextante.gui.additionalResults.AdditionalResults;
30
import es.unex.sextante.gui.core.SextanteGUI;
31
import es.unex.sextante.outputs.FileOutputChannel;
32
import es.unex.sextante.outputs.IOutputChannel;
33
import es.unex.sextante.outputs.Output;
34
import es.unex.sextante.outputs.OutputNumericalValue;
35

  
36
/**
37
 * A task to execute an algorithm iteratively over all the features of a vector layer
38
 * 
39
 * @author volaya
40
 * 
41
 */
42
public class IterativeAlgorithmMonitorableTask
43
         implements
44
            Runnable {
45

  
46
   private String                                           m_sErrorMessage;
47
   private final GeoAlgorithm                               m_Algorithm;
48
   private ITaskMonitor                                     m_ProgressMonitor = null;
49
   private final String                                     m_sParameterToIterateOver;
50
   private final SingleFeatureVectorLayer                   m_SFVL;
51
   private final IFeatureIterator                           m_Iterator;
52
   private final int                                        m_iShapesCount;
53
   private String                                           m_sLayerName;
54
   private final ArrayList<ArrayList<OutputNumericalValue>> m_NumericalOutputs;
55

  
56

  
57
   /**
58
    * Creates a new task
59
    * 
60
    * @param algorithm
61
    *                the algorithm to execute
62
    * @param parent
63
    *                the dialog from which it has been called, to be used as parent for the monitor dialog
64
    * @param sParameterToIterateOver
65
    *                the name of the parameter to iterate over
66
    * @throws WrongParameterIDException
67
    * @throws NullParameterValueException
68
    * @throws WrongParameterTypeException
69
    */
70
   public IterativeAlgorithmMonitorableTask(final GeoAlgorithm algorithm,
71
                                            final JDialog parent,
72
                                            final String sParameterToIterateOver) throws GeoAlgorithmExecutionException {
73

  
74
      try {
75
         m_Algorithm = algorithm;
76
         m_NumericalOutputs = new ArrayList<ArrayList<OutputNumericalValue>>();
77
         m_sParameterToIterateOver = sParameterToIterateOver;
78
         m_ProgressMonitor = SextanteGUI.getOutputFactory().getTaskMonitor(algorithm.getName(),
79
                  algorithm.isDeterminatedProcess(), parent);
80
         final IVectorLayer layer = m_Algorithm.getParameters().getParameter(m_sParameterToIterateOver).getParameterValueAsVectorLayer();
81
         m_Iterator = layer.iterator();
82
         m_iShapesCount = layer.getShapesCount();
83
         m_SFVL = new SingleFeatureVectorLayer(layer);
84
         m_Algorithm.getParameters().getParameter(m_sParameterToIterateOver).setParameterValue(m_SFVL);
85
         m_sLayerName = layer.getName();
86
      }
87
      catch (final Exception e) {
88
         if (m_ProgressMonitor != null) {
89
            m_ProgressMonitor.close();
90
         }
91
         throw new GeoAlgorithmExecutionException(e.getMessage());
92
      }
93

  
94
   }
95

  
96

  
97
   /**
98
    * Runs the batch process
99
    */
100
   public void run() {
101

  
102
      final OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
103
      final HashMap<String, String> filenames = new HashMap<String, String>();
104
      for (int i = 0; i < ooset.getOutputObjectsCount(); i++) {
105
         final Output output = ooset.getOutput(i);
106
         final IOutputChannel channel = output.getOutputChannel();
107
         if (channel != null) {
108
            if (channel instanceof FileOutputChannel) {
109
               final FileOutputChannel foc = (FileOutputChannel) channel;
110
               filenames.put(output.getName(), foc.getFilename());
111
            }
112
            else {
113
               m_sErrorMessage = Sextante.getText("Unsupported output channel:") + channel.toString();
114
               JOptionPane.showMessageDialog(null, m_sErrorMessage, Sextante.getText("Error"), JOptionPane.ERROR_MESSAGE);
115
            }
116
         }
117

  
118
      }
119

  
120
      int iIteration = 1;
121

  
122
      while (m_Iterator.hasNext()) {
123
         try {
124
            final IFeature feature = m_Iterator.next();
125
            m_SFVL.setFeature(feature.getGeometry(), feature.getRecord().getValues());
126
            m_SFVL.setName(m_sLayerName + "[" + Integer.toString(iIteration) + "]");
127
            m_SFVL.setID(iIteration);
128
            final Set<String> names = filenames.keySet();
129
            for (final Iterator iter = names.iterator(); iter.hasNext();) {
130
               final String sName = (String) iter.next();
131
               String sFilename = filenames.get(sName);
132
               if (sFilename == null) {
133
                  ooset.getOutput(sName).setOutputChannel(new FileOutputChannel(null));
134
               }
135
               else {
136
                  sFilename = sFilename + "_" + Integer.toString(iIteration);
137
                  ooset.getOutput(sName).setOutputChannel(new FileOutputChannel(sFilename));
138
               }
139
            }
140

  
141
            m_ProgressMonitor.setDescriptionPrefix("[" + Integer.toString(iIteration) + "/" + Integer.toString(m_iShapesCount)
142
                                                   + "] ");
143

  
144
            IterativeAlgorithmSingleUnit unit;
145
            final GeoAlgorithm alg = m_Algorithm.getNewInstance();
146
            unit = new IterativeAlgorithmSingleUnit(alg, m_ProgressMonitor, Integer.toString(iIteration), m_NumericalOutputs);
147

  
148
            final ExecutorService pool = Executors.newFixedThreadPool(2);
149
            final Future<Boolean> future = pool.submit(unit);
150
            Boolean success = null;
151
            success = future.get();
152
            if (!success.booleanValue() || m_ProgressMonitor.isCanceled()) {
153
               break;
154
            }
155
            iIteration++;
156
         }
157
         catch (final Exception e) {
158
            Sextante.addErrorToLog(e);
159
            m_sErrorMessage = e.getMessage();
160
            break;
161
         }
162
      }
163

  
164
      m_ProgressMonitor.close();
165

  
166
      if (m_sErrorMessage != null) {
167
         JOptionPane.showMessageDialog(null, m_sErrorMessage, Sextante.getText("Error"), JOptionPane.ERROR_MESSAGE);
168
      }
169

  
170
      final JScrollPane table = createNumericalOutputsTable();
171

  
172
      SextanteGUI.getInputFactory().clearDataObjects();
173
      SextanteGUI.getInputFactory().createDataObjects();
174

  
175
      if (table != null) {
176
         AdditionalResults.addComponent(new ObjectAndDescription(m_Algorithm.getName() + "[" + m_sLayerName + "]", table));
177
      }
178

  
179
   }
180

  
181

  
182
   private JScrollPane createNumericalOutputsTable() {
183

  
184
      if (m_NumericalOutputs.size() == 0) {
185
         return null;
186
      }
187

  
188
      final JScrollPane jScrollPane = new JScrollPane();
189
      final JTable jTable = new JTable();
190
      jScrollPane.setViewportView(jTable);
191

  
192

  
193
      final int iRecordsCount = m_NumericalOutputs.size();
194
      final int iFieldsCount = m_NumericalOutputs.get(0).size();
195
      final String[] fields = new String[iFieldsCount];
196
      for (int i = 0; i < fields.length; i++) {
197
         fields[i] = m_NumericalOutputs.get(0).get(i).getDescription();
198
      }
199

  
200
      final String[][] data = new String[iRecordsCount][fields.length];
201

  
202
      for (int i = 0; i < iRecordsCount; i++) {
203
         for (int j = 0; j < iFieldsCount; j++) {
204
            data[i][j] = m_NumericalOutputs.get(i).get(j).getOutputObject().toString();
205
         }
206
      }
207

  
208
      final DefaultTableModel model = new DefaultTableModel();
209
      model.setDataVector(data, fields);
210
      jTable.setModel(model);
211
      jTable.setEnabled(false);
212

  
213
      return jScrollPane;
214

  
215
   }
216

  
217
}
0 218

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/iterative/IterativeAlgorithmSingleUnit.java
1
package es.unex.sextante.gui.algorithm.iterative;
2

  
3
import java.util.ArrayList;
4
import java.util.concurrent.Callable;
5
import java.util.concurrent.ExecutorService;
6
import java.util.concurrent.Executors;
7
import java.util.concurrent.Future;
8

  
9
import es.unex.sextante.core.GeoAlgorithm;
10
import es.unex.sextante.core.ITaskMonitor;
11
import es.unex.sextante.core.OutputObjectsSet;
12
import es.unex.sextante.core.ProcessTask;
13
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
14
import es.unex.sextante.gui.core.SextanteGUI;
15
import es.unex.sextante.outputs.Output;
16
import es.unex.sextante.outputs.OutputNumericalValue;
17

  
18
/**
19
 * A task representing a single algorithm execution as a part of a batch process. The process is comprised of several single units
20
 * like the one represented by this class
21
 * 
22
 * @author volaya
23
 * 
24
 */
25
public class IterativeAlgorithmSingleUnit
26
         implements
27
            Callable<Boolean> {
28

  
29
   private final GeoAlgorithm                               m_Algorithm;
30
   private StringBuffer                                     m_sLog;
31
   private final ITaskMonitor                               m_TaskMonitor;
32
   private final String                                     m_sUnitName;
33
   private final ArrayList<ArrayList<OutputNumericalValue>> m_NumericalOutputs;
34

  
35

  
36
   /**
37
    * 
38
    * @param alg
39
    *                the algorithm to execute
40
    * @param monitor
41
    *                the task monitor to use
42
    * @param sUnitName
43
    *                the name of the unit to be executed
44
    * @param numericalOutputs
45
    *                an array list to collect numerical outputs produced by the algorithm
46
    */
47
   public IterativeAlgorithmSingleUnit(final GeoAlgorithm alg,
48
                                       final ITaskMonitor monitor,
49
                                       final String sUnitName,
50
                                       final ArrayList<ArrayList<OutputNumericalValue>> numericalOutputs) {
51

  
52
      m_Algorithm = alg;
53
      m_TaskMonitor = monitor;
54
      m_sUnitName = sUnitName;
55
      m_NumericalOutputs = numericalOutputs;
56

  
57
   }
58

  
59

  
60
   /**
61
    * Executes the algorithm
62
    * 
63
    * @return true if the algorithm was not canceled
64
    * @throws GeoAlgorithmExecutionException
65
    */
66
   public Boolean call() throws GeoAlgorithmExecutionException {
67

  
68
      final ExecutorService pool = Executors.newFixedThreadPool(1);
69
      final Future<Boolean> p = pool.submit(new ProcessTask(m_Algorithm, SextanteGUI.getOutputFactory(), m_TaskMonitor));
70
      try {
71
         final Boolean success = p.get();
72
         if ((success != null) && success.booleanValue()) {
73
            changeOutputDescriptions();
74
            collectIndividualNumericalOutputs();
75
            final Runnable postProcess = SextanteGUI.getPostProcessTask(m_Algorithm, false);
76
            if (postProcess != null) {
77
               postProcess.run();
78
            }
79
            return true;
80
         }
81
         else {
82
            return false;
83
         }
84

  
85
      }
86
      catch (final Exception e) {
87
         throw new GeoAlgorithmExecutionException(e.getMessage());
88
      }
89
   }
90

  
91

  
92
   private void collectIndividualNumericalOutputs() {
93

  
94
      final ArrayList<OutputNumericalValue> numericalOutputs = new ArrayList<OutputNumericalValue>();
95
      final OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
96
      for (int i = 0; i < ooset.getOutputObjectsCount(); i++) {
97
         final Output out = ooset.getOutput(i);
98
         if (out instanceof OutputNumericalValue) {
99
            numericalOutputs.add((OutputNumericalValue) out);
100
         }
101
      }
102

  
103
      m_NumericalOutputs.add(numericalOutputs);
104

  
105
   }
106

  
107

  
108
   private void changeOutputDescriptions() {
109

  
110
      final OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
111
      for (int i = 0; i < ooset.getOutputObjectsCount(); i++) {
112
         final Output out = ooset.getOutput(i);
113
         if (!(out instanceof OutputNumericalValue)) {
114
            out.setDescription(out.getDescription() + " <" + m_sUnitName + ">");
115
         }
116
      }
117

  
118
   }
119

  
120

  
121
   /**
122
    * Returns a string with information about the executed process
123
    * 
124
    * @return a string with information about the executed process
125
    */
126
   public String getLog() {
127

  
128
      return m_sLog.toString();
129

  
130
   }
131

  
132
}
0 133

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/iterative/SingleFeatureIterator.java
1
package es.unex.sextante.gui.algorithm.iterative;
2

  
3
import java.awt.geom.Rectangle2D;
4

  
5
import com.vividsolutions.jts.geom.Envelope;
6
import com.vividsolutions.jts.geom.Geometry;
7

  
8
import es.unex.sextante.dataObjects.FeatureImpl;
9
import es.unex.sextante.dataObjects.IFeature;
10
import es.unex.sextante.dataObjects.IFeatureIterator;
11

  
12
public class SingleFeatureIterator
13
         implements
14
            IFeatureIterator {
15

  
16

  
17
   private final Geometry m_Geometry;
18
   private final Object[] m_Record;
19
   private boolean        m_bHasNext;
20

  
21

  
22
   public SingleFeatureIterator(final Geometry geometry,
23
                                final Object[] record) {
24

  
25
      m_Geometry = geometry;
26
      m_Record = record;
27
      m_bHasNext = true;
28

  
29
   }
30

  
31

  
32
   public void close() {}
33

  
34

  
35
   public int getFeatureCount() {
36

  
37
      return 1;
38

  
39
   }
40

  
41

  
42
   public boolean hasNext() {
43

  
44
      return m_bHasNext;
45
   }
46

  
47

  
48
   public IFeature next() {
49

  
50
      m_bHasNext = false;
51
      return new FeatureImpl(m_Geometry, m_Record);
52

  
53
   }
54

  
55

  
56
   public Rectangle2D getExtent() {
57

  
58
      final Envelope envelope = m_Geometry.getEnvelopeInternal();
59
      return new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight());
60

  
61
   }
62

  
63
}
0 64

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/PointSelectionPanel.java
1
package es.unex.sextante.gui.algorithm;
2

  
3
import info.clearthought.layout.TableLayout;
4
import info.clearthought.layout.TableLayoutConstants;
5

  
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
import java.awt.geom.Point2D;
9
import java.util.ArrayList;
10

  
11
import javax.swing.JButton;
12
import javax.swing.JLabel;
13
import javax.swing.JOptionPane;
14
import javax.swing.JPanel;
15
import javax.swing.JTextField;
16

  
17
import es.unex.sextante.core.Sextante;
18
import es.unex.sextante.gui.core.NamedPoint;
19
import es.unex.sextante.gui.core.SextanteGUI;
20

  
21
/**
22
 * A panel with two text fields, to introduce point coordinates. It also features a button to access pre-stored coordinates
23
 * 
24
 * @author volaya
25
 * 
26
 */
27
public class PointSelectionPanel
28
         extends
29
            JPanel {
30

  
31
   private JTextField textFieldX;
32
   private JButton    jButton;
33
   private JTextField textFieldY;
34
   private JLabel     labelX;
35
   private JLabel     labelY;
36

  
37

  
38
   PointSelectionPanel() {
39

  
40
      super();
41

  
42
      initGUI();
43

  
44
   }
45

  
46

  
47
   private void initGUI() {
48

  
49
      textFieldX = new JTextField("0");
50
      textFieldY = new JTextField("0");
51
      labelX = new JLabel(" X:");
52
      labelY = new JLabel(" Y:");
53
      jButton = new JButton();
54
      jButton.setText("...");
55

  
56
      final TableLayout thisLayout = new TableLayout(new double[][] {
57
               { 25.0, TableLayoutConstants.FILL, 25.0, TableLayoutConstants.FILL, 5.0, 25.0, 5.0 },
58
               { TableLayoutConstants.FILL } });
59
      this.setLayout(thisLayout);
60
      this.setPreferredSize(new java.awt.Dimension(128, 22));
61
      this.add(labelX, "0,  0");
62
      this.add(textFieldX, "1,  0");
63
      this.add(labelY, "2,  0");
64
      this.add(textFieldY, "3,  0");
65
      this.add(jButton, "5, 0");
66
      jButton.addActionListener(new ActionListener() {
67
         public void actionPerformed(final ActionEvent evt) {
68
            showPointSelector();
69
         }
70
      });
71

  
72
   }
73

  
74

  
75
   protected void showPointSelector() {
76

  
77
      final ArrayList<NamedPoint> coordsList = SextanteGUI.getGUIFactory().getCoordinatesList();
78

  
79
      if (coordsList.size() != 0) {
80
         final NamedPoint[] pts = coordsList.toArray(new NamedPoint[0]);
81
         final NamedPoint pt = (NamedPoint) JOptionPane.showInputDialog(this, Sextante.getText("Select_coordinates"),
82
                  Sextante.getText("Coordinates"), JOptionPane.PLAIN_MESSAGE, null, pts, null);
83
         if (pt != null) {
84
            textFieldX.setText(Double.toString(pt.getPoint().getX()));
85
            textFieldY.setText(Double.toString(pt.getPoint().getY()));
86
         }
87
      }
88

  
89
   }
90

  
91

  
92
   /**
93
    * Returns the selected point
94
    * 
95
    * @return the point introduced using this panel
96
    */
97
   public Point2D getPoint() {
98

  
99
      try {
100
         final Point2D pt = new Point2D.Double(Double.parseDouble(textFieldX.getText()), Double.parseDouble(textFieldY.getText()));
101
         return pt;
102
      }
103
      catch (final Exception e) {
104
         return null;
105
      }
106

  
107
   }
108

  
109

  
110
   /**
111
    * Sets the current point
112
    * 
113
    * @param point
114
    *                the new point to set
115
    */
116
   public void setPoint(final Point2D point) {
117

  
118
      textFieldX.setText(Double.toString(Math.floor(point.getX() * 10000.) / 10000.));
119
      textFieldY.setText(Double.toString(Math.floor(point.getY() * 10000.) / 10000.));
120

  
121
   }
122

  
123
}
0 124

  
org.gvsig.toolbox/tags/org.gvsig.toolbox-1.0.27/org.gvsig.toolbox.gui/src/main/java/es/unex/sextante/gui/algorithm/OutputChannelSelectionPanel.java
1
package es.unex.sextante.gui.algorithm;
2

  
3
import info.clearthought.layout.TableLayout;
4
import info.clearthought.layout.TableLayoutConstants;
5

  
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8

  
9
import javax.swing.JButton;
10
import javax.swing.JPanel;
11
import javax.swing.JTextField;
12

  
13
import jsh.shell.Utils;
14
import es.unex.sextante.core.ParametersSet;
15
import es.unex.sextante.core.Sextante;
16
import es.unex.sextante.dataObjects.IVectorLayer;
17
import es.unex.sextante.exceptions.WrongOutputChannelDataException;
18
import es.unex.sextante.outputs.DatabaseOutputChannel;
19
import es.unex.sextante.outputs.FileOutputChannel;
20
import es.unex.sextante.outputs.IOutputChannel;
21
import es.unex.sextante.outputs.NullOutputChannel;
22
import es.unex.sextante.outputs.Output;
23
import es.unex.sextante.outputs.OutputVectorLayer;
24
import es.unex.sextante.outputs.OverwriteOutputChannel;
25
import es.unex.sextante.parameters.Parameter;
26

  
27
/**
28
 * A panel with a text field and a button, which pops-up a dialog to select an output channel
29
 * 
30
 * @author volaya
31
 * 
32
 */
33
public class OutputChannelSelectionPanel
34
         extends
35
            JPanel {
36

  
37
   private JTextField          textField;
38
   private JButton             button;
39
   private final Output        m_Output;
40
   private final ParametersSet m_ParametersSet;
41

  
42

  
43
   /**
44
    * Creates a new output channel selection panel
45
    * 
46
    * @param out
47
    *                the output represented by this panel
48
    * 
49
    */
50
   public OutputChannelSelectionPanel(final Output out,
51
                                      final ParametersSet paramSet) {
52

  
53
      super();
54

  
55
      m_Output = out;
56
      m_ParametersSet = paramSet;
57

  
58
      initGUI();
59

  
60
   }
61

  
62

  
63
   private void initGUI() {
64

  
65
      button = new JButton("...");
66

  
67
      textField = new JTextField(Sextante.getText("[Save_to_temporary_file]"));
68
      textField.setMaximumSize(new java.awt.Dimension(340, 18));
69
      button.addActionListener(new ActionListener() {
70
         public void actionPerformed(final ActionEvent evt) {
71
            showDialog();
72
         }
73
      });
74

  
75
      final TableLayout thisLayout = new TableLayout(new double[][] { { TableLayoutConstants.FILL, 25.0 },
76
               { TableLayoutConstants.FILL } });
77
      this.setLayout(thisLayout);
78
      this.add(textField, "0,  0");
79
      this.add(button, "1,  0");
80

  
81
   }
82

  
83

  
84
   /**
85
    * Returns the current output channel
86
    * 
87
    * @return the current output channel
88
    * @throws WrongOutputChannelDataException
89
    *                 if the channel could not be created
90
    */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff