Commit dfb5fe0993a33be94f493ade715546a692bc997d

More of the same.
src/acsa/views/swing/AnyView.java
(36 / 2)
  
22
33import java.awt.GridBagLayout;
44import java.io.File;
5import java.io.FileReader;
6import java.io.FileWriter;
57import java.io.IOException;
8import java.io.Reader;
9import java.io.Writer;
610import java.util.Observable;
11import java.util.Properties;
712
813import javax.swing.Box;
914import javax.swing.JComponent;
5353 @Override
5454 public void readProperties(final File file)
5555 throws IOException {
56 throw new UnsupportedOperationException();
56 final Reader reader = new FileReader(file);
57 try {
58 final Properties properties = new Properties();
59 properties.load(reader);
60 final double resolution = Double.parseDouble(properties.getProperty("resolution"));
61 final double constantTerm = Double.parseDouble(properties.getProperty("constantTerm"));
62 final double linearTerm = Double.parseDouble(properties.getProperty("linearTerm"));
63
64 resolutionSpinner.setValue(Double.valueOf(resolution / Units.DPI));
65 constantTermSpinner.setValue(Double.valueOf(constantTerm / 1e-3));
66 linearTermSpinner.setValue(Double.valueOf(linearTerm / 1e-6));
67 } catch (final NullPointerException exception) {
68 throw new IOException(exception.getCause());
69 } catch (final NumberFormatException exception) {
70 throw new IOException(exception.getCause());
71 } finally {
72 reader.close();
73 }
5774 }
5875
5976 @Override
6077 public void writeProperties(final File file)
6178 throws IOException {
62 throw new UnsupportedOperationException();
79 final Writer writer = new FileWriter(file);
80 try {
81 final double resolution = ((Double )resolutionSpinner.getValue()).doubleValue() * Units.DPI;
82 final double constantTerm = ((Double )constantTermSpinner.getValue()).doubleValue() * 1e-3;
83 final double linearTerm = ((Double )linearTermSpinner.getValue()).doubleValue() * 1e-6;
84 final Properties properties = new Properties();
85 properties.setProperty("resolution", Double.toString(resolution));
86 properties.setProperty("constantTerm", Double.toString(constantTerm));
87 properties.setProperty("linearTerm", Double.toString(linearTerm));
88 properties.store(writer, null);
89 } finally {
90 writer.close();
91 }
6392 }
6493
6594 public AnyView(final Model model) {
src/acsa/views/swing/ClamView.java
(61 / 2)
  
22
33import java.awt.GridBagLayout;
44import java.io.File;
5import java.io.FileReader;
6import java.io.FileWriter;
57import java.io.IOException;
8import java.io.Reader;
9import java.io.Writer;
610import java.util.Observable;
11import java.util.Properties;
712
813import javax.swing.Box;
914import javax.swing.JComponent;
8989 confidence); // (6)
9090 }
9191
92 // TODO Move into the model.
9293 @Override
9394 public void readProperties(final File file)
9495 throws IOException {
95 throw new UnsupportedOperationException();
96 final Reader reader = new FileReader(file);
97 try {
98 final Properties properties = new Properties();
99 properties.load(reader);
100 final double resolution = Double.parseDouble(properties.getProperty("resolution"));
101 final double threshold = Double.parseDouble(properties.getProperty("threshold"));
102 final double defectSize = Double.parseDouble(properties.getProperty("defectSize"));
103 final double featureSize = Double.parseDouble(properties.getProperty("featureSize"));
104 final double meanSpan = Double.parseDouble(properties.getProperty("meanSpan"));
105 final double meanSpanSD = Double.parseDouble(properties.getProperty("meanSpanSD"));
106 final double sDOfSpan = Double.parseDouble(properties.getProperty("sDOfSpan"));
107 final double sDOfSpanSD = Double.parseDouble(properties.getProperty("sDOfSpanSD"));
108 final double confidence = Double.parseDouble(properties.getProperty("confidence"));
109
110 resolutionSpinner.setValue(Double.valueOf(resolution / Units.DPI));
111 thresholdSpinner.setValue(Double.valueOf(threshold));
112 defectSizeSpinner.setValue(Double.valueOf(defectSize / 1e-3));
113 featureSizeSpinner.setValue(Double.valueOf(featureSize / 1e-3));
114 meanSpanSpinner.setValue(Double.valueOf(meanSpan / 1e-3));
115 meanSpanSDSpinner.setValue(Double.valueOf(meanSpanSD / 1e-3));
116 sDOfSpanSpinner.setValue(Double.valueOf(sDOfSpan / 1e-3));
117 sDOfSpanSDSpinner.setValue(Double.valueOf(sDOfSpanSD / 1e-3));
118 confidenceSpinner.setValue(Double.valueOf(confidence));
119 } catch (final NullPointerException exception) {
120 throw new IOException(exception.getCause());
121 } catch (final NumberFormatException exception) {
122 throw new IOException(exception.getCause());
123 } finally {
124 reader.close();
125 }
96126 }
97127
98128 @Override
99129 public void writeProperties(final File file)
100130 throws IOException {
101 throw new UnsupportedOperationException();
131 final Writer writer = new FileWriter(file);
132 try {
133 final double resolution = ((Double )resolutionSpinner.getValue()).doubleValue() * Units.DPI;
134 final double threshold = ((Double )thresholdSpinner.getValue()).doubleValue();
135 final double defectSize = ((Double )defectSizeSpinner.getValue()).doubleValue() * 1e-3;
136 final double featureSize = ((Double )featureSizeSpinner.getValue()).doubleValue() * 1e-3;
137 final double meanSpan = ((Double )meanSpanSpinner.getValue()).doubleValue() * 1e-3;
138 final double meanSpanSD = ((Double )meanSpanSDSpinner.getValue()).doubleValue() * 1e-3;
139 final double sDOfSpan = ((Double )sDOfSpanSpinner.getValue()).doubleValue() * 1e-3;
140 final double sDOfSpanSD = ((Double )sDOfSpanSDSpinner.getValue()).doubleValue() * 1e-3;
141 final double confidence = ((Double )confidenceSpinner.getValue()).doubleValue();
142 final Properties properties = new Properties();
143 properties.setProperty("resolution", Double.toString(resolution));
144 properties.setProperty("threshold", Double.toString(threshold));
145 properties.setProperty("defectSize", Double.toString(defectSize));
146 properties.setProperty("featureSize", Double.toString(featureSize));
147 properties.setProperty("meanSpan", Double.toString(meanSpan));
148 properties.setProperty("meanSpanSD", Double.toString(meanSpanSD));
149 properties.setProperty("sDOfSpan", Double.toString(sDOfSpan));
150 properties.setProperty("sDOfSpanSD", Double.toString(sDOfSpanSD));
151 properties.setProperty("confidence", Double.toString(confidence));
152 properties.store(writer, null);
153 } finally {
154 writer.close();
155 }
102156 }
103157
104158 public ClamView(final Model model) {
src/acsa/views/swing/ShrimpView.java
(1 / 0)
  
100100 final double sDOfThickness = Double.parseDouble(properties.getProperty("sDOfThickness"));
101101 final double sDOfThicknessSD = Double.parseDouble(properties.getProperty("sDOfThicknessSD"));
102102 final double confidence = Double.parseDouble(properties.getProperty("confidence"));
103
103104 resolutionSpinner.setValue(Double.valueOf(resolution / Units.DPI));
104105 thresholdSpinner.setValue(Double.valueOf(threshold));
105106 defectSizeSpinner.setValue(Double.valueOf(defectSize / 1e-3));