1
6
7 import javax.swing.*;
8 import java.awt.event.*;
9 import java.awt.*;
10 import java.util.*;
11
12 public class PrefMorph extends PrefEditor implements java.io.Serializable {
13
14 private static final long serialVersionUID = Version.getSUID();
15
16 public double beta = 100;
17 public double theta = 0.01;
18 public double sideoff = 1.0;
19 public double mindist = 0.000000001;
20 public double linethresh = 0.2;
21 public boolean redo = true;
22 public boolean savecooked = false;
23 public boolean usesoftcooked = false;
24 public String prefix = "morphed";
25
26 public boolean cookondemand = true;
27 public boolean cookpatched = true;
28 public int paintinterval = 5;
29 public int levels = 5;
30 public boolean thumbs = true;
31 public boolean lockall = true;
32 public boolean dobig = false;
33 public boolean usebigger = true;
34 public boolean usesmaller = true;
35 public boolean wait = false;
36
37 public PrefMorph() {
38 name = "Morph";
39 prefix = ImageFile.cookprefix;
40 }
41
42 public void newPane() throws NoSuchFieldException {
43 pane = new javax.swing.Box(BoxLayout.Y_AXIS);
44 setParm("cookondemand","Enable morph on demand");
45 setParm("paintinterval","Repaint interval");
46 setParm("levels","# of scales");
47 setParm("thumbs","Store thumbnails");
48 setParm("lockall","Keep morphed images in memory (do not deselect)");
49 setParm("dobig","Always do high resolution morph");
50 setParm("wait","Wait for morph (slow)");
51 setParm("usebigger","Substitute higher resolution when available");
52 setParm("usesmaller","Substitute lower resolution when available");
53
54 setParm("redo","Re-morph all segments on open");
55
56
57
58 setParm("linethresh","threshold for linear morph");
59 pane.add(new JLabel("Prefs below are black magic! Don't touch!"));
60 setParm("beta");
61 setParm("theta");
62 setParm("sideoff");
63 setParm("mindist");
64 }
65
66 public void save() {
67 if (pane==null) return;
68 super.save();
69 apply();
70 }
71
72 public void apply() {
73 Mapping.beta=beta;
74 Mapping.theta = theta;
75 Mapping.sideoff = sideoff;
76 Mapping.mindist = mindist;
77 Mapping.linethresh = linethresh;
78 Segment.cookondemand = cookondemand;
79 View.waitdefault = wait;
80 Segment.thumbs = usesmaller;
81 Segment.thumbs = usebigger;
82 Segment.lockall = lockall;
83 if (levels ==0) levels=1;
84 if (levels>5) levels=5;
85 Segment.levels = levels;
86 Segment.dobig = dobig;
87
88
89
90 CartoFrame.cookonopen = redo;
91 ImageThread.paintinterval = paintinterval;
92 }
93
94 private void readObject(java.io.ObjectInputStream st) throws java.io.IOException,ClassNotFoundException {
95 st.defaultReadObject();
96 usesoftcooked = false;
97 if (!cookpatched) {
98 cookondemand = true;
99 cookpatched=true;
100 paintinterval = 5;
101 dobig = false;
102 levels = 5;
103 lockall = true;
104 thumbs = true;
105 wait = false;
106 usebigger = true;
107 usesmaller = true;
108 }
109 }
110 }
111