Skip to content

Commit 841f0af

Browse files
committed
added toolbar, buttons do nothing for the moment
1 parent 383798e commit 841f0af

File tree

3 files changed

+397
-97
lines changed

3 files changed

+397
-97
lines changed

app/src/processing/app/GraphMonitor.java

+21-97
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class GraphMonitor extends JFrame implements MessageConsumer {
4949
private JTextArea graphArea;
5050
private JScrollPane scrollPane;
5151
private JScrollPane graphScrollPane;
52-
52+
private GraphToolbar toolbar;
5353
private JTextField textField;
5454
private JButton sendButton;
5555
private JCheckBox autoscrollBox;
@@ -80,98 +80,22 @@ public void actionPerformed(ActionEvent e) {
8080
getContentPane().setLayout(new BorderLayout());
8181

8282
Font font = Theme.getFont("console.font");
83-
84-
textArea = new JTextArea(16, 20);
83+
toolbar= new GraphToolbar(null,null);
84+
textArea = new JTextArea(16, 10);
8585
textArea.setEditable(false);
8686
textArea.setFont(font);
8787
// don't automatically update the caret. that way we can manually decide
8888
// whether or not to do so based on the autoscroll checkbox.
8989
((DefaultCaret)textArea.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
9090

9191
scrollPane = new JScrollPane(textArea);
92-
JPanel pane = new JPanel();
92+
JPanel pane = new JPanel();
9393
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
9494
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
9595
pane.add(this.graph());
96-
pane.add(scrollPane);
97-
getContentPane().add(pane, BorderLayout.CENTER);
98-
99-
100-
pane = new JPanel();
101-
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
102-
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
103-
104-
// textField = new JTextField(40);
105-
// textField.addActionListener(new ActionListener() {
106-
// public void actionPerformed(ActionEvent e) {
107-
// send(textField.getText());
108-
// textField.setText("");
109-
// }});
110-
111-
// sendButton = new JButton("Send");
112-
// sendButton.addActionListener(new ActionListener() {
113-
// public void actionPerformed(ActionEvent e) {
114-
// send(textField.getText());
115-
// textField.setText("");
116-
// }});
117-
118-
// pane.add(textField);
119-
// pane.add(Box.createRigidArea(new Dimension(4, 0)));
120-
// pane.add(sendButton);
121-
//
122-
// getContentPane().add(pane, BorderLayout.NORTH);
123-
124-
// pane = new JPanel();
125-
// pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
126-
// pane.setBorder(new EmptyBorder(4, 4, 4, 4));
127-
//
128-
// autoscrollBox = new JCheckBox("Autoscroll", true);
129-
//
130-
// lineEndings = new JComboBox(new String[] { "No line ending", "Newline", "Carriage return", "Both NL & CR" });
131-
// lineEndings.addActionListener(new ActionListener() {
132-
// public void actionPerformed(ActionEvent event) {
133-
// Preferences.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
134-
// }
135-
// });
136-
// if (Preferences.get("serial.line_ending") != null) {
137-
// lineEndings.setSelectedIndex(Preferences.getInteger("serial.line_ending"));
138-
// }
139-
// lineEndings.setMaximumSize(lineEndings.getMinimumSize());
140-
//
141-
// String[] serialRateStrings = {
142-
// "300","1200","2400","4800","9600","14400",
143-
// "19200","28800","38400","57600","115200"
144-
// };
145-
//
146-
// serialRates = new JComboBox();
147-
// for (int i = 0; i < serialRateStrings.length; i++)
148-
// serialRates.addItem(serialRateStrings[i] + " baud");
149-
//
150-
// serialRate = Preferences.getInteger("serial.debug_rate");
151-
// serialRates.setSelectedItem(serialRate + " baud");
152-
// serialRates.addActionListener(new ActionListener() {
153-
// public void actionPerformed(ActionEvent event) {
154-
// String wholeString = (String) serialRates.getSelectedItem();
155-
// String rateString = wholeString.substring(0, wholeString.indexOf(' '));
156-
// serialRate = Integer.parseInt(rateString);
157-
// Preferences.set("serial.debug_rate", rateString);
158-
// closeSerialPort();
159-
// try {
160-
// openSerialPort();
161-
// } catch (SerialException e) {
162-
// System.err.println(e);
163-
// }
164-
// }});
165-
//
166-
// serialRates.setMaximumSize(serialRates.getMinimumSize());
167-
//
168-
// pane.add(autoscrollBox);
169-
// pane.add(Box.createHorizontalGlue());
170-
// pane.add(lineEndings);
171-
// pane.add(Box.createRigidArea(new Dimension(8, 0)));
172-
// pane.add(serialRates);
173-
//
174-
// getContentPane().add(pane, BorderLayout.SOUTH);
96+
pane.add(scrollPane);
97+
getContentPane().add(toolbar,BorderLayout.NORTH);
98+
getContentPane().add(pane, BorderLayout.CENTER);
17599

176100
pack();
177101

@@ -238,27 +162,27 @@ public void closeSerialPort() {
238162
}
239163

240164
public void message(final String s) {
241-
SwingUtilities.invokeLater(new Runnable() {
165+
SwingUtilities.invokeLater(new Runnable() {//TODO implement 2 arrays for x and y values
242166
public void run() {
243167
textArea.append(s);
244168
if (autoscrollBox.isSelected()) {
245-
textArea.setCaretPosition(textArea.getDocument().getLength());
169+
textArea.setCaretPosition(textArea.getDocument().getLength());
246170
}
247171
}});
248172
}
249173
public ChartPanel graph(){
250-
TimeTableXYDataset data = new TimeTableXYDataset();
251-
Second second = new Second(new Date(System.currentTimeMillis() + 1000));
252-
data.add(second, 20.0,"a");
253-
Second second2 = new Second(new Date(System.currentTimeMillis() + 2000));
254-
data.add(second2, 30.8,"a");
255-
Second second3 = new Second(new Date(System.currentTimeMillis() + 3000));
256-
data.add(second3, 60.5,"a");
257-
JFreeChart chart = ChartFactory.createXYLineChart(null, null, null,
258-
data, PlotOrientation.VERTICAL,
259-
false, false, false);
260-
ChartPanel panel = new ChartPanel(chart);
261-
174+
TimeTableXYDataset data = new TimeTableXYDataset();
175+
Second second = new Second(new Date(System.currentTimeMillis() + 1000));
176+
data.add(second, 20.0,"a");
177+
Second second2 = new Second(new Date(System.currentTimeMillis() + 2000));
178+
data.add(second2, 30.8,"a");
179+
Second second3 = new Second(new Date(System.currentTimeMillis() + 3000));
180+
data.add(second3, 60.5,"a");
181+
JFreeChart chart = ChartFactory.createXYLineChart(null, null, null,
182+
data, PlotOrientation.VERTICAL,
183+
false, false, false);
184+
ChartPanel panel = new ChartPanel(chart);
185+
262186
return panel;
263187
}
264188
}

0 commit comments

Comments
 (0)