layout.setConstraints(label, c);
add(label);
- value = new JTextField(20);
- value.setFont(label_font);
+ value = new JTextField(30);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
layout.setConstraints(label, c);
add(label);
- value = new JTextField(10);
- value.setFont(label_font);
+ value = new JTextField(15);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
layout.setConstraints(value, c);
add(value);
- max_value = new JTextField(10);
- max_value.setFont(label_font);
+ max_value = new JTextField(15);
+ max_value.setFont(value_font);
max_value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
layout = new GridBagLayout();
label_font = new Font("Dialog", Font.PLAIN, 24);
- value_font = new Font("Monospace", Font.PLAIN, 24);
+ value_font = new Font("Monospaced", Font.PLAIN, 24);
setLayout(layout);
/* Elements in ascent display:
layout.setConstraints(label, c);
add(label);
- value = new JTextField(20);
- value.setFont(label_font);
+ value = new JTextField(30);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
+ c.gridwidth = 2;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(value, c);
Lon lon;
- class Bearing extends DescentValue {
+ class Bearing {
+ JLabel label;
+ JTextField value;
+ JTextField value_deg;
+ void reset () {
+ value.setText("");
+ value_deg.setText("");
+ }
void show (AltosState state, int crc_errors) {
- if (state.from_pad != null)
- show("%3.0f°", state.from_pad.bearing);
- else
+ if (state.from_pad != null) {
+ 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) {
- super (layout, y, "Bearing");
+ 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);
}
}
layout = new GridBagLayout();
label_font = new Font("Dialog", Font.PLAIN, 24);
- value_font = new Font("Monospace", Font.PLAIN, 24);
+ value_font = new Font("Monospaced", Font.PLAIN, 24);
setLayout(layout);
/* Elements in descent display */
state.state < Altos.ao_flight_landed &&
state.range >= 0)
{
- voice.speak("Height %d, bearing %d, elevation %d, range %d.\n",
+ voice.speak("Height %d, bearing %s %d, elevation %d, range %d.\n",
(int) (state.height + 0.5),
+ state.from_pad.bearing_words(
+ AltosGreatCircle.BEARING_VOICE),
(int) (state.from_pad.bearing + 0.5),
(int) (state.elevation + 0.5),
(int) (state.range + 0.5));
}
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
+ AltosPreferences.init(this);
+
voice = in_voice;
reader = in_reader;
static final double rad = Math.PI / 180;
static final double earth_radius = 6371.2 * 1000; /* in meters */
+ static int BEARING_LONG = 0;
+ static int BEARING_SHORT = 1;
+ static int BEARING_VOICE = 2;
+ String bearing_words(int length) {
+ String [][] bearing_string = {
+ {
+ "North", "North North East", "North East", "East North East",
+ "East", "East South East", "South East", "South South East",
+ "South", "South South West", "South West", "West South West",
+ "West", "West North West", "North West", "North North West"
+ }, {
+ "N", "NNE", "NE", "ENE",
+ "E", "ESE", "SE", "SSE",
+ "S", "SSW", "SW", "WSW",
+ "W", "WNW", "NW", "NNW"
+ }, {
+ "north", "nor nor east", "north east", "east nor east",
+ "east", "east sow east", "south east", "sow sow east",
+ "south", "sow sow west", "south west", "west sow west",
+ "west", "west nor west", "north west", "nor nor west "
+ }
+ };
+ return bearing_string[length][(int)((bearing / 90 * 8 + 1) / 2)%16];
+ }
+
public AltosGreatCircle (double start_lat, double start_lon,
double end_lat, double end_lon)
{
private AltosFlightInfoTableModel model[];
private Box ibox[];
- private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 14);
- private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 14);
+ private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 12);
+ private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 12);
static final int info_columns = 3;
static final int info_rows = 17;
layout.setConstraints(label, c);
add(label);
- value = new JTextField(20);
- value.setFont(label_font);
+ value = new JTextField(30);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 1; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
layout = new GridBagLayout();
label_font = new Font("Dialog", Font.PLAIN, 24);
- value_font = new Font("Monospace", Font.PLAIN, 24);
+ value_font = new Font("Monospaced", Font.PLAIN, 24);
setLayout(layout);
/* Elements in descent display */
add(green);
green.set(false);
}
-}
\ No newline at end of file
+}
layout.setConstraints(label, c);
add(label);
- value = new JTextField(10);
- value.setFont(label_font);
+ value = new JTextField(15);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.WEST;
layout.setConstraints(label, c);
add(label);
- value = new JTextField(20);
- value.setFont(label_font);
+ value = new JTextField(30);
+ value.setFont(value_font);
value.setHorizontalAlignment(SwingConstants.RIGHT);
c.gridx = 2; c.gridy = y;
c.anchor = GridBagConstraints.EAST;
public static void main(final String[] args) {
int process = 0;
/* Handle batch-mode */
- if (args.length > 0) {
+ if (args.length == 2 && args[0].equals("--replay")) {
+ String filename = args[1];
+ FileInputStream in;
+ try {
+ in = new FileInputStream(filename);
+ } catch (Exception e) {
+ System.out.printf("Failed to open file '%s'\n", filename);
+ return;
+ }
+ AltosRecordIterable recs;
+ AltosReplayReader reader;
+ if (filename.endsWith("eeprom")) {
+ recs = new AltosEepromIterable(in);
+ } else {
+ recs = new AltosTelemetryIterable(in);
+ }
+ reader = new AltosReplayReader(recs.iterator(), filename);
+ new AltosFlightUI(new AltosVoice(), reader);
+ return;
+ } else if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("--kml"))
process |= process_kml;