summaryrefslogtreecommitdiff
path: root/altosuilib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-24 23:40:47 -0700
committerKeith Packard <keithp@keithp.com>2016-05-24 23:40:47 -0700
commit59a9bdd73b580a9c934a574be7bf45c5033e14b5 (patch)
treeb89d50094b6ec17f00ce40e9587f96c79cb10dce /altosuilib
parent7b5521966119fcc290591bf1b397506ef44cedea (diff)
altosuilib: Have map preload respond to units and font size changes
Just add suitable listeners so that the display updates when preferences change. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib')
-rw-r--r--altosuilib/AltosUIMapPreloadNew.java60
1 files changed, 48 insertions, 12 deletions
diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java
index b16659da..d043e9e3 100644
--- a/altosuilib/AltosUIMapPreloadNew.java
+++ b/altosuilib/AltosUIMapPreloadNew.java
@@ -118,7 +118,7 @@ class AltosUIMapPos extends Box {
}
}
-public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosLaunchSiteListener, AltosMapLoaderListener {
+public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosLaunchSiteListener, AltosMapLoaderListener, AltosUnitsListener, AltosFontListener {
AltosUIFrame owner;
AltosUIMapNew map;
@@ -137,6 +137,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
JComboBox<Integer> min_zoom;
JComboBox<Integer> max_zoom;
+ JLabel radius_label;
JComboBox<Double> radius;
int scale = 1;
@@ -276,6 +277,35 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
});
}
+ private void set_radius_values() {
+ radius_label.setText(String.format("Map Radius (%s)",
+ AltosPreferences.imperial_units() ? "mi" : "km"));
+
+ Double[] radii;
+
+ if (AltosPreferences.imperial_units())
+ radii = radius_mi;
+ else
+ radii = radius_km;
+
+ radius.removeAllItems();
+ for (Double r : radii) {
+ System.out.printf("adding radius %f\n",r);
+ radius.addItem(r);
+ }
+ radius.setSelectedItem(radii[2]);
+ radius.setMaximumRowCount(radii.length);
+ }
+
+ public void units_changed(boolean imperial_units) {
+ map.units_changed(imperial_units);
+ set_radius_values();
+ }
+
+ public void font_size_changed(int font_size) {
+ map.font_size_changed(font_size);
+ }
+
public AltosUIMapPreloadNew(AltosUIFrame in_owner) {
owner = in_owner;
@@ -287,6 +317,18 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
pane.setLayout(new GridBagLayout());
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ AltosUIPreferences.unregister_font_listener(AltosUIMapPreloadNew.this);
+ AltosPreferences.unregister_units_listener(AltosUIMapPreloadNew.this);
+ }
+ });
+
+
+ AltosPreferences.register_units_listener(this);
+ AltosUIPreferences.register_font_listener(this);
+
map = new AltosUIMapNew();
c.fill = GridBagConstraints.BOTH;
@@ -462,26 +504,20 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
c.gridy = 3;
pane.add(max_zoom, c);
- JLabel radius_label = new JLabel(String.format("Map Radius (%s)",
- AltosPreferences.imperial_units() ? "miles" : "km"));
+ radius_label = new JLabel();
+
c.gridx = 4;
c.gridy = 4;
pane.add(radius_label, c);
- Double[] radii;
- Double radius_default;
-
- if (AltosPreferences.imperial_units())
- radii = radius_mi;
- else
- radii = radius_km;
- radius = new JComboBox<Double>(radii);
- radius.setSelectedItem(radii[2]);
+ radius = new JComboBox<Double>();
radius.setEditable(true);
c.gridx = 5;
c.gridy = 4;
pane.add(radius, c);
+ set_radius_values();
+
pack();
setLocationRelativeTo(owner);
setVisible(true);