1 import javax.swing.*;
2 import java.awt.event.*;
3 import java.awt.*;
4 import java.util.*;
5
6 public class PrefUnits extends PrefEditor implements java.io.Serializable {
7
8 private static final long serialVersionUID = Version.getSUID();
9
10 public Unit screenunit = Unit.inch;
11 public Unit surveyunit = Unit.foot;
12
13 Carto target;
14
15 public PrefUnits() {
16 name = "Default Units";
17 screenunit = Carto.defscreenunit;
18 surveyunit = Carto.defmapunit;
19 }
20
21 public PrefUnits(Carto target) {
22 this.target = target;
23 name = "Units";
24 screenunit = target.screenunit;
25 surveyunit = target.mapunit;
26 }
27
28 public void newPane() throws NoSuchFieldException {
29 pane = new javax.swing.Box(BoxLayout.Y_AXIS);
30 setUnit("screenunit",Unit.predefined,"Screen units");
31 setUnit("surveyunit",Unit.predefined,"Survey units");
32 }
33
34 public void save() {
35 if (pane==null) return;
36 super.save();
37 apply();
38 }
39
40 public void apply() {
41 if (target==null) {
42 Carto.defscreenunit = screenunit;
43 Carto.defmapunit = surveyunit;
44 } else {
45 target.screenunit = screenunit;
46 target.mapunit = surveyunit;
47 }
48 }
49 }
50
51
52