- JPanel main = new JPanel(new BorderLayout());
-
- main.setMinimumSize(new Dimension(500, 250));
- main.setPreferredSize(new Dimension(800, 400));
-
- // Three panels: mote list, graph, controls
- moteListModel = new MoteTableModel();
- JTable moteList = new JTable(moteListModel);
- moteList.setDefaultRenderer(Color.class, new MoteColor());
- moteList.setDefaultEditor(Color.class,
- new ColorCellEditor("Pick Mote Color"));
- moteList.setPreferredScrollableViewportSize(new Dimension(100, 400));
- JScrollPane motePanel = new JScrollPane();
- motePanel.getViewport().add(moteList, null);
- main.add(motePanel, BorderLayout.WEST);
-
- graph = new Graph(this);
- main.add(graph, BorderLayout.CENTER);
-
- // Controls. Organised using box layouts.
-
- // Sample period.
- JLabel sampleLabel = makeLabel("Sample period (ms):", JLabel.RIGHT);
- sampleText = makeTextField(6, new ActionListener() {
- public void actionPerformed(ActionEvent e) { setSamplePeriod(); }
- } );
- updateSamplePeriod();
-
- // Clear data.
- JButton clearButton = makeButton("Clear data", new ActionListener() {
- public void actionPerformed(ActionEvent e) { clearData(); }
- } );
-
- // Adjust X-axis zoom.
- Box xControl = new Box(BoxLayout.Y_AXIS);
- xLabel = makeLabel("", JLabel.CENTER);
- final JSlider xSlider = new JSlider(JSlider.HORIZONTAL, 0, 8, graph.scale);
- Hashtable xTable = new Hashtable();
- for (int i = 0; i <= 8; i += 2) {
- xTable.put(new Integer(i),
- makeSmallLabel("" + (Graph.MIN_WIDTH << i),
- JLabel.CENTER));
- }
- xSlider.setLabelTable(xTable);
- xSlider.setPaintLabels(true);
- graph.updateXLabel();
- graph.setScale(graph.scale);
- xSlider.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- //if (!xSlider.getValueIsAdjusting())
- graph.setScale((int)xSlider.getValue());
- }
- });
- xControl.add(xLabel);
- xControl.add(xSlider);
-
- // Adjust Y-axis range.
- JLabel yLabel = makeLabel("Y:", JLabel.RIGHT);
- yText = makeTextField(12, new ActionListener() {
- public void actionPerformed(ActionEvent e) { setYAxis(); }
- } );
- yText.setText(graph.gy0 + " - " + graph.gy1);
-
- Box controls = new Box(BoxLayout.X_AXIS);
- controls.add(clearButton);
- controls.add(Box.createHorizontalGlue());
- controls.add(Box.createRigidArea(new Dimension(20, 0)));
- controls.add(sampleLabel);
- controls.add(sampleText);
- controls.add(Box.createHorizontalGlue());
- controls.add(Box.createRigidArea(new Dimension(20, 0)));
- controls.add(xControl);
- controls.add(yLabel);
- controls.add(yText);
- main.add(controls, BorderLayout.SOUTH);
-
- // The frame part
- frame = new JFrame("Oscilloscope");
- frame.setSize(main.getPreferredSize());
- frame.getContentPane().add(main);
- frame.setVisible(true);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) { System.exit(0); }
- });
+ JPanel main = new JPanel(new BorderLayout());
+
+ main.setMinimumSize(new Dimension(500, 250));
+ main.setPreferredSize(new Dimension(800, 400));
+
+ // Three panels: mote list, graph, controls
+ moteListModel = new MoteTableModel();
+ JTable moteList = new JTable(moteListModel);
+ moteList.setDefaultRenderer(Color.class, new MoteColor());
+ moteList.setDefaultEditor(Color.class,
+ new ColorCellEditor("Pick Mote Color"));
+ moteList.setPreferredScrollableViewportSize(new Dimension(100, 400));
+ JScrollPane motePanel = new JScrollPane();
+ motePanel.getViewport().add(moteList, null);
+ main.add(motePanel, BorderLayout.WEST);
+
+ graph = new Graph(this);
+ main.add(graph, BorderLayout.CENTER);
+
+ // Controls. Organised using box layouts.
+
+ // Sample period.
+ JLabel sampleLabel = makeLabel("Sample period (ms):", JLabel.RIGHT);
+ sampleText = makeTextField(6, new ActionListener() {
+ public void actionPerformed(ActionEvent e) { setSamplePeriod(); }
+ } );
+ updateSamplePeriod();
+
+ // Clear data.
+ JButton clearButton = makeButton("Clear data", new ActionListener() {
+ public void actionPerformed(ActionEvent e) { clearData(); }
+ } );
+
+ // Adjust X-axis zoom.
+ Box xControl = new Box(BoxLayout.Y_AXIS);
+ xLabel = makeLabel("", JLabel.CENTER);
+ final JSlider xSlider = new JSlider(JSlider.HORIZONTAL, 0, 8, graph.scale);
+ Hashtable<Integer, JLabel> xTable = new Hashtable<Integer, JLabel>();
+ for (int i = 0; i <= 8; i += 2) {
+ xTable.put(new Integer(i),
+ makeSmallLabel("" + (Graph.MIN_WIDTH << i),
+ JLabel.CENTER));
+ }
+ xSlider.setLabelTable(xTable);
+ xSlider.setPaintLabels(true);
+ graph.updateXLabel();
+ graph.setScale(graph.scale);
+ xSlider.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ //if (!xSlider.getValueIsAdjusting())
+ graph.setScale((int)xSlider.getValue());
+ }
+ });
+ xControl.add(xLabel);
+ xControl.add(xSlider);
+
+ // Adjust Y-axis range.
+ JLabel yLabel = makeLabel("Y:", JLabel.RIGHT);
+ yText = makeTextField(12, new ActionListener() {
+ public void actionPerformed(ActionEvent e) { setYAxis(); }
+ } );
+ yText.setText(graph.gy0 + " - " + graph.gy1);
+
+ Box controls = new Box(BoxLayout.X_AXIS);
+ controls.add(clearButton);
+ controls.add(Box.createHorizontalGlue());
+ controls.add(Box.createRigidArea(new Dimension(20, 0)));
+ controls.add(sampleLabel);
+ controls.add(sampleText);
+ controls.add(Box.createHorizontalGlue());
+ controls.add(Box.createRigidArea(new Dimension(20, 0)));
+ controls.add(xControl);
+ controls.add(yLabel);
+ controls.add(yText);
+ main.add(controls, BorderLayout.SOUTH);
+
+ // The frame part
+ frame = new JFrame("Oscilloscope");
+ frame.setSize(main.getPreferredSize());
+ frame.getContentPane().add(main);
+ frame.setVisible(true);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) { System.exit(0); }
+ });