}
public AscentValue (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
label = new JLabel(text);
label.setFont(label_font);
c.gridx = 0; c.gridy = y;
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(label, c);
add(label);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.HORIZONTAL;
+ c.fill = GridBagConstraints.BOTH;
c.gridwidth = 2;
+ c.weightx = 1;
layout.setConstraints(value, c);
add(value);
}
}
public AscentValueHold (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
label = new JLabel(text);
label.setFont(label_font);
c.gridx = 0; c.gridy = y;
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(label, c);
add(label);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
layout.setConstraints(value, c);
add(value);
max_value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
layout.setConstraints(max_value, c);
add(max_value);
}
public DescentValue (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
label = new JLabel(text);
label.setFont(label_font);
c.gridx = 0; c.gridy = y;
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(label, c);
add(label);
c.gridx = 1; c.gridy = y;
c.gridwidth = 2;
c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.HORIZONTAL;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
layout.setConstraints(value, c);
add(value);
}
JLabel label;
JTextField value;
JTextField value_deg;
- void reset () {
+ void reset () {
value.setText("");
value_deg.setText("");
- }
+ }
void show (AltosState state, int crc_errors) {
if (state.from_pad != null) {
- value.setText(state.from_pad.bearing_words(
- AltosGreatCircle.BEARING_LONG));
+ value.setText(state.from_pad.bearing_words(
+ AltosGreatCircle.BEARING_LONG));
value_deg.setText(String.format("%3.0f°", state.from_pad.bearing));
} else {
value.setText("???");
value_deg.setText("???");
- }
+ }
}
public Bearing (GridBagLayout layout, int y) {
- GridBagConstraints c = new GridBagConstraints();
-
- label = new JLabel("Bearing");
- label.setFont(label_font);
- label.setHorizontalAlignment(SwingConstants.LEFT);
- c.gridx = 0; c.gridy = y;
- c.insets = new Insets(10, 10, 10, 10);
- c.anchor = GridBagConstraints.WEST;
- layout.setConstraints(label, c);
- add(label);
-
- value = new JTextField(30);
- value.setFont(value_font);
- value.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = 1; c.gridy = y;
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.HORIZONTAL;
- layout.setConstraints(value, c);
- add(value);
-
- value_deg = new JTextField(5);
- value_deg.setFont(value_font);
- value_deg.setHorizontalAlignment(SwingConstants.RIGHT);
- c.gridx = 2; c.gridy = y;
- c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.HORIZONTAL;
-
- layout.setConstraints(value_deg, c);
- add(value_deg);
+ GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
+
+ label = new JLabel("Bearing");
+ label.setFont(label_font);
+ label.setHorizontalAlignment(SwingConstants.LEFT);
+ c.gridx = 0; c.gridy = y;
+ c.insets = new Insets(10, 10, 10, 10);
+ c.anchor = GridBagConstraints.WEST;
+ c.weightx = 0;
+ c.fill = GridBagConstraints.VERTICAL;
+ layout.setConstraints(label, c);
+ add(label);
+
+ value = new JTextField(30);
+ value.setFont(value_font);
+ value.setHorizontalAlignment(SwingConstants.RIGHT);
+ c.gridx = 1; c.gridy = y;
+ c.anchor = GridBagConstraints.EAST;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.BOTH;
+ layout.setConstraints(value, c);
+ add(value);
+
+ value_deg = new JTextField(5);
+ value_deg.setFont(value_font);
+ value_deg.setHorizontalAlignment(SwingConstants.RIGHT);
+ c.gridx = 2; c.gridy = y;
+ c.anchor = GridBagConstraints.EAST;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.BOTH;
+ layout.setConstraints(value_deg, c);
+ add(value_deg);
}
}
--- /dev/null
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package altosui;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import javax.swing.table.*;
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.util.prefs.*;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
+ GridBagLayout layout;
+
+ private Font status_font;
+
+ public class FlightValue {
+ JLabel label;
+ JTextField value;
+
+ void show(AltosState state, int crc_errors) {}
+
+ void reset() {
+ value.setText("");
+ }
+ public FlightValue (GridBagLayout layout, int x, String text) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.insets = new Insets(5, 5, 5, 5);
+ c.anchor = GridBagConstraints.CENTER;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
+ c.weighty = 1;
+
+ label = new JLabel(text);
+ label.setFont(status_font);
+ label.setHorizontalAlignment(SwingConstants.CENTER);
+ c.gridx = x; c.gridy = 0;
+ layout.setConstraints(label, c);
+ add(label);
+
+ value = new JTextField("");
+ value.setFont(status_font);
+ value.setHorizontalAlignment(SwingConstants.CENTER);
+ c.gridx = x; c.gridy = 1;
+ layout.setConstraints(value, c);
+ add(value);
+ }
+ }
+
+ class Call extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ value.setText(state.data.callsign);
+ }
+ public Call (GridBagLayout layout, int x) {
+ super (layout, x, "Callsign");
+ }
+ }
+
+ Call call;
+
+ class Serial extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ value.setText(String.format("%d", state.data.serial));
+ }
+ public Serial (GridBagLayout layout, int x) {
+ super (layout, x, "Serial");
+ }
+ }
+
+ Serial serial;
+
+ class Flight extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ value.setText(String.format("%d", state.data.flight));
+ }
+ public Flight (GridBagLayout layout, int x) {
+ super (layout, x, "Flight");
+ }
+ }
+
+ Flight flight;
+
+ class FlightState extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ value.setText(state.data.state());
+ }
+ public FlightState (GridBagLayout layout, int x) {
+ super (layout, x, "State");
+ }
+ }
+
+ FlightState flight_state;
+
+ class RSSI extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ value.setText(String.format("%d", state.data.rssi));
+ }
+ public RSSI (GridBagLayout layout, int x) {
+ super (layout, x, "RSSI (dBm)");
+ }
+ }
+
+ RSSI rssi;
+
+ public void reset () {
+ call.reset();
+ serial.reset();
+ flight.reset();
+ flight_state.reset();
+ rssi.reset();
+ }
+
+ public void show (AltosState state, int crc_errors) {
+ call.show(state, crc_errors);
+ serial.show(state, crc_errors);
+ flight.show(state, crc_errors);
+ flight_state.show(state, crc_errors);
+ rssi.show(state, crc_errors);
+ }
+
+ public int height() {
+ Dimension d = layout.preferredLayoutSize(this);
+ return d.height;
+ }
+
+ public AltosFlightStatus() {
+ layout = new GridBagLayout();
+
+ status_font = new Font("SansSerif", Font.BOLD, 24);
+ setLayout(layout);
+
+ call = new Call(layout, 0);
+ serial = new Serial(layout, 1);
+ flight = new Flight(layout, 2);
+ flight_state = new FlightState(layout, 3);
+ rssi = new RSSI(layout, 4);
+ }
+}
AltosDescent descent;
AltosLanded landed;
- private AltosStatusTable flightStatus;
+ private AltosFlightStatus flightStatus;
+ private JScrollPane flightInfoPane;
private AltosInfoTable flightInfo;
static final int tab_pad = 1;
}
cur_tab = tab;
}
- flightStatus.set(state);
+ flightStatus.show(state, crc_errors);
flightInfo.show(state, crc_errors);
}
setTitle(String.format("AltOS %s", reader.name));
- flightStatus = new AltosStatusTable();
+ flightStatus = new AltosFlightStatus();
vbox = new Box (BoxLayout.Y_AXIS);
vbox.add(flightStatus);
pane.add("Landed", landed);
flightInfo = new AltosInfoTable();
- pane.add("Table", flightInfo.box());
+ flightInfoPane = new JScrollPane(flightInfo.box());
+ pane.add("Table", flightInfoPane);
vbox.add(pane);
public LandedValue (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
label = new JLabel(text);
label.setFont(label_font);
c.gridx = 0; c.gridy = y;
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
+ c.weightx = 0;
+ c.fill = GridBagConstraints.VERTICAL;
layout.setConstraints(label, c);
add(label);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.BOTH;
layout.setConstraints(value, c);
add(value);
}
public LaunchStatus (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.weighty = 1;
lights = new AltosLights();
c.gridx = 0; c.gridy = y;
c.anchor = GridBagConstraints.CENTER;
- c.fill = GridBagConstraints.CENTER;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(lights, c);
add(lights);
c.gridx = 1; c.gridy = y;
c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
- c.fill = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(label, c);
add(label);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
layout.setConstraints(value, c);
add(value);
}
public LaunchValue (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
+ c.insets = new Insets(10, 10, 10, 10);
+ c.weighty = 1;
label = new JLabel(text);
label.setFont(label_font);
label.setHorizontalAlignment(SwingConstants.LEFT);
c.gridx = 1; c.gridy = y;
- c.insets = new Insets(10, 10, 10, 10);
c.anchor = GridBagConstraints.WEST;
+ c.fill = GridBagConstraints.VERTICAL;
+ c.weightx = 0;
layout.setConstraints(label, c);
add(label);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
- c.fill = GridBagConstraints.HORIZONTAL;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
layout.setConstraints(value, c);
add(value);
}
public AltosPad() {
layout = new GridBagLayout();
- GridBagConstraints c;
-
label_font = new Font("Dialog", Font.PLAIN, 24);
value_font = new Font("Monospaced", Font.PLAIN, 24);
setLayout(layout);
- c = new GridBagConstraints();
/* Elements in pad display:
*
* Battery voltage
+++ /dev/null
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package altosui;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-public class AltosStatusTable extends JTable {
- private AltosFlightStatusTableModel flightStatusModel;
-
- private Font statusFont = new Font("SansSerif", Font.BOLD, 24);
-
- public AltosStatusTable() {
- super((TableModel) new AltosFlightStatusTableModel());
- flightStatusModel = (AltosFlightStatusTableModel) getModel();
-
- setFont(statusFont);
-
- TableColumnModel tcm = getColumnModel();
-
- for (int i = 0; i < flightStatusModel.getColumnCount(); i++) {
- DefaultTableCellRenderer r = new DefaultTableCellRenderer();
- r.setFont(statusFont);
- r.setHorizontalAlignment(SwingConstants.CENTER);
- tcm.getColumn(i).setCellRenderer(r);
- }
-
- setRowHeight(rowHeight());
- setShowGrid(false);
- }
-
- public int rowHeight() {
- FontMetrics statusMetrics = getFontMetrics(statusFont);
- return (statusMetrics.getHeight() + statusMetrics.getLeading()) * 15 / 10;
- }
-
- public int height() {
- return rowHeight * 4;
- }
-
- public void set(AltosState state) {
- flightStatusModel.set(state);
- }
-}
AltosFlightDisplay.java \
AltosFlightInfoTableModel.java \
AltosFlightReader.java \
- AltosFlightStatusTableModel.java \
+ AltosFlightStatus.java \
AltosFlightUI.java \
AltosGPS.java \
AltosGreatCircle.java \
AltosSerialInUseException.java \
AltosSerialMonitor.java \
AltosState.java \
- AltosStatusTable.java \
AltosTelemetry.java \
AltosTelemetryIterable.java \
AltosUI.java \