summaryrefslogtreecommitdiff
path: root/micropeak
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-01-22 17:29:37 -0800
committerKeith Packard <keithp@keithp.com>2013-01-22 17:40:25 -0800
commit9da66ca607664bb81b0986c121518faa4c1cb9fd (patch)
treea6e0f7e74a02480577dac8656c0514862ed0e953 /micropeak
parent3454592169dcb61b81de9af2b631b87e7dd86231 (diff)
micropeak: Respect font size preference in MicroPeak stats tab
This uses the font size preference to adjust the size of the text shown in the Statistics tab. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'micropeak')
-rw-r--r--micropeak/MicroPeak.java1
-rw-r--r--micropeak/MicroStatsTable.java31
2 files changed, 31 insertions, 1 deletions
diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java
index 6f5e432c..d370f563 100644
--- a/micropeak/MicroPeak.java
+++ b/micropeak/MicroPeak.java
@@ -231,6 +231,7 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
+ stats.tell_closing();
Close();
}
});
diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java
index cf30fcb7..be03b9f5 100644
--- a/micropeak/MicroStatsTable.java
+++ b/micropeak/MicroStatsTable.java
@@ -22,7 +22,7 @@ import javax.swing.*;
import org.altusmetrum.AltosLib.*;
import org.altusmetrum.altosuilib.*;
-public class MicroStatsTable extends JComponent {
+public class MicroStatsTable extends JComponent implements AltosFontListener {
GridBagLayout layout;
class MicroStat {
@@ -35,6 +35,12 @@ public class MicroStatsTable extends JComponent {
}
}
+ public void set_font() {
+ for (int j = 0; j < texts.length; j++)
+ texts[j].setFont(AltosUILib.value_font);
+ label.setFont(AltosUILib.label_font);
+ }
+
public MicroStat(GridBagLayout layout, int y, String label_text, String ... values) {
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad);
@@ -94,6 +100,22 @@ public class MicroStatsTable extends JComponent {
flight_time.set_values(String.format("%6.1f s", stats.landed_time));
}
+ public void set_font() {
+ max_height.set_font();
+ max_speed.set_font();
+ max_accel.set_font();
+ avg_accel.set_font();
+ boost_duration.set_font();
+ coast_duration.set_font();
+ descent_speed.set_font();
+ descent_duration.set_font();
+ flight_time.set_font();
+ }
+
+ public void font_size_changed(int font_size) {
+ set_font();
+ }
+
public void setData(MicroData data) {
setStats(new MicroStats(data));
}
@@ -129,6 +151,13 @@ public class MicroStatsTable extends JComponent {
String.format("%6.1f s", stats.descent_duration()));
flight_time = new MicroStat(layout, y++, "Flight Time",
String.format("%6.1f s", stats.landed_time));
+ set_font();
+
+ AltosUIPreferences.register_font_listener(this);
+ }
+
+ public void tell_closing() {
+ AltosUIPreferences.unregister_font_listener(this);
}
public MicroStatsTable() {