micropeak: Respect font size preference in MicroPeak stats tab
authorKeith Packard <keithp@keithp.com>
Wed, 23 Jan 2013 01:29:37 +0000 (17:29 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 23 Jan 2013 01:40:25 +0000 (17:40 -0800)
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>
micropeak/MicroPeak.java
micropeak/MicroStatsTable.java

index 6f5e432c6b97f5db19e2aa575752eb27d9e12bcd..d370f563ecf3528212f723f7474ccb9ea21710b3 100644 (file)
@@ -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();
                        }
                });
index cf30fcb75c26bdf9cb757ade044dff81ab4ca684..be03b9f578e412995c9bf512e00b393bef267234 100644 (file)
@@ -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() {