Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.app / org.gvsig.geoprocess.app.mainplugin / src / main / java / org / gvsig / geoprocess / sextante / gui / algorithm / ParametersPanel.java @ 229

History | View | Annotate | Download (6.2 KB)

1
/*
2
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2010 Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 */
21
package org.gvsig.geoprocess.sextante.gui.algorithm;
22

    
23
import javax.swing.JPanel;
24

    
25
import es.unex.sextante.core.OutputObjectsSet;
26
import es.unex.sextante.exceptions.WrongOutputIDException;
27
import es.unex.sextante.gui.algorithm.DefaultParametersPanel;
28
import es.unex.sextante.gui.algorithm.OutputParameterContainer;
29
import es.unex.sextante.gui.algorithm.ParameterContainer;
30
import es.unex.sextante.outputs.Output;
31

    
32
import org.gvsig.geoprocess.core.CompositeSourceOutputChannel;
33
import org.gvsig.geoprocess.lib.sextante.dataObjects.OutputParameters;
34

    
35
/**
36
 * Default panel for gvSIG algorithms
37
 * 
38
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
39
 */
40
public class ParametersPanel extends DefaultParametersPanel {
41

    
42
    private static final long serialVersionUID = 1L;
43

    
44
    @SuppressWarnings("unchecked")
45
    protected void addOutputObjects(JPanel pane) {
46
        String sDescription;
47
        OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
48

    
49
        m_iCurrentRow = 0;
50

    
51
        for (int i = 0; i < ooset.getOutputObjectsCount(); i++) {
52
            Output out = ooset.getOutput(i);
53

    
54
            sDescription =
55
                out.getDescription() + "[" + out.getTypeDescription() + "]";
56
            addTitleLabel(pane, sDescription, m_iCurrentRow, false);
57

    
58
            AlgorithmOutputPanel algorithmOutputPanel =
59
                new AlgorithmOutputPanel();
60

    
61
            pane.add(algorithmOutputPanel,
62
                getStringTableCoords(2, m_iCurrentRow));
63
            m_iCurrentRow++;
64
            m_OutputParameterContainer.add(new OutputParameterContainer(out
65
                .getName(), algorithmOutputPanel));
66
        }
67
    }
68

    
69
    public void assignParameters() {
70

    
71
        boolean bAssigningOK = true;
72
        int i;
73
        ParameterContainer parameterContainer;
74
        String sType;
75

    
76
        for (i = 0; i < m_ParameterContainer.size(); i++) {
77
            parameterContainer =
78
                (ParameterContainer) m_ParameterContainer.get(i);
79
            sType = parameterContainer.getType();
80
            if (sType.equals("Table")) {
81
                bAssigningOK = assignInputTable(parameterContainer);
82
            } else
83
                if (sType.equals("Vector Layer")
84
                    || sType.equals("Raster Layer")) {
85
                    bAssigningOK = assignInputLayer(parameterContainer);
86
                } else
87
                    if (sType.equals("Numerical Value")) {
88
                        bAssigningOK =
89
                            assignInputNumericalValue(parameterContainer);
90
                    } else
91
                        if (sType.equals("String")) {
92
                            bAssigningOK =
93
                                assignInputString(parameterContainer);
94
                        } else
95
                            if (sType.equals("Boolean")) {
96
                                bAssigningOK =
97
                                    assignInputBoolean(parameterContainer);
98
                            } else
99
                                if (sType.equals("Fixed Table")) {
100
                                    bAssigningOK =
101
                                        assignInputFixedTable(parameterContainer);
102
                                } else
103
                                    if (sType.equals("Multiple Input")) {
104
                                        bAssigningOK =
105
                                            assignInputMultipleInput(parameterContainer);
106
                                    } else
107
                                        if (sType.equals("Point")) {
108
                                            bAssigningOK =
109
                                                assignInputPoint(parameterContainer);
110
                                        } else
111
                                            if (parameterContainer.getType()
112
                                                .equals("Filepath")) {
113
                                                bAssigningOK =
114
                                                    assignInputFilepath(parameterContainer);
115
                                            } else
116
                                                if (sType.equals("Table Field")
117
                                                    || sType
118
                                                        .equals("Selection")
119
                                                    || sType.equals("Band")) {
120
                                                    bAssigningOK =
121
                                                        assignInputSelection(parameterContainer);
122
                                                }
123

    
124
            if (!bAssigningOK) {
125
                return;
126
            }
127

    
128
        }
129

    
130
        OutputObjectsSet ooset = m_Algorithm.getOutputObjects();
131
        for (i = 0; i < m_OutputParameterContainer.size(); i++) {
132
            OutputParameterContainer opc =
133
                (OutputParameterContainer) m_OutputParameterContainer.get(i);
134
            Output out;
135
            try {
136
                out = ooset.getOutput(opc.getName());
137
                AlgorithmOutputPanel op =
138
                    (AlgorithmOutputPanel) opc.getContainer();
139
                Object obj = op.getOutputParameters();
140
                if (obj == null) {
141
                    return;
142
                }
143
                if (obj instanceof OutputParameters)
144
                    out.setOutputChannel(new CompositeSourceOutputChannel(obj));
145
            } catch (WrongOutputIDException e) {
146
            }
147
        }
148

    
149
        return;
150

    
151
    }
152
}