comparison src/name/blackcap/imageprep/SettingsDialog.kt @ 21:0f3634a0816d

De-uglify SettingsDialog.
author David Barts <n5jrn@me.com>
date Sat, 21 Nov 2020 21:25:05 -0800
parents 71029c9bf7cd
children d3979a2155a8
comparison
equal deleted inserted replaced
20:71029c9bf7cd 21:0f3634a0816d
50 return _outputSuffix.text 50 return _outputSuffix.text
51 } 51 }
52 52
53 /* output to input dir? */ 53 /* output to input dir? */
54 private val otid = _PROPS.getBoolean("outputToInputDir") 54 private val otid = _PROPS.getBoolean("outputToInputDir")
55 private val outputToInputButton = JRadioButton("Create output file in same folder as input.", otid) 55 private val outputToInputButton = JRadioButton("Create output file in same folder as input.", otid).apply {
56 alignmentX = LEFT_ALIGNMENT
57 }
56 val outputToInputDir: Boolean 58 val outputToInputDir: Boolean
57 get() { 59 get() {
58 return outputToInputButton.isSelected() 60 return outputToInputButton.isSelected()
59 } 61 }
60 62
61 /* output to some other directory */ 63 /* output to some other directory */
62 private val outputToButton = JRadioButton("Create output file in:", !otid) 64 private val outputToButton = JRadioButton("Create output file in:", !otid).apply {
65 alignmentX = LEFT_ALIGNMENT
66 }
63 67
64 /* name of the other directory */ 68 /* name of the other directory */
65 private val oto = _getOutputTo() 69 private val oto = _getOutputTo()
66 protected val outputToText = JTextField(oto, 40).apply { 70 protected val outputToText = JTextField(oto, 40).apply {
67 setEditable(false) 71 setEditable(false)
122 init { 126 init {
123 title = "Preferences" 127 title = "Preferences"
124 contentPane.apply { 128 contentPane.apply {
125 layout = BoxLayout(this, BoxLayout.Y_AXIS) 129 layout = BoxLayout(this, BoxLayout.Y_AXIS)
126 add(Box(BoxLayout.X_AXIS).apply { 130 add(Box(BoxLayout.X_AXIS).apply {
131 alignmentX = LEFT_ALIGNMENT
127 border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2) 132 border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
128 add(leftLabel("Maximum dimension:")) 133 add(leftLabel("Maximum dimension: "))
129 add(_maxDimension) 134 add(_maxDimension)
130 add(Box.createGlue()) 135 add(Box.createGlue())
131 add(leftLabel("Output quality:")) 136 add(leftLabel("Output quality: "))
132 add(_outputQuality) 137 add(_outputQuality)
133 }) 138 })
134 add(Box(BoxLayout.X_AXIS).apply { 139 add(Box(BoxLayout.X_AXIS).apply {
140 alignmentX = LEFT_ALIGNMENT
135 border = BorderFactory.createEmptyBorder(BW, BW2, BW, BW2) 141 border = BorderFactory.createEmptyBorder(BW, BW2, BW, BW2)
136 add(leftLabel("Output filename suffix:")) 142 add(leftLabel("Output filename suffix: "))
137 add(_outputSuffix) 143 add(_outputSuffix)
138 add(Box.createGlue()) 144 add(Box.createGlue())
139 }) 145 })
140 add(Box(BoxLayout.Y_AXIS).apply { 146 add(Box(BoxLayout.Y_AXIS).apply {
141 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2) 147 alignmentX = LEFT_ALIGNMENT
148 border = BorderFactory.createEmptyBorder(BW, BW2, BW, BW2)
142 add(outputToInputButton) 149 add(outputToInputButton)
143 add(outputToButton) 150 add(outputToButton)
144 add(Box(BoxLayout.X_AXIS).apply { 151 add(Box(BoxLayout.X_AXIS).apply {
152 alignmentX = LEFT_ALIGNMENT
145 add(outputToText) 153 add(outputToText)
146 add(changeOutputTo) 154 add(changeOutputTo)
147 add(Box.createGlue()) 155 add(Box.createGlue())
148 }) 156 })
149 }) 157 })
150 add(Box(BoxLayout.X_AXIS).apply { 158 add(Box(BoxLayout.X_AXIS).apply {
159 alignmentX = LEFT_ALIGNMENT
160 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2)
161 add(Box.createGlue())
151 add(_cancel) 162 add(_cancel)
152 add(Box.createGlue()) 163 add(Box.createGlue())
153 add(_ok) 164 add(_ok)
165 add(Box.createGlue())
154 }) 166 })
155 } 167 }
156 rootPane.setDefaultButton(_ok) 168 rootPane.setDefaultButton(_ok)
157 pack() 169 pack()
158 setResizable(false) 170 setResizable(false)
197 "Error", 209 "Error",
198 JOptionPane.ERROR_MESSAGE) 210 JOptionPane.ERROR_MESSAGE)
199 } 211 }
200 } 212 }
201 213
202 private fun _getOutputTo(): String = _PROPS.getProperty("outputTo") ?: System.getProperty("user.dir") 214 private fun _getOutputTo(): String {
215 val p = _PROPS.getProperty("outputTo")
216 return if (p != null) tilde(p) else System.getProperty("user.dir")
217 }
203 } 218 }
204 219
205 fun Properties.getString(key: String): String = getProperty(key) as String 220 fun Properties.getString(key: String): String = getProperty(key) as String
206 221
207 fun Properties.getInt(key: String): Int = getString(key).toInt() 222 fun Properties.getInt(key: String): Int = getString(key).toInt()