annotate SMART/Java/Program.java @ 20:c265f13066d8

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:24:43 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 /**
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 * Copyright INRA-URGI 2009-2010
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 * This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 * abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 * modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 * license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 * "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 * As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 * modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 * with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 * economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 * liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 * In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 * with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 * software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 * that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 * therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 * professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 * encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 * requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 * data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 * same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 * The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 * knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 */
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 import java.util.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 import java.awt.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 import javax.swing.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 public class Program {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 String shortName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 String name;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 String section;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 String description;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 Vector <ProgramOption> options;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 JPanel panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 JButton button;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 public Program() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 this.shortName = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 this.name = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 this.options = new Vector <ProgramOption> ();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 public void setShortName(String shortName) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 this.shortName = shortName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 public void setName(String name) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 this.name = name;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 public void setSection(String section) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 this.section = section;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 public void setDescription(String description) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 this.description = description;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 public void addOption(ProgramOption option) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 options.add(option);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 public String getShortName() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 return this.shortName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 public String getName() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 return this.name;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 public String getSection() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 return this.section;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 public String getDescription() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 return this.description;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 public String checkValues() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 for (int i = 0; i < options.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 String comment = options.get(i).checkValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 if (comment != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 return comment;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 public LinkedList<String> getCommand() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 LinkedList<String> parameterList = new LinkedList<String>();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 parameterList.add(Global.pythonCommand);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 parameterList.add("Python" + java.io.File.separator + this.shortName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 for (int i = 0; i < options.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 ProgramOption option = options.get(i);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 parameterList.addAll(option.getCommand());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 return parameterList;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 public JPanel getPanel() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 if (this.panel != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 return this.panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 this.panel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 this.panel.setLayout(new FlowLayout());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 Box box = Box.createVerticalBox();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 JPanel descriptionPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 JLabel descriptionLabel = new JLabel(this.description);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 descriptionPanel.add(descriptionLabel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 box.add(descriptionPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 for (int i = 0; i < options.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 ProgramOption option = options.get(i);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 JPanel panel = option.getPanel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 if (panel == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 System.out.println("Problem with Python program '" + this.shortName + "'.");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 box.add(option.getPanel());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 JPanel buttonPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 this.button = new JButton("GO!");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 buttonPanel.add(button);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 box.add(buttonPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 this.panel.add(box);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 return this.panel;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 public JButton getButton() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 if (this.button == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 this.getPanel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 return this.button;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 public Vector < File > getOutputFiles() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 Vector < File > files = new Vector < File > ();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 for (int i = 0; i < options.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 ProgramOption option = options.get(i);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 if (! option.isInput()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 files.add(option.getOutputFile());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 return files;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 }