EMMA Coverage Report (generated Tue May 01 18:46:53 CEST 2007)
[all classes][dk.deepthought.sidious.gui]

COVERAGE SUMMARY FOR SOURCE FILE [Display.java]

nameclass, %method, %block, %line, %
Display.java0%   (0/4)0%   (0/12)0%   (0/317)0%   (0/73)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Display0%   (0/1)0%   (0/6)0%   (0/234)0%   (0/55)
Display (): void 0%   (0/1)0%   (0/41)0%   (0/9)
access$000 (Display): SidiousController 0%   (0/1)0%   (0/3)0%   (0/1)
finished (List): void 0%   (0/1)0%   (0/17)0%   (0/4)
initGui (): void 0%   (0/1)0%   (0/138)0%   (0/32)
setController (SidiousController): void 0%   (0/1)0%   (0/4)0%   (0/2)
setVertexAndStateValues (double, double, double, double, double, double): void 0%   (0/1)0%   (0/31)0%   (0/7)
     
class Display$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/3)
Display$1 (Display): void 0%   (0/1)0%   (0/6)0%   (0/1)
actionPerformed (ActionEvent): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class Display$20%   (0/1)0%   (0/2)0%   (0/11)0%   (0/3)
Display$2 (Display): void 0%   (0/1)0%   (0/6)0%   (0/1)
actionPerformed (ActionEvent): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class Display$SidiousLabel0%   (0/1)0%   (0/2)0%   (0/61)0%   (0/12)
Display$SidiousLabel (String): void 0%   (0/1)0%   (0/56)0%   (0/10)
setText (String): void 0%   (0/1)0%   (0/5)0%   (0/2)

1package dk.deepthought.sidious.gui;
2 
3import java.awt.BorderLayout;
4import java.awt.Dimension;
5import java.awt.event.ActionEvent;
6import java.awt.event.ActionListener;
7import java.util.List;
8 
9import javax.swing.Box;
10import javax.swing.BoxLayout;
11import javax.swing.JButton;
12import javax.swing.JFrame;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15import javax.swing.JTextArea;
16import javax.swing.JTextField;
17import javax.swing.UIManager;
18 
19import dk.deepthought.sidious.supportsystem.Step;
20 
21/**
22 * Class represents the gui of the project.
23 * 
24 * @author Deepthought
25 * 
26 */
27@SuppressWarnings("serial")//Only needed before Java 1.4!
28public class Display extends JFrame {
29 
30        /**
31         * The main panel.
32         */
33        private JPanel mainPanel;
34 
35        /**
36         * The cost label.
37         */
38        private SidiousLabel cost = new SidiousLabel("Cost: ");
39 
40        /**
41         * The temperature label.
42         */
43        private SidiousLabel temperature = new SidiousLabel("Temperature: ");
44 
45        /**
46         * The humidity label.
47         */
48        private SidiousLabel humidity = new SidiousLabel("Humidity: ");
49 
50        /**
51         * The CO2 label.
52         */
53        private SidiousLabel co2 = new SidiousLabel("CO2: ");
54 
55        /**
56         * The irradiance label.
57         */
58        private SidiousLabel irradiance = new SidiousLabel("Irradiance: ");
59 
60        /**
61         * The time label.
62         */
63        private SidiousLabel time = new SidiousLabel("Time: ");
64 
65        /**
66         * The area to put the final plan.
67         */
68        private JTextArea finishField;
69 
70        /**
71         * The controller of this.
72         */
73        private transient SidiousController controller;
74 
75        /**
76         * Constructor.
77         */
78        public Display() {
79                initGui();
80        }
81 
82        /**
83         * Init GUI.
84         */
85        private void initGui() {
86                // set look&feel
87                try {
88                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
89                } catch (Exception e) {
90                        e.printStackTrace();
91                }
92                // builds the main Panel
93                mainPanel = new JPanel();
94                mainPanel.setLayout(new BorderLayout());
95 
96                JPanel panel = new JPanel();
97                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
98                panel.add(cost);
99                panel.add(temperature);
100                panel.add(humidity);
101                panel.add(co2);
102                panel.add(irradiance);
103                panel.add(time);
104                mainPanel.add(panel, BorderLayout.CENTER);
105 
106                // Add finish field
107                finishField = new JTextArea();
108                panel.add(finishField);
109 
110                // Add buttons
111                JPanel buttonPanel = new JPanel();
112                // Add start button
113                JButton startButton = new JButton("Start");
114                startButton.addActionListener(new ActionListener() {
115                        public void actionPerformed(final ActionEvent e) {
116                                controller.start();
117                        }
118                });
119                buttonPanel.add(startButton);
120                // Add stop button
121                JButton stopButton = new JButton("Stop");
122                stopButton.addActionListener(new ActionListener() {
123                        public void actionPerformed(final ActionEvent e) {
124                                controller.stop();
125                        }
126                });
127                buttonPanel.add(stopButton);
128                // Add buttons to main panel
129                mainPanel.add(buttonPanel, BorderLayout.SOUTH);
130 
131                // Add main panel
132                getContentPane().add(mainPanel);
133                // Finish up
134                setPreferredSize(new Dimension(640, 480));
135                setDefaultCloseOperation(EXIT_ON_CLOSE);
136                setLocation(0, 0);
137                pack();
138                setVisible(true);
139        }
140 
141        /**
142         * Sets the controller for this
143         * 
144         * @param controller
145         *            the controller for this
146         */
147        public void setController(SidiousController controller) {
148                this.controller = controller;
149        }
150 
151        /**
152         * Sets the final plan.
153         * 
154         * @param steps
155         *            the steps comprising the plan
156         */
157        public void finished(List<Step> steps) {
158                for (Step step : steps) {
159                        finishField.append(step.toString());
160                }
161        }
162 
163        /**
164         * Sets the vertex and state values.
165         * 
166         * @param cost
167         *            the cost
168         * @param temperature
169         *            the temperature
170         * @param humidity
171         *            the humidity
172         * @param co2
173         *            the CO2 level
174         * @param irradiance
175         *            the irradiance
176         * @param time
177         *            the time
178         */
179        public void setVertexAndStateValues(double cost, double temperature,
180                        double humidity, double co2, double irradiance, double time) {
181                this.cost.setText(String.valueOf(cost));
182                this.temperature.setText(String.valueOf(temperature));
183                this.humidity.setText(String.valueOf(humidity));
184                this.co2.setText(String.valueOf(co2));
185                this.irradiance.setText(String.valueOf(irradiance));
186                this.time.setText(String.valueOf(time));
187        }
188 
189        /**
190         * Private class to hold a label.
191         * 
192         * @author Deepthought
193         * 
194         */
195        private static class SidiousLabel extends JPanel {
196 
197                private JLabel label;
198 
199                private JTextField textField;
200 
201                public SidiousLabel(String labelText) {
202                        textField = new JTextField();
203                        textField.setPreferredSize(new Dimension(80, 12));
204                        label = new JLabel(labelText);
205                        label.setPreferredSize(new Dimension(80, 10));
206                        setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
207                        add(label);
208                        add(Box.createRigidArea(new Dimension(10, 0)));
209                        add(textField);
210                }
211 
212                public void setText(String s) {
213                        textField.setText(s);
214                }
215 
216        }
217 
218}

[all classes][dk.deepthought.sidious.gui]
EMMA 2.0.5312 (C) Vladimir Roubtsov