1    import javax.swing.*;
2    import java.awt.event.*;
3    import java.awt.*;
4    import java.util.*;
5    import java.io.*;
6    
7    public class PrefCalibScreen extends PrefCalib implements java.io.Serializable,ActionListener,Scaleable {
8    
9      private static final long serialVersionUID = Version.getSUID();
10   
11     public static String DISPLAY = "Show calibration Patern";
12   
13     transient CompEditor edit = null;
14   
15     public PrefCalibScreen() {
16       scale = CompPane.screenscale;
17     }
18   
19     public String getText() {
20       return("To Calibrate the screen press 'display' and enter the length\n"+
21              "A in the boxe below. You may zoom in or out before\n"+
22              "making the measurement (you should get best results if the\n"+
23              "test pattern just fits on the screen), but you MUST NOT change\n"+
24              "the zoom after you make the measurement.\n\n"+
25              "Mesurement MUST be in cm regardless of unit settings");
26     }
27   
28     public String getTitle() {
29       return("Calibrate Screen");
30     }
31   
32     public void newPane() {
33       super.newPane();
34       JButton displaybutton = new JButton(DISPLAY);
35       displaybutton.addActionListener(this);
36       pane.add(displaybutton);
37     }
38   
39     public void actionPerformed(ActionEvent e) {
40       if (e.getActionCommand()==DISPLAY && owner!=null)
41         try {
42           edit = (CompEditor) owner.addEditor((Editable)(
43             ((new ObjectInputStream(getClass().getResource("calibrate.smb").openStream())).readObject())));
44         } catch (Exception ex) {
45           ErrorLog.exception(ex,"Trouble reading Calibrate.smb");
46         } 
47       edit.scale.addScaleable(this);
48       afield.setText(""+edit.scale.fact*100*scale);
49   //    bfield.setText(""+edit.scale.fact*100*scale[1]);
50     }
51   
52     public void setRotation(double fact) {}
53   
54     public void setScale(double fact) {
55       afield.setText(""+fact*100*scale);
56   //    bfield.setText(""+fact*100*scale[1]);
57     }
58   
59     public void save() {
60       super.save();
61       if (pane==null) return;
62       if (edit!=null) {
63         scale /= edit.scale.fact;
64   //      scale[1] /= edit.scale.fact;
65         edit.editframe.dispose();
66         edit = null;
67       }
68       apply();
69     }
70   
71     public void abandon() {
72       super.abandon();
73       if (edit!=null) {
74         edit.editframe.dispose();
75         edit = null;
76       }      
77     }
78   
79     public void apply() {
80       CompPane.screenscale = scale;
81     }
82   }
83