キャラクターなんとかJの本体
Revision | a51998d51dd649545b21030ad9964f55932c598c (tree) |
---|---|
Time | 2018-12-31 00:57:56 |
Author | seraphy <seraphy@user...> |
Commiter | seraphy |
Java8環境における、高解像度スクリーンのスケール対応
@@ -30,6 +30,7 @@ import charactermanaj.ui.MainFramePartialForMacOSX; | ||
30 | 30 | import charactermanaj.ui.MainFramePartialForMacOSX9; |
31 | 31 | import charactermanaj.ui.ProfileListManager; |
32 | 32 | import charactermanaj.ui.SelectCharatersDirDialog; |
33 | +import charactermanaj.ui.util.ScaleSupport; | |
33 | 34 | import charactermanaj.util.AWTExceptionLoggingHandler; |
34 | 35 | import charactermanaj.util.ApplicationLoggerConfigurator; |
35 | 36 | import charactermanaj.util.ConfigurationDirUtilities; |
@@ -237,6 +238,12 @@ public final class Main implements Runnable { | ||
237 | 238 | // デフォルトのフォントサイズ、0以下の場合はシステム標準のまま |
238 | 239 | int defFontSize = appConfig.getDefaultFontSize(); |
239 | 240 | |
241 | + // フォントサイズを画面のスケールの補正にあわせる | |
242 | + if (defFontSize > 0) { | |
243 | + ScaleSupport scaleSupport = ScaleSupport.getDefault(); | |
244 | + defFontSize = (int)(defFontSize * scaleSupport.getManualScaleY()); | |
245 | + } | |
246 | + | |
240 | 247 | // UIデフォルトのフォント設定で、優先フォント以外のフォントファミリが指定されているものを |
241 | 248 | // すべて最優先フォントファミリに設定する. |
242 | 249 | // また、設定されたフォントサイズが0よりも大きければ、そのサイズに設定する. |
@@ -36,6 +36,7 @@ import javax.swing.text.Document; | ||
36 | 36 | import javax.swing.text.EditorKit; |
37 | 37 | |
38 | 38 | import charactermanaj.model.AppConfig; |
39 | +import charactermanaj.ui.util.ScaleSupport; | |
39 | 40 | import charactermanaj.util.DesktopUtilities; |
40 | 41 | import charactermanaj.util.DirectoryConfig; |
41 | 42 | import charactermanaj.util.ErrorMessageHelper; |
@@ -45,7 +46,7 @@ import charactermanaj.util.SystemUtil; | ||
45 | 46 | |
46 | 47 | /** |
47 | 48 | * Aboutボックスを表示する. |
48 | - * | |
49 | + * | |
49 | 50 | * @author seraphy |
50 | 51 | */ |
51 | 52 | public class AboutBox { |
@@ -56,7 +57,7 @@ public class AboutBox { | ||
56 | 57 | private static Logger logger = Logger.getLogger(AboutBox.class.getName()); |
57 | 58 | |
58 | 59 | private JFrame parent; |
59 | - | |
60 | + | |
60 | 61 | public AboutBox(JFrame parent) { |
61 | 62 | if (parent == null) { |
62 | 63 | throw new IllegalArgumentException(); |
@@ -70,7 +71,16 @@ public class AboutBox { | ||
70 | 71 | public void showAboutBox() { |
71 | 72 | |
72 | 73 | final JTabbedPane tabs = new JTabbedPane(); |
73 | - tabs.setPreferredSize(new Dimension(500, 400)); | |
74 | + | |
75 | + // 解像度スケールで補正する | |
76 | + Dimension dim = new Dimension(500, 400); | |
77 | + if (this.parent != null) { | |
78 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this.parent); | |
79 | + if (scaleSupport != null) { | |
80 | + dim = scaleSupport.manualScaled(dim); | |
81 | + } | |
82 | + } | |
83 | + tabs.setPreferredSize(dim); | |
74 | 84 | |
75 | 85 | final JPanel aboutPanel = createAboutPanel(); |
76 | 86 | final JSysInfoPanel sysInfoPanel = new JSysInfoPanel() { |
@@ -81,7 +91,7 @@ public class AboutBox { | ||
81 | 91 | setText(getSysInfoText()); |
82 | 92 | } |
83 | 93 | }; |
84 | - | |
94 | + | |
85 | 95 | tabs.addTab("About", aboutPanel); |
86 | 96 | tabs.addTab("System", sysInfoPanel); |
87 | 97 |
@@ -92,10 +102,10 @@ public class AboutBox { | ||
92 | 102 | } |
93 | 103 | } |
94 | 104 | }); |
95 | - | |
105 | + | |
96 | 106 | JOptionPane.showMessageDialog(parent, tabs, "About", JOptionPane.INFORMATION_MESSAGE); |
97 | 107 | } |
98 | - | |
108 | + | |
99 | 109 | protected JPanel createAboutPanel() { |
100 | 110 | LocalizedTextResource textResource = new LocalizedTextResource() { |
101 | 111 | @Override |
@@ -111,10 +121,10 @@ public class AboutBox { | ||
111 | 121 | |
112 | 122 | String versionInfo = appConfig.getImplementationVersion(); |
113 | 123 | String specificationVersionInfo = appConfig.getSpecificationVersion(); |
114 | - | |
124 | + | |
115 | 125 | message = message.replace("@@IMPLEMENTS-VERSIONINFO@@", versionInfo); |
116 | 126 | message = message.replace("@@SPECIFICATION-VERSIONINFO@@", specificationVersionInfo); |
117 | - | |
127 | + | |
118 | 128 | JPanel aboutPanel = new JPanel(new BorderLayout()); |
119 | 129 | JEditorPane editorPane = new JEditorPane(); |
120 | 130 | editorPane.addHyperlinkListener(new HyperlinkListener() { |
@@ -161,29 +171,29 @@ public class AboutBox { | ||
161 | 171 | editorPane.setSelectionStart(0); |
162 | 172 | editorPane.setSelectionEnd(0); |
163 | 173 | aboutPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER); |
164 | - | |
174 | + | |
165 | 175 | return aboutPanel; |
166 | 176 | } |
167 | - | |
177 | + | |
168 | 178 | /** |
169 | 179 | * システム情報を取得してHTML形式の文字列として返す.<br> |
170 | 180 | * ランタイム情報、システムプロパティ情報、環境変数情報を取得する.<br> |
171 | - * | |
181 | + * | |
172 | 182 | * @return システム情報のHTML文字列 |
173 | 183 | */ |
174 | 184 | protected String getSysInfoText() { |
175 | 185 | |
176 | 186 | // ランタイム情報の取得 |
177 | - | |
187 | + | |
178 | 188 | long freeMem, totalMem, maxMem; |
179 | 189 | Runtime rt = Runtime.getRuntime(); |
180 | 190 | |
181 | 191 | totalMem = rt.totalMemory() / 1024; |
182 | 192 | freeMem = rt.freeMemory() / 1024; |
183 | 193 | maxMem = rt.maxMemory() / 1024; |
184 | - | |
194 | + | |
185 | 195 | DecimalFormat decimalFmt = new DecimalFormat("#,###,##0"); |
186 | - | |
196 | + | |
187 | 197 | StringBuilder buf = new StringBuilder(); |
188 | 198 | buf.append("<html>"); |
189 | 199 | buf.append("<h2>Runtime Information</h2>"); |
@@ -192,9 +202,9 @@ public class AboutBox { | ||
192 | 202 | buf.append("<tr><td>Total Memory:</td><td>" + decimalFmt.format(totalMem) + " KiB</td></tr>"); |
193 | 203 | buf.append("<tr><td>Free Memory:</td><td>" + decimalFmt.format(freeMem) + " KiB</td></tr>"); |
194 | 204 | buf.append("</table>"); |
195 | - | |
205 | + | |
196 | 206 | // キャラクターデータベースの取得 |
197 | - | |
207 | + | |
198 | 208 | DirectoryConfig dirConfig = DirectoryConfig.getInstance(); |
199 | 209 | String charactersDir = null; |
200 | 210 | try { |
@@ -202,13 +212,13 @@ public class AboutBox { | ||
202 | 212 | } catch (RuntimeException ex) { |
203 | 213 | charactersDir = "**INVALID**"; |
204 | 214 | } |
205 | - | |
215 | + | |
206 | 216 | buf.append("<h2>Character Database</h2>"); |
207 | 217 | buf.append("<table border=\"1\">"); |
208 | 218 | buf.append("<tr><td>Location</td>"); |
209 | 219 | buf.append("<td>" + escape(charactersDir) + "</td></tr>"); |
210 | 220 | buf.append("</table>"); |
211 | - | |
221 | + | |
212 | 222 | // サポートしているエンコーディングの列挙 |
213 | 223 | buf.append("<h2>Available Charsets</h2>"); |
214 | 224 | Charset defaultCharset = Charset.defaultCharset(); |
@@ -257,9 +267,9 @@ public class AboutBox { | ||
257 | 267 | buf.append("<p><span style=\"color: red;\">This system is not supporting Japanese.</span></p>"); |
258 | 268 | } |
259 | 269 | buf.append(bufChars.toString()); |
260 | - | |
270 | + | |
261 | 271 | // システムプロパティの取得 |
262 | - | |
272 | + | |
263 | 273 | buf.append("<h2>System Properties</h2><table border=\"1\">"); |
264 | 274 | try { |
265 | 275 | Properties sysprops = System.getProperties(); |
@@ -279,9 +289,9 @@ public class AboutBox { | ||
279 | 289 | } catch (Exception ex) { |
280 | 290 | buf.append(escape(ex.toString())); |
281 | 291 | } |
282 | - | |
292 | + | |
283 | 293 | // 環境変数の取得 |
284 | - | |
294 | + | |
285 | 295 | buf.append("<h2>System Environments</h2>"); |
286 | 296 | try { |
287 | 297 | TreeMap<String, String> envMap = new TreeMap<String, String>(); // 環境変数名のアルファベット順にソート |
@@ -302,7 +312,7 @@ public class AboutBox { | ||
302 | 312 | buf.append("</html>"); |
303 | 313 | return buf.toString(); |
304 | 314 | } |
305 | - | |
315 | + | |
306 | 316 | protected String escape(String value) { |
307 | 317 | if (value == null) { |
308 | 318 | return null; |
@@ -319,16 +329,16 @@ class JSysInfoPanel extends JPanel { | ||
319 | 329 | private static final long serialVersionUID = 1L; |
320 | 330 | |
321 | 331 | private JEditorPane editorPane; |
322 | - | |
332 | + | |
323 | 333 | public JSysInfoPanel() { |
324 | 334 | super(new BorderLayout()); |
325 | - | |
335 | + | |
326 | 336 | editorPane = new JEditorPane(); |
327 | 337 | editorPane.setEditable(false); |
328 | 338 | editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); |
329 | 339 | editorPane.setContentType("text/html"); |
330 | 340 | editorPane.setText(""); |
331 | - | |
341 | + | |
332 | 342 | JButton btnSave = new JButton(new AbstractAction("save") { |
333 | 343 | private static final long serialVersionUID = 1L; |
334 | 344 | public void actionPerformed(ActionEvent e) { |
@@ -347,21 +357,21 @@ class JSysInfoPanel extends JPanel { | ||
347 | 357 | btnPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
348 | 358 | btnPanel.add(btnSave, BorderLayout.EAST); |
349 | 359 | btnPanel.add(btnGc, BorderLayout.WEST); |
350 | - | |
360 | + | |
351 | 361 | add(new JScrollPane(editorPane), BorderLayout.CENTER); |
352 | 362 | add(btnPanel, BorderLayout.SOUTH); |
353 | 363 | } |
354 | - | |
364 | + | |
355 | 365 | public void setText(String message) { |
356 | 366 | editorPane.setText(message); |
357 | 367 | editorPane.setSelectionStart(0); |
358 | 368 | editorPane.setSelectionEnd(0); |
359 | 369 | } |
360 | - | |
370 | + | |
361 | 371 | protected void onGc() { |
362 | 372 | SystemUtil.gc(); |
363 | 373 | } |
364 | - | |
374 | + | |
365 | 375 | protected void onSave() { |
366 | 376 | JFileChooser chooser = new JFileChooser(); |
367 | 377 | chooser.setSelectedFile(new File("sysinfo.html")); |
@@ -384,10 +394,10 @@ class JSysInfoPanel extends JPanel { | ||
384 | 394 | } finally { |
385 | 395 | os.close(); |
386 | 396 | } |
387 | - | |
397 | + | |
388 | 398 | } catch (Exception ex) { |
389 | 399 | ErrorMessageHelper.showErrorDialog(this, ex); |
390 | 400 | } |
391 | 401 | } |
392 | - | |
402 | + | |
393 | 403 | } |
@@ -62,6 +62,7 @@ import javax.swing.table.TableColumnModel; | ||
62 | 62 | |
63 | 63 | import charactermanaj.Main; |
64 | 64 | import charactermanaj.model.AppConfig; |
65 | +import charactermanaj.ui.util.ScaleSupport; | |
65 | 66 | import charactermanaj.util.BeanPropertiesUtilities; |
66 | 67 | import charactermanaj.util.BeanPropertiesUtilities.PropertyAccessor; |
67 | 68 | import charactermanaj.util.BeanPropertiesUtilities.PropertyAccessorMap; |
@@ -317,14 +318,14 @@ public class AppConfigDialog extends JDialog { | ||
317 | 318 | fireTableRowsUpdated(rowIndex, rowIndex); |
318 | 319 | } |
319 | 320 | |
320 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
321 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
321 | 322 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
322 | 323 | .getLocalizedProperties("languages/appconfigdialog"); |
323 | 324 | int mx = columnModel.getColumnCount(); |
324 | 325 | for (int idx = 0; idx < mx; idx++) { |
325 | 326 | String reskey = COLUMNS[idx].getResourceKey() + ".width"; |
326 | 327 | int width = Integer.parseInt(strings.getProperty(reskey)); |
327 | - columnModel.getColumn(idx).setPreferredWidth(width); | |
328 | + columnModel.getColumn(idx).setPreferredWidth((int)(width * scale)); | |
328 | 329 | } |
329 | 330 | } |
330 | 331 | } |
@@ -454,7 +455,13 @@ public class AppConfigDialog extends JDialog { | ||
454 | 455 | |
455 | 456 | add(btnPanel, BorderLayout.SOUTH); |
456 | 457 | |
457 | - setSize(600, 400); | |
458 | + Dimension dim = new Dimension(600, 400); | |
459 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
460 | + if (scaleSupport != null) { | |
461 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
462 | + dim = scaleSupport.manualScaled(dim); | |
463 | + } | |
464 | + setSize(dim); | |
458 | 465 | setLocationRelativeTo(getParent()); |
459 | 466 | |
460 | 467 | // Notes |
@@ -574,11 +581,14 @@ public class AppConfigDialog extends JDialog { | ||
574 | 581 | appConfigTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
575 | 582 | appConfigTable.setCellSelectionEnabled(true); |
576 | 583 | |
584 | + // 行の高さをフォントの高さにする | |
585 | + appConfigTable.setRowHeight((int)(appConfigTable.getFont().getSize() * 1.2)); | |
586 | + | |
577 | 587 | // データタイプがColorの場合のセルレンダラーとエディタを設定する |
578 | 588 | appConfigTable.setDefaultRenderer(Color.class, new ColorCellRender()); |
579 | 589 | appConfigTable.setDefaultEditor(Color.class, new ColorCellEditor()); |
580 | 590 | |
581 | - appConfigTableModel.adjustColumnModel(appConfigTable.getColumnModel()); | |
591 | + appConfigTableModel.adjustColumnModel(appConfigTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
582 | 592 | |
583 | 593 | appConfigTableModel.addTableModelListener(new TableModelListener() { |
584 | 594 | @Override |
@@ -88,6 +88,7 @@ import charactermanaj.ui.progress.ProgressHandle; | ||
88 | 88 | import charactermanaj.ui.progress.Worker; |
89 | 89 | import charactermanaj.ui.progress.WorkerException; |
90 | 90 | import charactermanaj.ui.progress.WorkerWithProgessDialog; |
91 | +import charactermanaj.ui.util.ScaleSupport; | |
91 | 92 | import charactermanaj.util.ErrorMessageHelper; |
92 | 93 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
93 | 94 |
@@ -296,7 +297,13 @@ public class ExportWizardDialog extends JDialog { | ||
296 | 297 | |
297 | 298 | // 表示 |
298 | 299 | |
299 | - setSize(500, 500); | |
300 | + Dimension dim = new Dimension(500, 500); | |
301 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
302 | + if (scaleSupport != null) { | |
303 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
304 | + dim = scaleSupport.manualScaled(dim); | |
305 | + } | |
306 | + setSize(dim); | |
300 | 307 | setLocationRelativeTo(parent); |
301 | 308 | |
302 | 309 | mainPanelLayout.first(mainPanel); |
@@ -849,10 +856,12 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
849 | 856 | partsTable.setGridColor(appConfig.getGridColor()); |
850 | 857 | partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
851 | 858 | partsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
852 | - partsTableModel.adjustColumnModel(partsTable.getColumnModel()); | |
853 | 859 | partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
854 | 860 | partsTable.setRowSelectionAllowed(true); |
855 | 861 | |
862 | + // 行の高さをフォントの高さにする | |
863 | + partsTable.setRowHeight((int)(partsTable.getFont().getSize() * 1.2)); | |
864 | + | |
856 | 865 | Action actPartsSetCheck = new AbstractAction(strings.getProperty("parts.popup.check")) { |
857 | 866 | private static final long serialVersionUID = 1L; |
858 | 867 | public void actionPerformed(ActionEvent e) { |
@@ -943,6 +952,13 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR | ||
943 | 952 | add(btnPanel, BorderLayout.SOUTH); |
944 | 953 | } |
945 | 954 | |
955 | + @Override | |
956 | + public void addNotify() { | |
957 | + super.addNotify(); | |
958 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
959 | + partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
960 | + } | |
961 | + | |
946 | 962 | protected void loadPartsInfo(PartsSpecResolver partsSpecResolver) { |
947 | 963 | partsTableModel.clear(); |
948 | 964 | for (PartsCategory partsCategory : partsSpecResolver.getPartsCategories()) { |
@@ -1104,6 +1120,9 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1104 | 1120 | presetTable.setGridColor(appConfig.getGridColor()); |
1105 | 1121 | presetTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
1106 | 1122 | |
1123 | + // 行の高さをフォントの高さにする | |
1124 | + presetTable.setRowHeight((int)(presetTable.getFont().getSize() * 1.2)); | |
1125 | + | |
1107 | 1126 | final Action actSelectUsedParts = new AbstractAction( |
1108 | 1127 | strings.getProperty("preset.popup.selectUsedParts")) { |
1109 | 1128 | private static final long serialVersionUID = 1L; |
@@ -1119,7 +1138,6 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1119 | 1138 | |
1120 | 1139 | |
1121 | 1140 | presetTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
1122 | - presetTableModel.adjustColumnModel(presetTable.getColumnModel()); | |
1123 | 1141 | |
1124 | 1142 | add(new JScrollPane(presetTable), BorderLayout.CENTER); |
1125 | 1143 |
@@ -1179,6 +1197,13 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese | ||
1179 | 1197 | add(btnPanel, BorderLayout.SOUTH); |
1180 | 1198 | } |
1181 | 1199 | |
1200 | + @Override | |
1201 | + public void addNotify() { | |
1202 | + super.addNotify(); | |
1203 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
1204 | + presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
1205 | + } | |
1206 | + | |
1182 | 1207 | protected void loadPresetInfo(Collection<PartsSet> partsSets, String defaultPresetId) { |
1183 | 1208 | presetTableModel.clear(); |
1184 | 1209 | for (PartsSet orgPartsSet : partsSets) { |
@@ -1298,9 +1323,9 @@ class ExportPartsTableModel extends AbstractTableModelWithComboBoxModel<ExportPa | ||
1298 | 1323 | }; |
1299 | 1324 | } |
1300 | 1325 | |
1301 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
1326 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
1302 | 1327 | for (int idx = 0; idx < columnWidths.length; idx++) { |
1303 | - columnModel.getColumn(idx).setPreferredWidth(columnWidths[idx]); | |
1328 | + columnModel.getColumn(idx).setPreferredWidth((int)(columnWidths[idx] * scale)); | |
1304 | 1329 | } |
1305 | 1330 | } |
1306 | 1331 |
@@ -1648,9 +1673,9 @@ class ExportPresetTableModel extends AbstractTableModelWithComboBoxModel<ExportP | ||
1648 | 1673 | |
1649 | 1674 | private String defaultPresetId; |
1650 | 1675 | |
1651 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
1676 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
1652 | 1677 | for (int idx = 0; idx < columnWidths.length; idx++) { |
1653 | - columnModel.getColumn(idx).setPreferredWidth(columnWidths[idx]); | |
1678 | + columnModel.getColumn(idx).setPreferredWidth((int)(columnWidths[idx] * scale)); | |
1654 | 1679 | } |
1655 | 1680 | } |
1656 | 1681 |
@@ -58,6 +58,7 @@ import charactermanaj.model.PartsCategory; | ||
58 | 58 | import charactermanaj.model.PartsIdentifier; |
59 | 59 | import charactermanaj.model.PartsSpec; |
60 | 60 | import charactermanaj.model.PartsSpecResolver; |
61 | +import charactermanaj.ui.util.ScaleSupport; | |
61 | 62 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
62 | 63 | import charactermanaj.util.UIHelper; |
63 | 64 |
@@ -221,7 +222,8 @@ public class ImageSelectPanel extends JPanel { | ||
221 | 222 | * @param partsCategory パーツカテゴリ |
222 | 223 | * @param partsSpecResolver キャラクターデータ |
223 | 224 | */ |
224 | - public ImageSelectPanel(final PartsCategory partsCategory, final PartsSpecResolver partsSpecResolver) { | |
225 | + public ImageSelectPanel(ScaleSupport scaleSupport, final PartsCategory partsCategory, | |
226 | + final PartsSpecResolver partsSpecResolver) { | |
225 | 227 | if (partsCategory == null || partsSpecResolver == null) { |
226 | 228 | throw new IllegalArgumentException(); |
227 | 229 | } |
@@ -240,11 +242,13 @@ public class ImageSelectPanel extends JPanel { | ||
240 | 242 | |
241 | 243 | partsSelectTableModel = new PartsSelectListModel(partsCategory); |
242 | 244 | |
245 | + double scale = scaleSupport.getManualScaleX(); | |
246 | + | |
243 | 247 | final DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); |
244 | - TableColumn checkColumn = new TableColumn(0, 32); | |
245 | - checkColumn.setMaxWidth(42); | |
248 | + TableColumn checkColumn = new TableColumn(0, (int)(32 * scale)); | |
249 | + checkColumn.setMaxWidth((int)(42 * scale)); | |
246 | 250 | columnModel.addColumn(checkColumn); |
247 | - columnModel.addColumn(new TableColumn(1, 100)); | |
251 | + columnModel.addColumn(new TableColumn(1, (int)(100 * scale))); | |
248 | 252 | |
249 | 253 | final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); |
250 | 254 | selectionModel.addListSelectionListener(new ListSelectionListener() { |
@@ -310,6 +314,7 @@ public class ImageSelectPanel extends JPanel { | ||
310 | 314 | return null; |
311 | 315 | } |
312 | 316 | }; |
317 | + | |
313 | 318 | partsSelectTable.addFocusListener(new FocusAdapter() { |
314 | 319 | @Override |
315 | 320 | public void focusGained(FocusEvent e) { |
@@ -320,6 +325,10 @@ public class ImageSelectPanel extends JPanel { | ||
320 | 325 | partsSelectTable.repaint(); |
321 | 326 | } |
322 | 327 | }); |
328 | + | |
329 | + // 行の高さをフォントの高さにする | |
330 | + partsSelectTable.setRowHeight((int)(partsSelectTable.getFont().getSize() * 1.2)); | |
331 | + | |
323 | 332 | final JPopupMenu partsSelectTablePopupMenu = new JPopupMenu(); |
324 | 333 | Action actDeselectAll = new AbstractAction( |
325 | 334 | strings.getProperty("popupmenu.deselectall")) { |
@@ -527,6 +536,7 @@ public class ImageSelectPanel extends JPanel { | ||
527 | 536 | |
528 | 537 | // デフォルトのパネル幅を設定する. |
529 | 538 | Dimension dim = new Dimension(200, 200); |
539 | + dim = scaleSupport.manualScaled(dim); | |
530 | 540 | setPreferredSize(dim); |
531 | 541 | |
532 | 542 | // パネルの初期サイズ |
@@ -101,6 +101,7 @@ import charactermanaj.ui.progress.Worker; | ||
101 | 101 | import charactermanaj.ui.progress.WorkerException; |
102 | 102 | import charactermanaj.ui.progress.WorkerWithProgessDialog; |
103 | 103 | import charactermanaj.ui.util.FileDropTarget; |
104 | +import charactermanaj.ui.util.ScaleSupport; | |
104 | 105 | import charactermanaj.util.ErrorMessageHelper; |
105 | 106 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
106 | 107 |
@@ -376,7 +377,13 @@ public class ImportWizardDialog extends JDialog { | ||
376 | 377 | |
377 | 378 | // 表示 |
378 | 379 | |
379 | - setSize(500, 550); | |
380 | + Dimension dim = new Dimension(500, 500); | |
381 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
382 | + if (scaleSupport != null) { | |
383 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
384 | + dim = scaleSupport.manualScaled(dim); | |
385 | + } | |
386 | + setSize(dim); | |
380 | 387 | setLocationRelativeTo(parent); |
381 | 388 | |
382 | 389 | mainPanelLayout.first(mainPanel); |
@@ -1173,9 +1180,9 @@ class URLTableModel extends AbstractTableModelWithComboBoxModel<URLTableRow> { | ||
1173 | 1180 | } |
1174 | 1181 | |
1175 | 1182 | |
1176 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
1183 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
1177 | 1184 | for (int idx = 0; idx < COLUMN_WIDTHS.length; idx++) { |
1178 | - columnModel.getColumn(idx).setPreferredWidth(COLUMN_WIDTHS[idx]); | |
1185 | + columnModel.getColumn(idx).setPreferredWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
1179 | 1186 | } |
1180 | 1187 | } |
1181 | 1188 |
@@ -1844,10 +1851,12 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1844 | 1851 | partsTable.setShowGrid(true); |
1845 | 1852 | partsTable.setGridColor(appConfig.getGridColor()); |
1846 | 1853 | partsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
1847 | - partsTableModel.adjustColumnModel(partsTable.getColumnModel()); | |
1848 | 1854 | partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
1849 | 1855 | partsTable.setRowSelectionAllowed(true); |
1850 | 1856 | |
1857 | + // 行の高さをフォントの高さにする | |
1858 | + partsTable.setRowHeight((int)(partsTable.getFont().getSize() * 1.2)); | |
1859 | + | |
1851 | 1860 | Action actPartsSetCheck = new AbstractAction(strings.getProperty("parts.popup.check")) { |
1852 | 1861 | private static final long serialVersionUID = 1L; |
1853 | 1862 | public void actionPerformed(ActionEvent e) { |
@@ -1949,6 +1958,12 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel { | ||
1949 | 1958 | add(btnPanel, BorderLayout.SOUTH); |
1950 | 1959 | } |
1951 | 1960 | |
1961 | + @Override | |
1962 | + public void addNotify() { | |
1963 | + super.addNotify(); | |
1964 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
1965 | + partsTableModel.adjustColumnModel(partsTable.getColumnModel(), scaleSupport.getDefaultScaleX()); | |
1966 | + } | |
1952 | 1967 | |
1953 | 1968 | @Override |
1954 | 1969 | public void onActive(ImportWizardDialog parent, ImportWizardCardPanel previousPanel) { |
@@ -2721,10 +2736,10 @@ class ImportPartsTableModel extends AbstractTableModelWithComboBoxModel<ImportPa | ||
2721 | 2736 | return false; |
2722 | 2737 | } |
2723 | 2738 | |
2724 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
2739 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
2725 | 2740 | int mx = columnModel.getColumnCount(); |
2726 | 2741 | for (int idx = 0; idx < mx; idx++) { |
2727 | - columnModel.getColumn(idx).setWidth(COLUMN_WIDTHS[idx]); | |
2742 | + columnModel.getColumn(idx).setWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
2728 | 2743 | } |
2729 | 2744 | } |
2730 | 2745 |
@@ -2918,6 +2933,9 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2918 | 2933 | presetTable.setGridColor(appConfig.getGridColor()); |
2919 | 2934 | presetTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
2920 | 2935 | |
2936 | + // 行の高さをフォントの高さにする | |
2937 | + presetTable.setRowHeight((int)(presetTable.getFont().getSize() * 1.2)); | |
2938 | + | |
2921 | 2939 | actSelectUsedParts = new AbstractAction(strings.getProperty("preset.popup.selectUsedParts")) { |
2922 | 2940 | private static final long serialVersionUID = 1L; |
2923 | 2941 |
@@ -2930,9 +2948,7 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2930 | 2948 | popupMenu.add(actSelectUsedParts); |
2931 | 2949 | |
2932 | 2950 | presetTable.setComponentPopupMenu(popupMenu); |
2933 | - | |
2934 | 2951 | presetTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
2935 | - presetTableModel.adjustColumnModel(presetTable.getColumnModel()); | |
2936 | 2952 | |
2937 | 2953 | add(new JScrollPane(presetTable), BorderLayout.CENTER); |
2938 | 2954 |
@@ -2996,6 +3012,13 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel { | ||
2996 | 3012 | } |
2997 | 3013 | |
2998 | 3014 | @Override |
3015 | + public void addNotify() { | |
3016 | + super.addNotify(); | |
3017 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
3018 | + presetTableModel.adjustColumnModel(presetTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
3019 | + } | |
3020 | + | |
3021 | + @Override | |
2999 | 3022 | public void onActive(ImportWizardDialog parent, |
3000 | 3023 | ImportWizardCardPanel previousPanel) { |
3001 | 3024 | this.parent= parent; |
@@ -3302,10 +3325,10 @@ class ImportPresetTableModel extends AbstractTableModelWithComboBoxModel<ImportP | ||
3302 | 3325 | return rowModel.getPartsSet().getPartsSetId().equals(defaultPartsSetId); |
3303 | 3326 | } |
3304 | 3327 | |
3305 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
3328 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
3306 | 3329 | int mx = columnModel.getColumnCount(); |
3307 | 3330 | for (int idx = 0; idx < mx; idx++) { |
3308 | - columnModel.getColumn(idx).setWidth(COLUMN_WIDTHS[idx]); | |
3331 | + columnModel.getColumn(idx).setWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
3309 | 3332 | } |
3310 | 3333 | } |
3311 | 3334 |
@@ -5,6 +5,7 @@ import static java.lang.Math.*; | ||
5 | 5 | import java.awt.BorderLayout; |
6 | 6 | import java.awt.Component; |
7 | 7 | import java.awt.Container; |
8 | +import java.awt.Dimension; | |
8 | 9 | import java.awt.GridBagConstraints; |
9 | 10 | import java.awt.GridBagLayout; |
10 | 11 | import java.awt.Insets; |
@@ -65,6 +66,7 @@ import charactermanaj.model.PartsSpecResolver; | ||
65 | 66 | import charactermanaj.model.io.PartsImageCollectionParser; |
66 | 67 | import charactermanaj.model.io.PartsImageCollectionParser.PartsImageCollectionHandler; |
67 | 68 | import charactermanaj.ui.model.AbstractTableModelWithComboBoxModel; |
69 | +import charactermanaj.ui.util.ScaleSupport; | |
68 | 70 | import charactermanaj.util.DesktopUtilities; |
69 | 71 | import charactermanaj.util.ErrorMessageHelper; |
70 | 72 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
@@ -137,13 +139,17 @@ public class InformationDialog extends JDialog { | ||
137 | 139 | return prepareRenderer; |
138 | 140 | } |
139 | 141 | }; |
140 | - informationTableModel.adjustColumnModel(informationTable.getColumnModel()); | |
142 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
143 | + informationTableModel.adjustColumnModel(informationTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
141 | 144 | informationTable.setShowGrid(true); |
142 | 145 | informationTable.setGridColor(appConfig.getGridColor()); |
143 | 146 | informationTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
144 | 147 | informationTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
145 | 148 | informationTable.setRowHeight(informationTable.getRowHeight() + 4); |
146 | 149 | |
150 | + // 行の高さをフォントの高さにする | |
151 | + informationTable.setRowHeight((int)(informationTable.getFont().getSize() * 1.2)); | |
152 | + | |
147 | 153 | informationTable.setDefaultRenderer(JButton.class, new ButtonCellRender()); |
148 | 154 | informationTable.setDefaultEditor(JButton.class, new ButtonCellEditor()); |
149 | 155 |
@@ -232,7 +238,10 @@ public class InformationDialog extends JDialog { | ||
232 | 238 | im.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, tk.getMenuShortcutKeyMask()), "closeInformationDialog"); |
233 | 239 | am.put("closeInformationDialog", actClose); |
234 | 240 | |
235 | - pack(); | |
241 | + // 推奨サイズをスクリーンのスケールで調整する | |
242 | + Dimension dim = getPreferredSize(); | |
243 | + dim = scaleSupport.manualScaled(dim); | |
244 | + setSize(dim); | |
236 | 245 | setLocationRelativeTo(parent); |
237 | 246 | } |
238 | 247 |
@@ -421,9 +430,9 @@ class InformationTableModel extends AbstractTableModelWithComboBoxModel<Informat | ||
421 | 430 | } |
422 | 431 | } |
423 | 432 | |
424 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
433 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
425 | 434 | for (int idx = 0; idx < COLUMNS.length; idx++) { |
426 | - columnModel.getColumn(idx).setPreferredWidth(columnWidths[idx]); | |
435 | + columnModel.getColumn(idx).setPreferredWidth((int)(columnWidths[idx] * scale)); | |
427 | 436 | } |
428 | 437 | } |
429 | 438 |
@@ -72,6 +72,7 @@ import charactermanaj.model.ListChangeListener; | ||
72 | 72 | import charactermanaj.model.ObservableList; |
73 | 73 | import charactermanaj.model.PartsCategory; |
74 | 74 | import charactermanaj.ui.model.SimpleComboBoxModel; |
75 | +import charactermanaj.ui.util.ScaleSupport; | |
75 | 76 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
76 | 77 | |
77 | 78 | /** |
@@ -390,7 +391,15 @@ public class LayerOrderCustomizeDialog extends JDialog { | ||
390 | 391 | tblLayerOrder.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
391 | 392 | tblLayerOrder.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
392 | 393 | |
393 | - dataModel.adjustColumnModel(tblLayerOrder.getColumnModel()); | |
394 | + // 行の高さをフォントの高さにする | |
395 | + tblLayerOrder.setRowHeight((int)(tblLayerOrder.getFont().getSize() * 1.2)); | |
396 | + | |
397 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
398 | + int tableWidth = dataModel.adjustColumnModel(tblLayerOrder.getColumnModel(), scaleSupport.getManualScaleX()); | |
399 | + | |
400 | + Dimension tablePrefSize = scr.getPreferredSize(); | |
401 | + tablePrefSize.width = tableWidth + 10; | |
402 | + scr.setPreferredSize(tablePrefSize); | |
394 | 403 | |
395 | 404 | AbstractAction actAddLayer = new AbstractAction(strings.getProperty("btnAdd")) { |
396 | 405 | private static final long serialVersionUID = 1L; |
@@ -679,11 +688,14 @@ public class LayerOrderCustomizeDialog extends JDialog { | ||
679 | 688 | * カラム幅を設定する。 |
680 | 689 | * @param columnModel |
681 | 690 | */ |
682 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
691 | + public int adjustColumnModel(TableColumnModel columnModel, double scale) { | |
692 | + int total = 0; | |
683 | 693 | for (int idx = 0; idx < columns.length; idx++) { |
684 | - columnModel.getColumn(idx).setPreferredWidth( | |
685 | - columns[idx].getPrefWidth()); | |
694 | + int width = (int)(columns[idx].getPrefWidth() * scale); | |
695 | + columnModel.getColumn(idx).setPreferredWidth(width); | |
696 | + total += width; | |
686 | 697 | } |
698 | + return total; | |
687 | 699 | } |
688 | 700 | |
689 | 701 | /** |
@@ -1321,8 +1333,9 @@ public class LayerOrderCustomizeDialog extends JDialog { | ||
1321 | 1333 | am.put("closeAddLayerDialog", actCancel); |
1322 | 1334 | |
1323 | 1335 | // コンボボックスの推奨幅を明示的に指定する。(言語によっては幅が小さくなりすぎるため) |
1336 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
1324 | 1337 | Dimension prefSize = cmbCategory.getPreferredSize(); |
1325 | - prefSize.width = 200; | |
1338 | + prefSize.width = (int)(200 * scaleSupport.getManualScaleX()); | |
1326 | 1339 | cmbCategory.setPreferredSize(prefSize); |
1327 | 1340 | pack(); |
1328 | 1341 |
@@ -119,6 +119,7 @@ import charactermanaj.ui.model.WallpaperFactoryException; | ||
119 | 119 | import charactermanaj.ui.model.WallpaperInfo; |
120 | 120 | import charactermanaj.ui.scrollablemenu.JScrollableMenu; |
121 | 121 | import charactermanaj.ui.util.FileDropTarget; |
122 | +import charactermanaj.ui.util.ScaleSupport; | |
122 | 123 | import charactermanaj.ui.util.WindowAdjustLocationSupport; |
123 | 124 | import charactermanaj.util.DesktopUtilities; |
124 | 125 | import charactermanaj.util.ErrorMessageHelper; |
@@ -473,7 +474,14 @@ public class MainFrame extends JFrame | ||
473 | 474 | int imageHeight = min(maxHeight, max(400, imageSize != null ? imageSize.height : 0)); |
474 | 475 | // 300x400の画像の場合にメインフレームが600x550だとちょうどいい感じ. |
475 | 476 | // それ以上大きい画像の場合は増えた分だけフレームを大きくしておく. |
476 | - setSize(imageWidth - 300 + 600, imageHeight - 400 + 550); | |
477 | + | |
478 | + Dimension dim = new Dimension(imageWidth - 300 + 600, imageHeight - 400 + 550); | |
479 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
480 | + if (scaleSupport != null) { | |
481 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
482 | + dim = scaleSupport.manualScaled(dim); | |
483 | + } | |
484 | + setSize(dim); | |
477 | 485 | |
478 | 486 | // 現在表示されていなければ、次回表示時にプラットフォーム固有位置に表示するように予約 |
479 | 487 | if (!isShowing()) { |
@@ -733,11 +741,13 @@ public class MainFrame extends JFrame | ||
733 | 741 | |
734 | 742 | imageSelectPanels = new ImageSelectPanelList(); |
735 | 743 | |
744 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
745 | + | |
736 | 746 | JPanel imgSelectPanelsPanel = new JPanel(); |
737 | 747 | BoxLayout bl = new BoxLayout(imgSelectPanelsPanel, BoxLayout.PAGE_AXIS); |
738 | 748 | imgSelectPanelsPanel.setLayout(bl); |
739 | 749 | for (PartsCategory category : characterData.getPartsCategories()) { |
740 | - final ImageSelectPanel imageSelectPanel = new ImageSelectPanel(category, characterData); | |
750 | + final ImageSelectPanel imageSelectPanel = new ImageSelectPanel(scaleSupport, category, characterData); | |
741 | 751 | imgSelectPanelsPanel.add(imageSelectPanel); |
742 | 752 | imageSelectPanels.add(imageSelectPanel); |
743 | 753 | partsSelectionManager.register(imageSelectPanel); |
@@ -48,6 +48,7 @@ import javax.swing.table.AbstractTableModel; | ||
48 | 48 | |
49 | 49 | import charactermanaj.model.CharacterData; |
50 | 50 | import charactermanaj.model.PartsSet; |
51 | +import charactermanaj.ui.util.ScaleSupport; | |
51 | 52 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
52 | 53 | import charactermanaj.util.UIHelper; |
53 | 54 |
@@ -228,8 +229,10 @@ public class ManageFavoriteDialog extends JDialog { | ||
228 | 229 | partsSetListModel = new PartsSetListTableModel(); |
229 | 230 | partsSetList = new JTable(partsSetListModel); |
230 | 231 | partsSetList.setRowSelectionAllowed(true); |
231 | - partsSetList | |
232 | - .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
232 | + partsSetList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); | |
233 | + | |
234 | + // 行の高さをフォントの高さにする | |
235 | + partsSetList.setRowHeight((int)(partsSetList.getFont().getSize() * 1.2)); | |
233 | 236 | |
234 | 237 | partsSetList.setTableHeader(null); |
235 | 238 | partsSetList.getColumnModel().getColumn(1).setMaxWidth(150); |
@@ -316,7 +319,13 @@ public class ManageFavoriteDialog extends JDialog { | ||
316 | 319 | am.put("deleteFav", actDelete); |
317 | 320 | am.put("closeManageFavoriteDialog", actCancel); |
318 | 321 | |
319 | - setSize(400, 500); | |
322 | + Dimension dim = new Dimension(400, 500); | |
323 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
324 | + if (scaleSupport != null) { | |
325 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
326 | + dim = scaleSupport.manualScaled(dim); | |
327 | + } | |
328 | + setSize(dim); | |
320 | 329 | setLocationRelativeTo(parent); |
321 | 330 | |
322 | 331 | final JPopupMenu popupMenu = new JPopupMenu(); |
@@ -4,6 +4,7 @@ import java.awt.BorderLayout; | ||
4 | 4 | import java.awt.Color; |
5 | 5 | import java.awt.Component; |
6 | 6 | import java.awt.Container; |
7 | +import java.awt.Dimension; | |
7 | 8 | import java.awt.GridBagConstraints; |
8 | 9 | import java.awt.GridBagLayout; |
9 | 10 | import java.awt.Insets; |
@@ -68,6 +69,7 @@ import charactermanaj.model.PartsSpec; | ||
68 | 69 | import charactermanaj.model.io.PartsInfoXMLReader; |
69 | 70 | import charactermanaj.model.io.PartsInfoXMLWriter; |
70 | 71 | import charactermanaj.ui.model.AbstractTableModelWithComboBoxModel; |
72 | +import charactermanaj.ui.util.ScaleSupport; | |
71 | 73 | import charactermanaj.util.DesktopUtilities; |
72 | 74 | import charactermanaj.util.ErrorMessageHelper; |
73 | 75 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
@@ -75,33 +77,33 @@ import charactermanaj.util.LocalizedResourcePropertyLoader; | ||
75 | 77 | public class PartsManageDialog extends JDialog { |
76 | 78 | |
77 | 79 | private static final long serialVersionUID = 1L; |
78 | - | |
80 | + | |
79 | 81 | protected static final String STRINGS_RESOURCE = "languages/partsmanagedialog"; |
80 | - | |
81 | - | |
82 | + | |
83 | + | |
82 | 84 | private static final Logger logger = Logger.getLogger(PartsManageDialog.class.getName()); |
83 | 85 | |
84 | 86 | private CharacterData characterData; |
85 | - | |
87 | + | |
86 | 88 | private PartsManageTableModel partsManageTableModel; |
87 | - | |
89 | + | |
88 | 90 | private JTable partsManageTable; |
89 | - | |
91 | + | |
90 | 92 | private JTextField txtHomepage; |
91 | - | |
93 | + | |
92 | 94 | private JTextField txtAuthor; |
93 | - | |
95 | + | |
94 | 96 | private boolean updated; |
95 | 97 | |
96 | - | |
98 | + | |
97 | 99 | public PartsManageDialog(JFrame parent, CharacterData characterData) { |
98 | 100 | super(parent, true); |
99 | - | |
101 | + | |
100 | 102 | if (characterData == null) { |
101 | 103 | throw new IllegalArgumentException(); |
102 | 104 | } |
103 | 105 | this.characterData = characterData; |
104 | - | |
106 | + | |
105 | 107 | setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); |
106 | 108 | addWindowListener(new WindowAdapter() { |
107 | 109 | @Override |
@@ -116,7 +118,7 @@ public class PartsManageDialog extends JDialog { | ||
116 | 118 | setTitle(strings.getProperty("title")); |
117 | 119 | |
118 | 120 | Container contentPane = getContentPane(); |
119 | - | |
121 | + | |
120 | 122 | // パーツリストテーブル |
121 | 123 | JPanel partsListPanel = new JPanel(); |
122 | 124 | partsListPanel.setBorder(BorderFactory.createCompoundBorder( |
@@ -125,7 +127,7 @@ public class PartsManageDialog extends JDialog { | ||
125 | 127 | |
126 | 128 | GridBagLayout partsListPanelLayout = new GridBagLayout(); |
127 | 129 | partsListPanel.setLayout(partsListPanelLayout); |
128 | - | |
130 | + | |
129 | 131 | partsManageTableModel = new PartsManageTableModel(); |
130 | 132 | partsManageTable = new JTable(partsManageTableModel) { |
131 | 133 | private static final long serialVersionUID = 1L; |
@@ -166,12 +168,16 @@ public class PartsManageDialog extends JDialog { | ||
166 | 168 | }; |
167 | 169 | partsManageTable.setShowGrid(true); |
168 | 170 | partsManageTable.setGridColor(AppConfig.getInstance().getGridColor()); |
169 | - partsManageTableModel.adjustColumnModel(partsManageTable.getColumnModel()); | |
171 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
172 | + partsManageTableModel.adjustColumnModel(partsManageTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
170 | 173 | partsManageTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
171 | 174 | partsManageTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
172 | 175 | |
176 | + // 行の高さをフォントの高さにする | |
177 | + partsManageTable.setRowHeight((int)(partsManageTable.getFont().getSize() * 1.2)); | |
178 | + | |
173 | 179 | JScrollPane partsManageTableSP = new JScrollPane(partsManageTable); |
174 | - | |
180 | + | |
175 | 181 | partsManageTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
176 | 182 | public void valueChanged(ListSelectionEvent e) { |
177 | 183 | if (!e.getValueIsAdjusting()) { |
@@ -179,13 +185,13 @@ public class PartsManageDialog extends JDialog { | ||
179 | 185 | } |
180 | 186 | } |
181 | 187 | }); |
182 | - | |
188 | + | |
183 | 189 | partsManageTableModel.addTableModelListener(new TableModelListener() { |
184 | 190 | public void tableChanged(TableModelEvent e) { |
185 | 191 | onTableDataChange(e.getFirstRow(), e.getLastRow()); |
186 | 192 | } |
187 | 193 | }); |
188 | - | |
194 | + | |
189 | 195 | GridBagConstraints gbc = new GridBagConstraints(); |
190 | 196 | gbc.gridx = 0; |
191 | 197 | gbc.gridy = 0; |
@@ -199,7 +205,7 @@ public class PartsManageDialog extends JDialog { | ||
199 | 205 | gbc.weightx = 1.; |
200 | 206 | gbc.weighty = 1.; |
201 | 207 | partsListPanel.add(partsManageTableSP, gbc); |
202 | - | |
208 | + | |
203 | 209 | Action actSortByName = new AbstractAction(strings.getProperty("sortByName")) { |
204 | 210 | private static final long serialVersionUID = 1L; |
205 | 211 | public void actionPerformed(ActionEvent e) { |
@@ -218,7 +224,7 @@ public class PartsManageDialog extends JDialog { | ||
218 | 224 | onSortByTimestamp(); |
219 | 225 | } |
220 | 226 | }; |
221 | - | |
227 | + | |
222 | 228 | gbc.gridx = 0; |
223 | 229 | gbc.gridy = 1; |
224 | 230 | gbc.gridheight = 1; |
@@ -271,9 +277,9 @@ public class PartsManageDialog extends JDialog { | ||
271 | 277 | popupMenu.add(new JSeparator()); |
272 | 278 | popupMenu.add(actApplyAllVersion); |
273 | 279 | popupMenu.add(actApplyAllDownloadURL); |
274 | - | |
280 | + | |
275 | 281 | partsManageTable.setComponentPopupMenu(popupMenu); |
276 | - | |
282 | + | |
277 | 283 | // 作者情報パネル |
278 | 284 | JPanel authorPanel = new JPanel(); |
279 | 285 | authorPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory |
@@ -281,7 +287,7 @@ public class PartsManageDialog extends JDialog { | ||
281 | 287 | .createTitledBorder(strings.getProperty("author.info")))); |
282 | 288 | GridBagLayout authorPanelLayout = new GridBagLayout(); |
283 | 289 | authorPanel.setLayout(authorPanelLayout); |
284 | - | |
290 | + | |
285 | 291 | gbc.gridx = 0; |
286 | 292 | gbc.gridy = 0; |
287 | 293 | gbc.gridheight = 1; |
@@ -330,7 +336,7 @@ public class PartsManageDialog extends JDialog { | ||
330 | 336 | if (!DesktopUtilities.isSupported()) { |
331 | 337 | actBrowseHomepage.setEnabled(false); |
332 | 338 | } |
333 | - | |
339 | + | |
334 | 340 | txtAuthor.getDocument().addDocumentListener(new DocumentListener() { |
335 | 341 | public void removeUpdate(DocumentEvent e) { |
336 | 342 | onEditAuthor(); |
@@ -353,14 +359,14 @@ public class PartsManageDialog extends JDialog { | ||
353 | 359 | onEditHomepage(); |
354 | 360 | } |
355 | 361 | }); |
356 | - | |
357 | - | |
362 | + | |
363 | + | |
358 | 364 | // ボタンパネル |
359 | 365 | JPanel btnPanel = new JPanel(); |
360 | 366 | btnPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 45)); |
361 | 367 | GridBagLayout btnPanelLayout = new GridBagLayout(); |
362 | 368 | btnPanel.setLayout(btnPanelLayout); |
363 | - | |
369 | + | |
364 | 370 | Action actClose = new AbstractAction(strings.getProperty("cancel")) { |
365 | 371 | private static final long serialVersionUID = 1L; |
366 | 372 | public void actionPerformed(ActionEvent e) { |
@@ -373,12 +379,12 @@ public class PartsManageDialog extends JDialog { | ||
373 | 379 | onOK(); |
374 | 380 | } |
375 | 381 | }; |
376 | - | |
382 | + | |
377 | 383 | gbc.gridx = 0; |
378 | 384 | gbc.gridy = 0; |
379 | 385 | gbc.weightx = 1.; |
380 | 386 | btnPanel.add(Box.createHorizontalGlue(), gbc); |
381 | - | |
387 | + | |
382 | 388 | gbc.gridx = Main.isLinuxOrMacOSX() ? 2 : 1; |
383 | 389 | gbc.gridy = 0; |
384 | 390 | gbc.weightx = 0.; |
@@ -388,16 +394,16 @@ public class PartsManageDialog extends JDialog { | ||
388 | 394 | gbc.gridy = 0; |
389 | 395 | gbc.weightx = 0.; |
390 | 396 | btnPanel.add(new JButton(actClose), gbc); |
391 | - | |
397 | + | |
392 | 398 | // ダイアログ下部 |
393 | 399 | JPanel southPanel = new JPanel(new BorderLayout()); |
394 | 400 | southPanel.add(authorPanel, BorderLayout.NORTH); |
395 | 401 | southPanel.add(btnPanel, BorderLayout.SOUTH); |
396 | 402 | |
397 | 403 | contentPane.add(southPanel, BorderLayout.SOUTH); |
398 | - | |
404 | + | |
399 | 405 | // キーボード |
400 | - | |
406 | + | |
401 | 407 | Toolkit tk = Toolkit.getDefaultToolkit(); |
402 | 408 | JRootPane rootPane = getRootPane(); |
403 | 409 | InputMap im = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); |
@@ -408,14 +414,16 @@ public class PartsManageDialog extends JDialog { | ||
408 | 414 | |
409 | 415 | // モデル構築 |
410 | 416 | partsManageTableModel.initModel(characterData); |
411 | - | |
417 | + | |
412 | 418 | // ウィンドウ配置 |
413 | - setSize(500, 400); | |
419 | + Dimension dim = new Dimension(500, 400); | |
420 | + dim = scaleSupport.manualScaled(dim); | |
421 | + setSize(dim); | |
414 | 422 | setLocationRelativeTo(parent); |
415 | 423 | } |
416 | 424 | |
417 | 425 | private Semaphore authorEditSemaphore = new Semaphore(1); |
418 | - | |
426 | + | |
419 | 427 | protected void onChangeSelection() { |
420 | 428 | try { |
421 | 429 | authorEditSemaphore.acquire(); |
@@ -471,11 +479,11 @@ public class PartsManageDialog extends JDialog { | ||
471 | 479 | ErrorMessageHelper.showErrorDialog(this, ex); |
472 | 480 | } |
473 | 481 | } |
474 | - | |
482 | + | |
475 | 483 | protected void onTableDataChange(int firstRow, int lastRow) { |
476 | 484 | onChangeSelection(); |
477 | 485 | } |
478 | - | |
486 | + | |
479 | 487 | protected void onApplyAllLastModified() { |
480 | 488 | int[] selRows = partsManageTable.getSelectedRows(); |
481 | 489 | if (selRows.length == 0) { |
@@ -520,7 +528,7 @@ public class PartsManageDialog extends JDialog { | ||
520 | 528 | return; |
521 | 529 | } |
522 | 530 | } |
523 | - | |
531 | + | |
524 | 532 | PartsManageTableRow firstRow = partsManageTableModel.getRow(selRows[0]); |
525 | 533 | String downloadURL = firstRow.getDownloadURL(); |
526 | 534 | if (downloadURL == null) { |
@@ -531,7 +539,7 @@ public class PartsManageDialog extends JDialog { | ||
531 | 539 | // キャンセルされたか、内容に変化ない場合は何もしない |
532 | 540 | return; |
533 | 541 | } |
534 | - | |
542 | + | |
535 | 543 | for (int selRow : selRows) { |
536 | 544 | PartsManageTableRow row = partsManageTableModel.getRow(selRow); |
537 | 545 | row.setDownloadURL(downloadURL_new); |
@@ -541,7 +549,7 @@ public class PartsManageDialog extends JDialog { | ||
541 | 549 | } |
542 | 550 | partsManageTableModel.fireTableRowsUpdated(selRows[0], selRows[selRows.length - 1]); |
543 | 551 | } |
544 | - | |
552 | + | |
545 | 553 | protected void onApplyAllVersion() { |
546 | 554 | Toolkit tk = Toolkit.getDefaultToolkit(); |
547 | 555 | int[] selRows = partsManageTable.getSelectedRows(); |
@@ -586,7 +594,7 @@ public class PartsManageDialog extends JDialog { | ||
586 | 594 | tk.beep(); |
587 | 595 | return; |
588 | 596 | } |
589 | - | |
597 | + | |
590 | 598 | for (int selRow : selRows) { |
591 | 599 | PartsManageTableRow row = partsManageTableModel.getRow(selRow); |
592 | 600 | row.setVersion(version_new); |
@@ -596,7 +604,7 @@ public class PartsManageDialog extends JDialog { | ||
596 | 604 | } |
597 | 605 | partsManageTableModel.fireTableRowsUpdated(selRows[0], selRows[selRows.length - 1]); |
598 | 606 | } |
599 | - | |
607 | + | |
600 | 608 | protected void onEditHomepage() { |
601 | 609 | try { |
602 | 610 | if (!authorEditSemaphore.tryAcquire()) { |
@@ -637,24 +645,24 @@ public class PartsManageDialog extends JDialog { | ||
637 | 645 | lastRow = Math.min(lastRow, selRow); |
638 | 646 | } |
639 | 647 | } |
640 | - | |
648 | + | |
641 | 649 | String homepage = partsManageTableModel.getHomepage(author); |
642 | 650 | if (homepage == null) { |
643 | 651 | homepage = ""; |
644 | 652 | } |
645 | 653 | txtHomepage.setText(homepage); |
646 | - | |
654 | + | |
647 | 655 | if (firstRow >= 0) { |
648 | 656 | partsManageTable.repaint(); |
649 | 657 | } |
650 | 658 | } finally { |
651 | - authorEditSemaphore.release(); | |
659 | + authorEditSemaphore.release(); | |
652 | 660 | } |
653 | 661 | } catch (Exception ex) { |
654 | 662 | ErrorMessageHelper.showErrorDialog(this, ex); |
655 | 663 | } |
656 | 664 | } |
657 | - | |
665 | + | |
658 | 666 | protected void onClose() { |
659 | 667 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
660 | 668 | .getLocalizedProperties(STRINGS_RESOURCE); |
@@ -667,7 +675,7 @@ public class PartsManageDialog extends JDialog { | ||
667 | 675 | updated = false; |
668 | 676 | dispose(); |
669 | 677 | } |
670 | - | |
678 | + | |
671 | 679 | protected void onBrosweHomepage() { |
672 | 680 | Toolkit tk = Toolkit.getDefaultToolkit(); |
673 | 681 | String homepage = txtHomepage.getText(); |
@@ -684,26 +692,26 @@ public class PartsManageDialog extends JDialog { | ||
684 | 692 | logger.log(Level.INFO, "browse failed. : " + homepage, ex); |
685 | 693 | } |
686 | 694 | } |
687 | - | |
695 | + | |
688 | 696 | protected void onSortByAuthor() { |
689 | 697 | partsManageTableModel.sortByAuthor(); |
690 | 698 | } |
691 | - | |
699 | + | |
692 | 700 | protected void onSortByName() { |
693 | 701 | partsManageTableModel.sortByName(); |
694 | 702 | } |
695 | - | |
703 | + | |
696 | 704 | protected void onSortByTimestamp() { |
697 | 705 | partsManageTableModel.sortByTimestamp(); |
698 | 706 | } |
699 | - | |
707 | + | |
700 | 708 | protected void onOK() { |
701 | 709 | if (partsManageTable.isEditing()) { |
702 | 710 | Toolkit tk = Toolkit.getDefaultToolkit(); |
703 | 711 | tk.beep(); |
704 | 712 | return; |
705 | 713 | } |
706 | - | |
714 | + | |
707 | 715 | int mx = partsManageTableModel.getRowCount(); |
708 | 716 | |
709 | 717 | // 作者ごとのホームページ情報の取得 |
@@ -725,34 +733,34 @@ public class PartsManageDialog extends JDialog { | ||
725 | 733 | } |
726 | 734 | |
727 | 735 | PartsManageData partsManageData = new PartsManageData(); |
728 | - | |
736 | + | |
729 | 737 | // パーツごとの作者とバージョン、ダウンロード先の取得 |
730 | 738 | for (int idx = 0; idx < mx; idx++) { |
731 | 739 | PartsManageTableRow row = partsManageTableModel.getRow(idx); |
732 | - | |
740 | + | |
733 | 741 | String author = row.getAuthor(); |
734 | 742 | PartsAuthorInfo partsAuthorInfo = null; |
735 | 743 | if (author != null && author.trim().length() > 0) { |
736 | 744 | partsAuthorInfo = authorInfoMap.get(author.trim()); |
737 | 745 | } |
738 | - | |
746 | + | |
739 | 747 | double version = row.getVersion(); |
740 | 748 | String downloadURL = row.getDownloadURL(); |
741 | 749 | String localizedName = row.getLocalizedName(); |
742 | 750 | Timestamp lastModified = row.getLastModified(); |
743 | - | |
751 | + | |
744 | 752 | PartsManageData.PartsVersionInfo versionInfo = new PartsManageData.PartsVersionInfo(); |
745 | 753 | versionInfo.setVersion(version); |
746 | 754 | versionInfo.setDownloadURL(downloadURL); |
747 | 755 | versionInfo.setLastModified(lastModified); |
748 | 756 | |
749 | 757 | PartsIdentifier partsIdentifier = row.getPartsIdentifier(); |
750 | - | |
758 | + | |
751 | 759 | PartsManageData.PartsKey partsKey = new PartsManageData.PartsKey(partsIdentifier); |
752 | 760 | partsManageData.putPartsInfo(partsKey, localizedName, |
753 | 761 | partsAuthorInfo, versionInfo); |
754 | 762 | } |
755 | - | |
763 | + | |
756 | 764 | // パーツ管理情報を書き込む. |
757 | 765 | PartsInfoXMLWriter xmlWriter = new PartsInfoXMLWriter(); |
758 | 766 | try { |
@@ -763,14 +771,14 @@ public class PartsManageDialog extends JDialog { | ||
763 | 771 | ErrorMessageHelper.showErrorDialog(this, ex); |
764 | 772 | return; |
765 | 773 | } |
766 | - | |
774 | + | |
767 | 775 | updated = true; |
768 | 776 | dispose(); |
769 | 777 | } |
770 | 778 | |
771 | 779 | /** |
772 | 780 | * パーツ管理情報が更新されたか? |
773 | - * | |
781 | + * | |
774 | 782 | * @return 更新された場合はtrue、そうでなければfalse |
775 | 783 | */ |
776 | 784 | public boolean isUpdated() { |
@@ -779,21 +787,21 @@ public class PartsManageDialog extends JDialog { | ||
779 | 787 | } |
780 | 788 | |
781 | 789 | class PartsManageTableRow { |
782 | - | |
790 | + | |
783 | 791 | private PartsIdentifier partsIdentifier; |
784 | - | |
792 | + | |
785 | 793 | private Timestamp timestamp; |
786 | - | |
794 | + | |
787 | 795 | private String localizedName; |
788 | - | |
796 | + | |
789 | 797 | private String author; |
790 | - | |
798 | + | |
791 | 799 | private String homepage; |
792 | - | |
800 | + | |
793 | 801 | private String downloadURL; |
794 | - | |
802 | + | |
795 | 803 | private double version; |
796 | - | |
804 | + | |
797 | 805 | private Timestamp lastModified; |
798 | 806 | |
799 | 807 | public PartsManageTableRow(PartsIdentifier partsIdentifier, |
@@ -805,9 +813,9 @@ class PartsManageTableRow { | ||
805 | 813 | this.localizedName = partsIdentifier.getLocalizedPartsName(); |
806 | 814 | |
807 | 815 | this.timestamp = new Timestamp(partsSpec.getPartsFiles().lastModified()); |
808 | - | |
816 | + | |
809 | 817 | this.lastModified = lastModified; |
810 | - | |
818 | + | |
811 | 819 | PartsAuthorInfo autherInfo = partsSpec.getAuthorInfo(); |
812 | 820 | if (autherInfo != null) { |
813 | 821 | author = autherInfo.getAuthor(); |
@@ -822,11 +830,11 @@ class PartsManageTableRow { | ||
822 | 830 | downloadURL = partsSpec.getDownloadURL(); |
823 | 831 | version = partsSpec.getVersion(); |
824 | 832 | } |
825 | - | |
833 | + | |
826 | 834 | public PartsIdentifier getPartsIdentifier() { |
827 | 835 | return partsIdentifier; |
828 | 836 | } |
829 | - | |
837 | + | |
830 | 838 | public Timestamp getTimestamp() { |
831 | 839 | return timestamp; |
832 | 840 | } |
@@ -834,46 +842,46 @@ class PartsManageTableRow { | ||
834 | 842 | public String getLocalizedName() { |
835 | 843 | return localizedName; |
836 | 844 | } |
837 | - | |
845 | + | |
838 | 846 | public void setLocalizedName(String localizedName) { |
839 | 847 | if (localizedName == null || localizedName.trim().length() == 0) { |
840 | 848 | throw new IllegalArgumentException(); |
841 | 849 | } |
842 | 850 | this.localizedName = localizedName; |
843 | 851 | } |
844 | - | |
852 | + | |
845 | 853 | public String getAuthor() { |
846 | 854 | return author; |
847 | 855 | } |
848 | - | |
856 | + | |
849 | 857 | public String getDownloadURL() { |
850 | 858 | return downloadURL; |
851 | 859 | } |
852 | - | |
860 | + | |
853 | 861 | public double getVersion() { |
854 | 862 | return version; |
855 | 863 | } |
856 | - | |
864 | + | |
857 | 865 | public void setAuthor(String author) { |
858 | 866 | this.author = author; |
859 | 867 | } |
860 | - | |
868 | + | |
861 | 869 | public void setDownloadURL(String downloadURL) { |
862 | 870 | this.downloadURL = downloadURL; |
863 | 871 | } |
864 | - | |
872 | + | |
865 | 873 | public void setVersion(double version) { |
866 | 874 | this.version = version; |
867 | 875 | } |
868 | - | |
876 | + | |
869 | 877 | public String getHomepage() { |
870 | 878 | return homepage; |
871 | 879 | } |
872 | - | |
880 | + | |
873 | 881 | public void setHomepage(String homepage) { |
874 | 882 | this.homepage = homepage; |
875 | 883 | } |
876 | - | |
884 | + | |
877 | 885 | public Timestamp getLastModified() { |
878 | 886 | return lastModified; |
879 | 887 | } |
@@ -1040,21 +1048,21 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1040 | 1048 | } |
1041 | 1049 | } |
1042 | 1050 | |
1043 | - | |
1051 | + | |
1044 | 1052 | public int getColumnCount() { |
1045 | 1053 | return Columns.values().length; |
1046 | 1054 | } |
1047 | - | |
1055 | + | |
1048 | 1056 | @Override |
1049 | 1057 | public String getColumnName(int column) { |
1050 | 1058 | return Columns.values()[column].getDisplayName(); |
1051 | 1059 | } |
1052 | - | |
1053 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
1060 | + | |
1061 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
1054 | 1062 | Columns[] columns = Columns.values(); |
1055 | 1063 | for (int idx = 0; idx < columns.length; idx++) { |
1056 | 1064 | columnModel.getColumn(idx).setPreferredWidth( |
1057 | - columns[idx].getWidth()); | |
1065 | + (int)(columns[idx].getWidth() * scale)); | |
1058 | 1066 | } |
1059 | 1067 | } |
1060 | 1068 |
@@ -1063,7 +1071,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1063 | 1071 | Columns column = Columns.values()[columnIndex]; |
1064 | 1072 | return column.getValue(row); |
1065 | 1073 | } |
1066 | - | |
1074 | + | |
1067 | 1075 | @Override |
1068 | 1076 | public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
1069 | 1077 | PartsManageTableRow row = getRow(rowIndex); |
@@ -1080,19 +1088,19 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1080 | 1088 | // 変更通知 |
1081 | 1089 | fireTableRowsUpdated(rowIndex, columnIndex); |
1082 | 1090 | } |
1083 | - | |
1091 | + | |
1084 | 1092 | @Override |
1085 | 1093 | public Class<?> getColumnClass(int columnIndex) { |
1086 | 1094 | Columns column = Columns.values()[columnIndex]; |
1087 | 1095 | return column.getColumnClass(); |
1088 | 1096 | } |
1089 | - | |
1097 | + | |
1090 | 1098 | @Override |
1091 | 1099 | public boolean isCellEditable(int rowIndex, int columnIndex) { |
1092 | 1100 | Columns column = Columns.values()[columnIndex]; |
1093 | 1101 | return column.isEditable(); |
1094 | 1102 | } |
1095 | - | |
1103 | + | |
1096 | 1104 | public void initModel(CharacterData characterData) { |
1097 | 1105 | if (characterData == null) { |
1098 | 1106 | throw new IllegalArgumentException(); |
@@ -1120,7 +1128,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1120 | 1128 | .getPartsSpecMap(partsCategory).entrySet()) { |
1121 | 1129 | PartsIdentifier partsIdentifier = entry.getKey(); |
1122 | 1130 | PartsSpec partsSpec = entry.getValue(); |
1123 | - | |
1131 | + | |
1124 | 1132 | // パーツ管理情報ファイルから、パーツ管理情報を設定した時点の |
1125 | 1133 | // ファイルサイズや更新日時などを読み取る. |
1126 | 1134 | PartsKey partsKey = new PartsKey(partsIdentifier); |
@@ -1147,7 +1155,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1147 | 1155 | * ホームページはAuthorに対して1つであるが、Authorが自由編集可能であるため便宜的にRowに持たせている.<br> |
1148 | 1156 | * 結果として同じAuthorに対して同じ値を設定する必要がある.<br> |
1149 | 1157 | * ホームページはテーブルに表示されないのでリスナーへの通知は行わない.<br> |
1150 | - * | |
1158 | + * | |
1151 | 1159 | * @param author |
1152 | 1160 | * 作者、空またはnullは何もしない. |
1153 | 1161 | * @param homepage |
@@ -1171,7 +1179,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1171 | 1179 | /** |
1172 | 1180 | * ホームページを取得する.<br> |
1173 | 1181 | * 該当する作者がないか、作者がnullまたは空の場合は常にnullを返す.<br> |
1174 | - * | |
1182 | + * | |
1175 | 1183 | * @param author |
1176 | 1184 | * 作者 |
1177 | 1185 | * @return ホームページ、またはnull |
@@ -1191,7 +1199,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1191 | 1199 | } |
1192 | 1200 | return null; |
1193 | 1201 | } |
1194 | - | |
1202 | + | |
1195 | 1203 | protected static final Comparator<PartsManageTableRow> NAMED_SORTER |
1196 | 1204 | = new Comparator<PartsManageTableRow>() { |
1197 | 1205 | public int compare(PartsManageTableRow o1, PartsManageTableRow o2) { |
@@ -1217,12 +1225,12 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan | ||
1217 | 1225 | return ret; |
1218 | 1226 | } |
1219 | 1227 | }; |
1220 | - | |
1228 | + | |
1221 | 1229 | public void sortByName() { |
1222 | 1230 | Collections.sort(elements, NAMED_SORTER); |
1223 | 1231 | fireTableDataChanged(); |
1224 | 1232 | } |
1225 | - | |
1233 | + | |
1226 | 1234 | public void sortByTimestamp() { |
1227 | 1235 | Collections.sort(elements, new Comparator<PartsManageTableRow>() { |
1228 | 1236 | public int compare(PartsManageTableRow o1, PartsManageTableRow o2) { |
@@ -76,6 +76,7 @@ import charactermanaj.model.io.CharacterDataDefaultProvider; | ||
76 | 76 | import charactermanaj.model.io.CharacterDataDefaultProvider.DefaultCharacterDataVersion; |
77 | 77 | import charactermanaj.model.io.CharacterDataPersistent; |
78 | 78 | import charactermanaj.ui.model.AbstractTableModelWithComboBoxModel; |
79 | +import charactermanaj.ui.util.ScaleSupport; | |
79 | 80 | import charactermanaj.util.DesktopUtilities; |
80 | 81 | import charactermanaj.util.ErrorMessageHelper; |
81 | 82 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
@@ -565,6 +566,10 @@ public class ProfileEditDialog extends JDialog { | ||
565 | 566 | colorGroupTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
566 | 567 | colorGroupTable.setRowHeight(colorGroupTable.getRowHeight() + 4); |
567 | 568 | colorGroupTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
569 | + | |
570 | + // 行の高さをフォントの高さにする | |
571 | + colorGroupTable.setRowHeight((int)(colorGroupTable.getFont().getSize() * 1.2)); | |
572 | + | |
568 | 573 | colorGroupPanel.add(new JScrollPane(colorGroupTable), BorderLayout.CENTER); |
569 | 574 | |
570 | 575 | JPanel colorGroupBtnPanel = new JPanel(); |
@@ -677,9 +682,14 @@ public class ProfileEditDialog extends JDialog { | ||
677 | 682 | categoriesTable.setRowHeight(categoriesTable.getRowHeight() + 4); |
678 | 683 | categoriesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
679 | 684 | categoriesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
685 | + | |
686 | + // 行の高さをフォントの高さにする | |
687 | + categoriesTable.setRowHeight((int)(categoriesTable.getFont().getSize() * 1.2)); | |
688 | + | |
680 | 689 | categoriesPanel.add(new JScrollPane(categoriesTable), BorderLayout.CENTER); |
681 | 690 | |
682 | - categoriesTableModel.adjustColumnModel(categoriesTable.getColumnModel()); | |
691 | + ScaleSupport scaleSupprt = ScaleSupport.getInstance(this); | |
692 | + categoriesTableModel.adjustColumnModel(categoriesTable.getColumnModel(), scaleSupprt.getManualScaleX()); | |
683 | 693 | |
684 | 694 | JPanel categoriesBtnPanel = new JPanel(); |
685 | 695 | GridBagLayout categoryBtnPanelLayout = new GridBagLayout(); |
@@ -784,7 +794,8 @@ public class ProfileEditDialog extends JDialog { | ||
784 | 794 | return comp; |
785 | 795 | } |
786 | 796 | }; |
787 | - layersTableModel.adjustColumnModel(layersTable.getColumnModel()); | |
797 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
798 | + layersTableModel.adjustColumnModel(layersTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
788 | 799 | |
789 | 800 | JComboBox colorGroupCombo = new JComboBox( |
790 | 801 | new FirstItemInjectionComboBoxModelWrapper<ColorGroupsTableRow>(colorGroupsTableModel, ColorGroupsTableRow.NA)); |
@@ -801,6 +812,10 @@ public class ProfileEditDialog extends JDialog { | ||
801 | 812 | |
802 | 813 | layersTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
803 | 814 | layersTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
815 | + | |
816 | + // 行の高さをフォントの高さにする | |
817 | + layersTable.setRowHeight((int)(layersTable.getFont().getSize() * 1.2)); | |
818 | + | |
804 | 819 | layersPanel.add(new JScrollPane(layersTable), BorderLayout.CENTER); |
805 | 820 | |
806 | 821 | JPanel layersBtnPanel = new JPanel(); |
@@ -917,7 +932,7 @@ public class ProfileEditDialog extends JDialog { | ||
917 | 932 | return comp; |
918 | 933 | } |
919 | 934 | }; |
920 | - partssetsTableModel.adjustColumnModel(partssetsTable.getColumnModel()); | |
935 | + partssetsTableModel.adjustColumnModel(partssetsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
921 | 936 | |
922 | 937 | partssetsTable.setRowHeight(layersTable.getRowHeight() + 4); |
923 | 938 |
@@ -926,6 +941,10 @@ public class ProfileEditDialog extends JDialog { | ||
926 | 941 | partssetsTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); |
927 | 942 | partssetsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
928 | 943 | partssetsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
944 | + | |
945 | + // 行の高さをフォントの高さにする | |
946 | + partssetsTable.setRowHeight((int)(partssetsTable.getFont().getSize() * 1.2)); | |
947 | + | |
929 | 948 | partssetsPanel.add(new JScrollPane(partssetsTable), BorderLayout.CENTER); |
930 | 949 | |
931 | 950 | // Recommendations |
@@ -950,7 +969,7 @@ public class ProfileEditDialog extends JDialog { | ||
950 | 969 | return comp; |
951 | 970 | } |
952 | 971 | }; |
953 | - recommendationsTableModel.adjustColumnModel(recommendationsTable.getColumnModel()); | |
972 | + recommendationsTableModel.adjustColumnModel(recommendationsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
954 | 973 | |
955 | 974 | recommendationsTable.setRowHeight(layersTable.getRowHeight() + 4); |
956 | 975 |
@@ -960,6 +979,9 @@ public class ProfileEditDialog extends JDialog { | ||
960 | 979 | recommendationsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
961 | 980 | recommendationsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
962 | 981 | |
982 | + // 行の高さをフォントの高さにする | |
983 | + recommendationsTable.setRowHeight((int)(recommendationsTable.getFont().getSize() * 1.2)); | |
984 | + | |
963 | 985 | recommendationsPanel.add(new JScrollPane(recommendationsTable), BorderLayout.CENTER); |
964 | 986 | |
965 | 987 | JPanel recommendationsBtnPanel = new JPanel(); |
@@ -1114,7 +1136,9 @@ public class ProfileEditDialog extends JDialog { | ||
1114 | 1136 | |
1115 | 1137 | contentPane.add(tabbedPane, BorderLayout.CENTER); |
1116 | 1138 | |
1117 | - setSize(500, 500); | |
1139 | + Dimension dim = new Dimension(500, 500); | |
1140 | + dim = scaleSupport.manualScaled(dim); | |
1141 | + setSize(dim); | |
1118 | 1142 | setLocationRelativeTo(parent); |
1119 | 1143 | |
1120 | 1144 | updateUIState(); |
@@ -2157,12 +2181,12 @@ class CategoriesTableModel extends AbstractTableModelWithComboBoxModel<Categorie | ||
2157 | 2181 | public CategoriesTableModel() { |
2158 | 2182 | } |
2159 | 2183 | |
2160 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
2184 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
2161 | 2185 | for (int idx = 0; idx < COLUMNS.length; idx++) { |
2162 | 2186 | ColumnDef columnDef = COLUMNS[idx]; |
2163 | 2187 | String reskey = columnDef.getResourceKey(); |
2164 | 2188 | int width = Integer.parseInt(strings.getProperty(reskey + ".width")); |
2165 | - columnModel.getColumn(idx).setPreferredWidth(width); | |
2189 | + columnModel.getColumn(idx).setPreferredWidth((int)(width * scale)); | |
2166 | 2190 | } |
2167 | 2191 | } |
2168 | 2192 |
@@ -2431,9 +2455,9 @@ class LayersTableModel extends AbstractTableModelWithComboBoxModel<LayersTableRo | ||
2431 | 2455 | super(); |
2432 | 2456 | } |
2433 | 2457 | |
2434 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
2458 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
2435 | 2459 | for (int idx = 0; idx < layersColumnWidths.length; idx++) { |
2436 | - columnModel.getColumn(idx).setPreferredWidth(layersColumnWidths[idx]); | |
2460 | + columnModel.getColumn(idx).setPreferredWidth((int)(layersColumnWidths[idx] * scale)); | |
2437 | 2461 | } |
2438 | 2462 | } |
2439 | 2463 |
@@ -2749,9 +2773,9 @@ class PartssetsTableModel extends AbstractTableModelWithComboBoxModel<PresetsTab | ||
2749 | 2773 | return defaultPartsSetId; |
2750 | 2774 | } |
2751 | 2775 | |
2752 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
2776 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
2753 | 2777 | for (int idx = 0; idx < partssetsColumnWidths.length; idx++) { |
2754 | - columnModel.getColumn(idx).setPreferredWidth(partssetsColumnWidths[idx]); | |
2778 | + columnModel.getColumn(idx).setPreferredWidth((int)(partssetsColumnWidths[idx] * scale)); | |
2755 | 2779 | } |
2756 | 2780 | } |
2757 | 2781 |
@@ -2956,9 +2980,9 @@ class RecommendationTableModel extends AbstractTableModelWithComboBoxModel<Recom | ||
2956 | 2980 | public RecommendationTableModel() { |
2957 | 2981 | } |
2958 | 2982 | |
2959 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
2983 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
2960 | 2984 | for (int idx = 0; idx < partssetsColumnWidths.length; idx++) { |
2961 | - columnModel.getColumn(idx).setPreferredWidth(partssetsColumnWidths[idx]); | |
2985 | + columnModel.getColumn(idx).setPreferredWidth((int)(partssetsColumnWidths[idx] * scale)); | |
2962 | 2986 | } |
2963 | 2987 | } |
2964 | 2988 |
@@ -92,6 +92,7 @@ import charactermanaj.model.io.CustomLayerOrderPersist; | ||
92 | 92 | import charactermanaj.model.io.PartsImageDirectoryWatchAgent; |
93 | 93 | import charactermanaj.model.io.PartsImageDirectoryWatchAgentFactory; |
94 | 94 | import charactermanaj.ui.util.FileDropTarget; |
95 | +import charactermanaj.ui.util.ScaleSupport; | |
95 | 96 | import charactermanaj.ui.util.SingleRootFileSystemView; |
96 | 97 | import charactermanaj.util.DesktopUtilities; |
97 | 98 | import charactermanaj.util.ErrorMessageHelper; |
@@ -233,7 +234,11 @@ public class ProfileSelectorDialog extends JDialog { | ||
233 | 234 | characterList.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
234 | 235 | characterList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
235 | 236 | |
236 | - characterListModel.adjustColumnModel(characterList.getColumnModel()); | |
237 | + // 行の高さをフォントの高さにする | |
238 | + characterList.setRowHeight((int)(characterList.getFont().getSize() * 1.2)); | |
239 | + | |
240 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
241 | + characterListModel.adjustColumnModel(characterList.getColumnModel(), scaleSupport.getManualScaleX()); | |
237 | 242 | |
238 | 243 | characterList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
239 | 244 | characterList.getSelectionModel().addListSelectionListener( |
@@ -556,7 +561,11 @@ public class ProfileSelectorDialog extends JDialog { | ||
556 | 561 | |
557 | 562 | int width = Integer.parseInt(strings.getProperty("windowWidth")); |
558 | 563 | int height = Integer.parseInt(strings.getProperty("windowHeight")); |
559 | - setSize(width, height); | |
564 | + | |
565 | + Dimension dim = new Dimension(width, height); | |
566 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
567 | + dim = scaleSupport.manualScaled(dim); | |
568 | + setSize(dim); | |
560 | 569 | setLocationRelativeTo(parent); |
561 | 570 | |
562 | 571 | characterList.requestFocus(); |
@@ -1469,11 +1478,11 @@ class ProfileSelectorTableModel extends AbstractTableModel { | ||
1469 | 1478 | return rows.size(); |
1470 | 1479 | } |
1471 | 1480 | |
1472 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
1481 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
1473 | 1482 | Columns[] columns = Columns.values(); |
1474 | 1483 | for (int idx = 0; idx < columns.length; idx++) { |
1475 | 1484 | columnModel.getColumn(idx).setPreferredWidth( |
1476 | - columns[idx].getWidth()); | |
1485 | + (int)(columns[idx].getWidth() * scale)); | |
1477 | 1486 | } |
1478 | 1487 | } |
1479 | 1488 |
@@ -2,6 +2,7 @@ package charactermanaj.ui; | ||
2 | 2 | |
3 | 3 | import java.awt.BorderLayout; |
4 | 4 | import java.awt.Container; |
5 | +import java.awt.Dimension; | |
5 | 6 | import java.awt.GridBagConstraints; |
6 | 7 | import java.awt.GridBagLayout; |
7 | 8 | import java.awt.Insets; |
@@ -51,52 +52,53 @@ import charactermanaj.model.PartsSpec; | ||
51 | 52 | import charactermanaj.model.PartsSpecResolver; |
52 | 53 | import charactermanaj.ui.model.AbstractTableModelWithComboBoxModel; |
53 | 54 | import charactermanaj.ui.model.PartsSelectionManager; |
55 | +import charactermanaj.ui.util.ScaleSupport; | |
54 | 56 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
55 | 57 | |
56 | 58 | public class SearchPartsDialog extends JDialog { |
57 | 59 | |
58 | 60 | private static final long serialVersionUID = 1L; |
59 | - | |
60 | - | |
61 | + | |
62 | + | |
61 | 63 | private static final WeakHashMap<SearchPartsDialog, Object> ALL_DIALOGS |
62 | 64 | = new WeakHashMap<SearchPartsDialog, Object>(); |
63 | - | |
64 | - | |
65 | + | |
66 | + | |
65 | 67 | protected static final String STRINGS_RESOURCE = "languages/searchpartsdialog"; |
66 | 68 | |
67 | 69 | private PartsSpecResolver partsSpecResolver; |
68 | - | |
70 | + | |
69 | 71 | private PartsSelectionManager partsSelectionManager; |
70 | - | |
72 | + | |
71 | 73 | private JTable searchPartsTable; |
72 | - | |
73 | - | |
74 | + | |
75 | + | |
74 | 76 | private SearchPartsTableModel searchPartsTableModel; |
75 | - | |
77 | + | |
76 | 78 | private JTextField txtPartsName; |
77 | - | |
79 | + | |
78 | 80 | private JComboBox cmbAuthors; |
79 | - | |
81 | + | |
80 | 82 | private JComboBox cmbCategories; |
81 | - | |
82 | - | |
83 | + | |
84 | + | |
83 | 85 | public static SearchPartsDialog[] getDialogs() { |
84 | 86 | return ALL_DIALOGS.keySet().toArray(new SearchPartsDialog[ALL_DIALOGS.size()]); |
85 | 87 | } |
86 | - | |
87 | - | |
88 | + | |
89 | + | |
88 | 90 | public SearchPartsDialog(JFrame parent, |
89 | 91 | PartsSpecResolver partsSpecResolver, |
90 | 92 | PartsSelectionManager partsSelectionManager) { |
91 | 93 | super(parent, false); |
92 | - | |
94 | + | |
93 | 95 | if (partsSpecResolver == null) { |
94 | 96 | throw new IllegalArgumentException(); |
95 | 97 | } |
96 | 98 | |
97 | 99 | this.partsSpecResolver = partsSpecResolver; |
98 | 100 | this.partsSelectionManager = partsSelectionManager; |
99 | - | |
101 | + | |
100 | 102 | setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); |
101 | 103 | addWindowListener(new WindowAdapter() { |
102 | 104 | @Override |
@@ -104,28 +106,28 @@ public class SearchPartsDialog extends JDialog { | ||
104 | 106 | onClose(); |
105 | 107 | } |
106 | 108 | }); |
107 | - | |
108 | - | |
109 | + | |
110 | + | |
109 | 111 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
110 | 112 | .getLocalizedProperties(STRINGS_RESOURCE); |
111 | 113 | |
112 | 114 | setTitle(strings.getProperty("title")); |
113 | - | |
115 | + | |
114 | 116 | // モデル |
115 | 117 | searchPartsTableModel = new SearchPartsTableModel(); |
116 | - | |
117 | - | |
118 | + | |
119 | + | |
118 | 120 | // 検索条件パネル |
119 | - | |
121 | + | |
120 | 122 | JPanel searchCondPanel = new JPanel(); |
121 | 123 | GridBagLayout searchCondPanelLayout = new GridBagLayout(); |
122 | 124 | searchCondPanel.setLayout(searchCondPanelLayout); |
123 | 125 | GridBagConstraints gbc = new GridBagConstraints(); |
124 | - | |
126 | + | |
125 | 127 | searchCondPanel.setBorder(BorderFactory.createCompoundBorder( |
126 | 128 | BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory |
127 | 129 | .createTitledBorder(strings.getProperty("search.condition")))); |
128 | - | |
130 | + | |
129 | 131 | gbc.gridx = 0; |
130 | 132 | gbc.gridy = 0; |
131 | 133 | gbc.gridheight = 1; |
@@ -138,19 +140,19 @@ public class SearchPartsDialog extends JDialog { | ||
138 | 140 | gbc.weightx = 0.; |
139 | 141 | gbc.weighty = 0.; |
140 | 142 | searchCondPanel.add(new JLabel(strings.getProperty("partsname"), JLabel.RIGHT), gbc); |
141 | - | |
143 | + | |
142 | 144 | gbc.gridx = 1; |
143 | 145 | gbc.gridy = 0; |
144 | 146 | gbc.weightx = 1.; |
145 | 147 | txtPartsName = new JTextField(); |
146 | 148 | searchCondPanel.add(txtPartsName, gbc); |
147 | - | |
149 | + | |
148 | 150 | gbc.gridx = 0; |
149 | 151 | gbc.gridy = 1; |
150 | 152 | gbc.gridwidth = 1; |
151 | 153 | gbc.weightx = 0.; |
152 | 154 | searchCondPanel.add(new JLabel(strings.getProperty("author"), JLabel.RIGHT), gbc); |
153 | - | |
155 | + | |
154 | 156 | gbc.gridx = 1; |
155 | 157 | gbc.gridy = 1; |
156 | 158 | gbc.gridwidth = 2; |
@@ -160,13 +162,13 @@ public class SearchPartsDialog extends JDialog { | ||
160 | 162 | authors.addAll(getAuthors(partsSpecResolver)); |
161 | 163 | cmbAuthors = new JComboBox(authors.toArray(new String[authors.size()])); |
162 | 164 | searchCondPanel.add(cmbAuthors, gbc); |
163 | - | |
165 | + | |
164 | 166 | gbc.gridx = 0; |
165 | 167 | gbc.gridy = 2; |
166 | 168 | gbc.gridwidth = 1; |
167 | 169 | gbc.weightx = 0.; |
168 | 170 | searchCondPanel.add(new JLabel(strings.getProperty("partscategory"), JLabel.RIGHT), gbc); |
169 | - | |
171 | + | |
170 | 172 | gbc.gridx = 1; |
171 | 173 | gbc.gridy = 2; |
172 | 174 | gbc.gridwidth = 2; |
@@ -192,7 +194,7 @@ public class SearchPartsDialog extends JDialog { | ||
192 | 194 | } |
193 | 195 | }); |
194 | 196 | searchCondPanel.add(btnClear, gbc); |
195 | - | |
197 | + | |
196 | 198 | // 検索結果 |
197 | 199 | JPanel searchResult = new JPanel(new BorderLayout()); |
198 | 200 | searchResult.setBorder(BorderFactory.createCompoundBorder( |
@@ -201,8 +203,13 @@ public class SearchPartsDialog extends JDialog { | ||
201 | 203 | searchPartsTable = new JTable(searchPartsTableModel); |
202 | 204 | searchPartsTable.setShowGrid(true); |
203 | 205 | searchPartsTable.setGridColor(AppConfig.getInstance().getGridColor()); |
206 | + | |
207 | + // 行の高さをフォントの高さにする | |
208 | + searchPartsTable.setRowHeight((int)(searchPartsTable.getFont().getSize() * 1.2)); | |
209 | + | |
204 | 210 | JScrollPane searchPartsTableSP = new JScrollPane(searchPartsTable); |
205 | - searchPartsTableModel.adjustColumnModel(searchPartsTable.getColumnModel()); | |
211 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
212 | + searchPartsTableModel.adjustColumnModel(searchPartsTable.getColumnModel(), scaleSupport.getManualScaleX()); | |
206 | 213 | searchResult.add(searchPartsTableSP, BorderLayout.CENTER); |
207 | 214 | searchPartsTable.addMouseListener(new MouseAdapter() { |
208 | 215 | @Override |
@@ -214,7 +221,7 @@ public class SearchPartsDialog extends JDialog { | ||
214 | 221 | } |
215 | 222 | } |
216 | 223 | }); |
217 | - | |
224 | + | |
218 | 225 | // テーブルのキーイベント |
219 | 226 | ActionMap tblAm = searchPartsTable.getActionMap(); |
220 | 227 | InputMap tblIm = searchPartsTable.getInputMap(); |
@@ -225,7 +232,7 @@ public class SearchPartsDialog extends JDialog { | ||
225 | 232 | onSelect(); |
226 | 233 | } |
227 | 234 | }); |
228 | - | |
235 | + | |
229 | 236 | JPanel btnPanel = new JPanel(); |
230 | 237 | btnPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10)); |
231 | 238 | GridBagLayout btnPanelLayout = new GridBagLayout(); |
@@ -255,10 +262,10 @@ public class SearchPartsDialog extends JDialog { | ||
255 | 262 | }); |
256 | 263 | btnPanel.add(btnSelect, gbc); |
257 | 264 | searchResult.add(btnPanel, BorderLayout.SOUTH); |
258 | - | |
259 | - | |
265 | + | |
266 | + | |
260 | 267 | // 検索条件の入力が変更されたことを検知するリスナの登録 |
261 | - | |
268 | + | |
262 | 269 | txtPartsName.getDocument().addDocumentListener(new DocumentListener() { |
263 | 270 | public void removeUpdate(DocumentEvent e) { |
264 | 271 | onChangeCondition(); |
@@ -270,7 +277,7 @@ public class SearchPartsDialog extends JDialog { | ||
270 | 277 | onChangeCondition(); |
271 | 278 | } |
272 | 279 | }); |
273 | - | |
280 | + | |
274 | 281 | ActionListener changeListener = new ActionListener() { |
275 | 282 | public void actionPerformed(ActionEvent e) { |
276 | 283 | onChangeCondition(); |
@@ -278,7 +285,7 @@ public class SearchPartsDialog extends JDialog { | ||
278 | 285 | }; |
279 | 286 | cmbAuthors.addActionListener(changeListener); |
280 | 287 | cmbCategories.addActionListener(changeListener); |
281 | - | |
288 | + | |
282 | 289 | // ESCキーとCTRL-Wで閉じる. |
283 | 290 | Toolkit tk = Toolkit.getDefaultToolkit(); |
284 | 291 | JRootPane rootPane = getRootPane(); |
@@ -292,7 +299,7 @@ public class SearchPartsDialog extends JDialog { | ||
292 | 299 | onClose(); |
293 | 300 | } |
294 | 301 | }); |
295 | - | |
302 | + | |
296 | 303 | // ウィンドウがアクティブになったときに検索フィールドにフォーカスをあてる |
297 | 304 | addWindowFocusListener(new WindowAdapter() { |
298 | 305 | public void windowGainedFocus(WindowEvent e) { |
@@ -305,14 +312,17 @@ public class SearchPartsDialog extends JDialog { | ||
305 | 312 | contentPane.setLayout(new BorderLayout()); |
306 | 313 | contentPane.add(searchCondPanel, BorderLayout.NORTH); |
307 | 314 | contentPane.add(searchResult, BorderLayout.CENTER); |
308 | - | |
309 | - setSize(250, 300); | |
315 | + | |
316 | + Dimension dim = new Dimension(250, 300); | |
317 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
318 | + dim = scaleSupport.manualScaled(dim); | |
319 | + setSize(dim); | |
310 | 320 | setLocationRelativeTo(parent); |
311 | - | |
321 | + | |
312 | 322 | // ダイアログの登録 |
313 | 323 | ALL_DIALOGS.put(this, null); |
314 | 324 | } |
315 | - | |
325 | + | |
316 | 326 | public List<String> getAuthors(PartsSpecResolver partsSpecResolver) { |
317 | 327 | if (partsSpecResolver == null) { |
318 | 328 | throw new IllegalArgumentException(); |
@@ -327,16 +337,16 @@ public class SearchPartsDialog extends JDialog { | ||
327 | 337 | } |
328 | 338 | } |
329 | 339 | } |
330 | - | |
331 | - ArrayList<String> authors = new ArrayList<String>(authorsSet); | |
340 | + | |
341 | + ArrayList<String> authors = new ArrayList<String>(authorsSet); | |
332 | 342 | Collections.sort(authors); |
333 | 343 | return authors; |
334 | 344 | } |
335 | - | |
345 | + | |
336 | 346 | protected void onClose() { |
337 | 347 | dispose(); |
338 | 348 | } |
339 | - | |
349 | + | |
340 | 350 | /** |
341 | 351 | * 「選択」ボタンまたはテーブルのダブルクリックのハンドラ.<br> |
342 | 352 | * 選択されている行のパーツ識別子をもとに、パーツにフォーカスをあてる.<br> |
@@ -349,20 +359,20 @@ public class SearchPartsDialog extends JDialog { | ||
349 | 359 | partsSelectionManager.setSelection(partsIdentifier); |
350 | 360 | } |
351 | 361 | } |
352 | - | |
362 | + | |
353 | 363 | protected void onChangeCondition() { |
354 | 364 | String partsNamesRaw = txtPartsName.getText(); |
355 | 365 | partsNamesRaw = partsNamesRaw.replace(" ", " "); // 全角空白を半角に変換 |
356 | 366 | String[] condPartsNames = partsNamesRaw.split("\\s+"); |
357 | - | |
367 | + | |
358 | 368 | PartsCategory condPartsCategory = (PartsCategory) cmbCategories.getSelectedItem(); |
359 | 369 | String condAuthor = (String) cmbAuthors.getSelectedItem(); |
360 | 370 | if (condAuthor != null && condAuthor.trim().length() == 0) { |
361 | 371 | condAuthor = null; |
362 | 372 | } |
363 | - | |
373 | + | |
364 | 374 | ArrayList<Map.Entry<PartsIdentifier, PartsSpec>> partsIdentifiers = new ArrayList<Map.Entry<PartsIdentifier, PartsSpec>>(); |
365 | - | |
375 | + | |
366 | 376 | for (PartsCategory partsCategory : partsSpecResolver.getPartsCategories()) { |
367 | 377 | if (condPartsCategory != null && !condPartsCategory.equals(partsCategory)) { |
368 | 378 | continue; |
@@ -397,7 +407,7 @@ public class SearchPartsDialog extends JDialog { | ||
397 | 407 | }); |
398 | 408 | searchPartsTableModel.initModel(partsIdentifiers); |
399 | 409 | } |
400 | - | |
410 | + | |
401 | 411 | } |
402 | 412 | |
403 | 413 | class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entry<PartsIdentifier, PartsSpec>> { |
@@ -405,13 +415,13 @@ class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entr | ||
405 | 415 | private static final long serialVersionUID = 1L; |
406 | 416 | |
407 | 417 | private static final String[] COLUMN_NAMES; |
408 | - | |
418 | + | |
409 | 419 | private static final int[] COLUMN_WIDTHS; |
410 | - | |
420 | + | |
411 | 421 | static { |
412 | 422 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
413 | 423 | .getLocalizedProperties(SearchPartsDialog.STRINGS_RESOURCE); |
414 | - | |
424 | + | |
415 | 425 | COLUMN_NAMES = new String[] { |
416 | 426 | strings.getProperty("column.partsname"), |
417 | 427 | strings.getProperty("column.category"), |
@@ -423,28 +433,28 @@ class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entr | ||
423 | 433 | Integer.parseInt(strings.getProperty("column.author.width")), |
424 | 434 | }; |
425 | 435 | } |
426 | - | |
427 | - public void adjustColumnModel(TableColumnModel columnModel) { | |
436 | + | |
437 | + public void adjustColumnModel(TableColumnModel columnModel, double scale) { | |
428 | 438 | for (int idx = 0; idx < COLUMN_WIDTHS.length; idx++) { |
429 | - columnModel.getColumn(idx).setPreferredWidth(COLUMN_WIDTHS[idx]); | |
439 | + columnModel.getColumn(idx).setPreferredWidth((int)(COLUMN_WIDTHS[idx] * scale)); | |
430 | 440 | } |
431 | 441 | } |
432 | - | |
442 | + | |
433 | 443 | public int getColumnCount() { |
434 | 444 | return COLUMN_NAMES.length; |
435 | 445 | } |
436 | - | |
446 | + | |
437 | 447 | @Override |
438 | 448 | public String getColumnName(int column) { |
439 | 449 | return COLUMN_NAMES[column]; |
440 | 450 | } |
441 | - | |
451 | + | |
442 | 452 | public Object getValueAt(int rowIndex, int columnIndex) { |
443 | 453 | Map.Entry<PartsIdentifier, PartsSpec> row = getRow(rowIndex); |
444 | - | |
454 | + | |
445 | 455 | PartsIdentifier partsIdentifier = row.getKey(); |
446 | 456 | PartsSpec partsSpec = row.getValue(); |
447 | - | |
457 | + | |
448 | 458 | switch (columnIndex) { |
449 | 459 | case 0: |
450 | 460 | return partsIdentifier.getLocalizedPartsName(); |
@@ -455,7 +465,7 @@ class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entr | ||
455 | 465 | } |
456 | 466 | return ""; |
457 | 467 | } |
458 | - | |
468 | + | |
459 | 469 | public void initModel(List<Map.Entry<PartsIdentifier, PartsSpec>> partsIdentifiers) { |
460 | 470 | clear(); |
461 | 471 | if (partsIdentifiers != null) { |
@@ -464,6 +474,6 @@ class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entr | ||
464 | 474 | } |
465 | 475 | } |
466 | 476 | } |
467 | - | |
477 | + | |
468 | 478 | } |
469 | 479 |
@@ -1,6 +1,5 @@ | ||
1 | 1 | package charactermanaj.ui; |
2 | 2 | |
3 | -import java.awt.BorderLayout; | |
4 | 3 | import java.awt.Container; |
5 | 4 | import java.awt.Dimension; |
6 | 5 | import java.awt.Font; |
@@ -26,6 +25,7 @@ import java.util.logging.Logger; | ||
26 | 25 | import javax.swing.AbstractAction; |
27 | 26 | import javax.swing.BorderFactory; |
28 | 27 | import javax.swing.Box; |
28 | +import javax.swing.BoxLayout; | |
29 | 29 | import javax.swing.InputMap; |
30 | 30 | import javax.swing.JButton; |
31 | 31 | import javax.swing.JCheckBox; |
@@ -42,6 +42,7 @@ import javax.swing.KeyStroke; | ||
42 | 42 | import charactermanaj.Main; |
43 | 43 | import charactermanaj.model.io.WorkingSetPersist; |
44 | 44 | import charactermanaj.ui.util.FileDropTarget; |
45 | +import charactermanaj.ui.util.ScaleSupport; | |
45 | 46 | import charactermanaj.util.ErrorMessageHelper; |
46 | 47 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
47 | 48 | import charactermanaj.util.UIHelper; |
@@ -144,9 +145,6 @@ public class SelectCharatersDirDialog extends JDialog { | ||
144 | 145 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
145 | 146 | .getLocalizedProperties("languages/selectCharatersDirDialog"); |
146 | 147 | |
147 | - Container contentPane = getContentPane(); | |
148 | - contentPane.setLayout(new BorderLayout(3, 3)); | |
149 | - | |
150 | 148 | AbstractAction actOk = new AbstractAction(strings.getProperty("btn.ok")) { |
151 | 149 | private static final long serialVersionUID = 1L; |
152 | 150 | public void actionPerformed(ActionEvent e) { |
@@ -213,108 +211,82 @@ public class SelectCharatersDirDialog extends JDialog { | ||
213 | 211 | btnCancel.addFocusListener(focusAdapter); |
214 | 212 | btnBroseForDir.addFocusListener(focusAdapter); |
215 | 213 | |
214 | + Container contentPane = getContentPane(); | |
215 | + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); | |
216 | + | |
217 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
218 | + | |
219 | + { | |
220 | + JLabel lbl = new JLabel(strings.getProperty("caption")); | |
221 | + lbl.setFont(lbl.getFont().deriveFont(Font.BOLD)); | |
222 | + lbl.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); | |
223 | + Dimension dim = lbl.getPreferredSize(); | |
224 | + dim.width = Integer.parseInt(strings.getProperty("width")); | |
225 | + dim = scaleSupport.manualScaled(dim); | |
226 | + lbl.setPreferredSize(dim); | |
227 | + Box header = Box.createHorizontalBox(); | |
228 | + header.add(lbl); | |
229 | + contentPane.add(header); | |
230 | + } | |
231 | + { | |
232 | + JPanel dirPanel = new JPanel(new GridBagLayout()); | |
233 | + dirPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 3)); | |
234 | + | |
235 | + combDir = new JComboBox(); | |
236 | + combDir.setEditable(true); | |
237 | + | |
238 | + GridBagConstraints gbc = new GridBagConstraints(); | |
239 | + gbc.gridx = 0; | |
240 | + gbc.gridy = 0; | |
241 | + gbc.insets = new Insets(3, 3, 3, 3); | |
242 | + dirPanel.add(new JLabel(strings.getProperty("lbl.dir")), gbc); | |
243 | + | |
244 | + gbc.gridx = 1; | |
245 | + gbc.fill = GridBagConstraints.BOTH; | |
246 | + gbc.weightx = 1; | |
247 | + dirPanel.add(combDir, gbc); | |
248 | + | |
249 | + gbc.gridx = 2; | |
250 | + gbc.weightx = 0; | |
251 | + dirPanel.add(btnBroseForDir, gbc); | |
252 | + | |
253 | + // リサイズ時に開く余白部 | |
254 | + gbc.gridx = 0; | |
255 | + gbc.gridy = 1; | |
256 | + gbc.weighty = 1; | |
257 | + dirPanel.add(Box.createGlue(), gbc); | |
258 | + contentPane.add(dirPanel); | |
259 | + } | |
216 | 260 | |
217 | - JPanel dirPanel = new JPanel(new BorderLayout(3, 3)); | |
218 | - dirPanel.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 3)); | |
219 | - | |
220 | - JLabel lbl = new JLabel(strings.getProperty("caption"), JLabel.CENTER); | |
221 | - lbl.setFont(lbl.getFont().deriveFont(Font.BOLD)); | |
222 | - lbl.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); | |
223 | - Dimension dim = lbl.getPreferredSize(); | |
224 | - dim.width = Integer.parseInt(strings.getProperty("width")); | |
225 | - lbl.setPreferredSize(dim); | |
226 | - dirPanel.add(lbl, BorderLayout.NORTH); | |
227 | - | |
228 | - combDir = new JComboBox(); | |
229 | - combDir.setEditable(true); | |
230 | - | |
231 | - dirPanel.add(combDir, BorderLayout.CENTER); | |
232 | - | |
233 | - dirPanel.add(new JLabel(strings.getProperty("lbl.dir")), BorderLayout.WEST); | |
234 | - dirPanel.add(btnBroseForDir, BorderLayout.EAST); | |
235 | - | |
236 | - contentPane.add(dirPanel, BorderLayout.NORTH); | |
237 | - | |
238 | - JPanel btnPanel = new JPanel(); | |
239 | - GridBagLayout gbl = new GridBagLayout(); | |
240 | - btnPanel.setLayout(gbl); | |
241 | - | |
242 | - chkDoNotAsk = new JCheckBox(strings.getProperty("chk.doNotAskAgein")); | |
243 | - chkDoNotAsk.setSelected(recentCharactersDir.isDoNotAskAgain()); | |
244 | - | |
245 | - GridBagConstraints gbc = new GridBagConstraints(); | |
246 | - gbc.gridx = 0; | |
247 | - gbc.gridy = 0; | |
248 | - gbc.gridwidth = 5; | |
249 | - gbc.gridheight = 1; | |
250 | - gbc.weightx = 1.; | |
251 | - gbc.weighty = 0.; | |
252 | - gbc.fill = GridBagConstraints.BOTH; | |
253 | - gbc.anchor = GridBagConstraints.WEST; | |
254 | - gbc.ipadx = 0; | |
255 | - gbc.ipady = 0; | |
256 | - gbc.insets = new Insets(3, 3, 3, 3); | |
257 | - | |
258 | - btnPanel.add(chkDoNotAsk, gbc); | |
259 | - | |
260 | - gbc.gridx = 0; | |
261 | - gbc.gridy = 1; | |
262 | - gbc.gridwidth = 1; | |
263 | - gbc.gridheight = 1; | |
264 | - gbc.weightx = 0.; | |
265 | - gbc.weighty = 0.; | |
266 | - btnPanel.add(btnRemoveRecent, gbc); | |
267 | - | |
268 | - gbc.gridx = 1; | |
269 | - gbc.gridy = 1; | |
270 | - gbc.gridwidth = 1; | |
271 | - gbc.gridheight = 1; | |
272 | - gbc.weightx = 0.; | |
273 | - gbc.weighty = 0.; | |
274 | - btnPanel.add(btnRemoveWorkingSets, gbc); | |
275 | - | |
276 | - gbc.gridx = 2; | |
277 | - gbc.gridy = 1; | |
278 | - gbc.gridwidth = 1; | |
279 | - gbc.gridheight = 1; | |
280 | - gbc.weightx = 1.; | |
281 | - gbc.weighty = 0.; | |
282 | - | |
283 | - btnPanel.add(Box.createGlue(), gbc); | |
284 | - | |
285 | - gbc.gridx = Main.isLinuxOrMacOSX() ? 4 : 3; | |
286 | - gbc.gridy = 1; | |
287 | - gbc.gridwidth = 1; | |
288 | - gbc.gridheight = 1; | |
289 | - gbc.weightx = 0.; | |
290 | - gbc.weighty = 0.; | |
291 | - | |
292 | - btnPanel.add(btnOK, gbc); | |
293 | - | |
294 | - | |
295 | - gbc.gridx = Main.isLinuxOrMacOSX() ? 3 : 4; | |
296 | - gbc.gridy = 1; | |
297 | - gbc.gridwidth = 1; | |
298 | - gbc.gridheight = 1; | |
299 | - gbc.weightx = 0.; | |
300 | - gbc.weighty = 0.; | |
301 | - btnPanel.add(btnCancel, gbc); | |
302 | - | |
303 | - gbc.gridx = 5; | |
304 | - gbc.gridy = 1; | |
305 | - gbc.gridwidth = 1; | |
306 | - gbc.gridheight = 1; | |
307 | - gbc.weightx = 0.; | |
308 | - gbc.weighty = 0.; | |
309 | - gbc.ipadx = 32; | |
310 | - gbc.ipady = 0; | |
311 | - | |
312 | - btnPanel.add(Box.createGlue(), gbc); | |
261 | + { | |
262 | + chkDoNotAsk = new JCheckBox(strings.getProperty("chk.doNotAskAgein")); | |
263 | + chkDoNotAsk.setSelected(recentCharactersDir.isDoNotAskAgain()); | |
313 | 264 | |
314 | - setTitle(strings.getProperty("title")); | |
315 | - setResizable(false); | |
265 | + Box chkPanel = Box.createHorizontalBox(); | |
266 | + chkPanel.add(chkDoNotAsk); | |
267 | + chkPanel.add(Box.createHorizontalGlue()); | |
268 | + contentPane.add(chkPanel); | |
269 | + } | |
316 | 270 | |
317 | - contentPane.add(btnPanel, BorderLayout.SOUTH); | |
271 | + { | |
272 | + Box btnsBox = Box.createHorizontalBox(); | |
273 | + btnsBox.add(btnRemoveRecent); | |
274 | + btnsBox.add(btnRemoveWorkingSets); | |
275 | + btnsBox.add(Box.createHorizontalGlue()); | |
276 | + | |
277 | + if (!Main.isLinuxOrMacOSX()) { | |
278 | + btnsBox.add(btnOK); | |
279 | + btnsBox.add(btnCancel); | |
280 | + } else { | |
281 | + btnsBox.add(btnCancel); | |
282 | + btnsBox.add(btnOK); | |
283 | + } | |
284 | + btnsBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 24)); | |
285 | + contentPane.add(btnsBox); | |
286 | + } | |
287 | + | |
288 | + setTitle(strings.getProperty("title")); | |
289 | + setResizable(true); | |
318 | 290 | |
319 | 291 | // フォルダのドロップによる入力を許可 |
320 | 292 | new DropTarget(this, new FileDropTarget() { |
@@ -3,6 +3,7 @@ package charactermanaj.ui; | ||
3 | 3 | import java.awt.BorderLayout; |
4 | 4 | import java.awt.Color; |
5 | 5 | import java.awt.Container; |
6 | +import java.awt.Dimension; | |
6 | 7 | import java.awt.GridBagConstraints; |
7 | 8 | import java.awt.GridBagLayout; |
8 | 9 | import java.awt.Insets; |
@@ -38,6 +39,7 @@ import javax.swing.event.ChangeListener; | ||
38 | 39 | |
39 | 40 | import charactermanaj.Main; |
40 | 41 | import charactermanaj.graphics.io.UkagakaImageConverter; |
42 | +import charactermanaj.ui.util.ScaleSupport; | |
41 | 43 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
42 | 44 | |
43 | 45 | /** |
@@ -57,23 +59,23 @@ public class UkagakaConvertDialog extends JDialog { | ||
57 | 59 | * キャプション |
58 | 60 | */ |
59 | 61 | private TextField caption = new TextField(); |
60 | - | |
62 | + | |
61 | 63 | /** |
62 | 64 | * キャンセル |
63 | 65 | */ |
64 | 66 | private AbstractAction actCancel; |
65 | - | |
67 | + | |
66 | 68 | /** |
67 | 69 | * 保存(デフォルトアクション) |
68 | 70 | */ |
69 | 71 | private AbstractAction actSave; |
70 | - | |
72 | + | |
71 | 73 | |
72 | 74 | /** |
73 | 75 | * プレビュー(PNG) |
74 | 76 | */ |
75 | 77 | private SamplePicturePanel opaqueImagePanel = new SamplePicturePanel(); |
76 | - | |
78 | + | |
77 | 79 | /** |
78 | 80 | * プレビュー(PNA) |
79 | 81 | */ |
@@ -83,17 +85,17 @@ public class UkagakaConvertDialog extends JDialog { | ||
83 | 85 | * 透過色キー表示ボックス |
84 | 86 | */ |
85 | 87 | private ColorBox colorBox = new ColorBox(); |
86 | - | |
88 | + | |
87 | 89 | /** |
88 | 90 | * エクスポート対象の元イメージ. |
89 | 91 | */ |
90 | 92 | private BufferedImage originalImage; |
91 | - | |
93 | + | |
92 | 94 | /** |
93 | 95 | * 透過色をマニュアルとするか? |
94 | 96 | */ |
95 | 97 | private boolean manualTransparentColorKey; |
96 | - | |
98 | + | |
97 | 99 | /** |
98 | 100 | * 透過キー自動モード |
99 | 101 | */ |
@@ -103,27 +105,27 @@ public class UkagakaConvertDialog extends JDialog { | ||
103 | 105 | * 透過キー手動選択モード |
104 | 106 | */ |
105 | 107 | private JRadioButton radioManual; |
106 | - | |
108 | + | |
107 | 109 | /** |
108 | 110 | * 上書きモードチェックボックス |
109 | 111 | */ |
110 | 112 | private JCheckBox chkOverwriteOption; |
111 | - | |
113 | + | |
112 | 114 | /** |
113 | 115 | * 終了コード |
114 | 116 | */ |
115 | 117 | private Object result; |
116 | - | |
118 | + | |
117 | 119 | /** |
118 | 120 | * 保存ボタンアクションリスナ.<br> |
119 | 121 | */ |
120 | 122 | private ActionListener saveActionListener; |
121 | - | |
123 | + | |
122 | 124 | /** |
123 | 125 | * 上書きオプションの表示フラグ |
124 | 126 | */ |
125 | 127 | private boolean showOverwriteOption; |
126 | - | |
128 | + | |
127 | 129 | |
128 | 130 | /** |
129 | 131 | * 伺か用PNG/PNA出力設定ダイアログを構築する. |
@@ -132,11 +134,11 @@ public class UkagakaConvertDialog extends JDialog { | ||
132 | 134 | public UkagakaConvertDialog(JFrame parent) { |
133 | 135 | this(parent, false); |
134 | 136 | } |
135 | - | |
137 | + | |
136 | 138 | /** |
137 | 139 | * 伺か用PNG/PNA出力設定ダイアログを構築する. |
138 | 140 | * @param parent 親フレーム |
139 | - * @param overwriteOption 上書きオプションの表示 | |
141 | + * @param overwriteOption 上書きオプションの表示 | |
140 | 142 | */ |
141 | 143 | public UkagakaConvertDialog(JFrame parent, boolean overwriteOption) { |
142 | 144 | this(parent, null, overwriteOption); |
@@ -146,7 +148,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
146 | 148 | * 伺か用PNG/PNA出力設定ダイアログを構築する. |
147 | 149 | * @param parent 親フレーム |
148 | 150 | * @param saveActionListener 保存ボタンアクション |
149 | - * @param overwriteOption 上書きオプションの表示 | |
151 | + * @param overwriteOption 上書きオプションの表示 | |
150 | 152 | */ |
151 | 153 | public UkagakaConvertDialog(JFrame parent, ActionListener saveActionListener, boolean overwriteOption) { |
152 | 154 | super(parent, true); |
@@ -163,7 +165,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
163 | 165 | result = null; |
164 | 166 | } |
165 | 167 | }); |
166 | - | |
168 | + | |
167 | 169 | try { |
168 | 170 | initComponent(); |
169 | 171 |
@@ -177,7 +179,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
177 | 179 | * コンポーネントの初期化 |
178 | 180 | */ |
179 | 181 | private void initComponent() { |
180 | - | |
182 | + | |
181 | 183 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
182 | 184 | .getLocalizedProperties(STRINGS_RESOURCE); |
183 | 185 |
@@ -197,7 +199,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
197 | 199 | onSave(); |
198 | 200 | } |
199 | 201 | }; |
200 | - | |
202 | + | |
201 | 203 | JButton btnCancel = new JButton(actCancel); |
202 | 204 | JButton btnSave = new JButton(actSave); |
203 | 205 |
@@ -207,18 +209,18 @@ public class UkagakaConvertDialog extends JDialog { | ||
207 | 209 | contentPane.add(caption, BorderLayout.NORTH); |
208 | 210 | caption.setEditable(false); |
209 | 211 | caption.setVisible(false); |
210 | - | |
212 | + | |
211 | 213 | JScrollPane opaqueSp = new JScrollPane(opaqueImagePanel); |
212 | 214 | JScrollPane alphaSp = new JScrollPane(alphaImagePanel); |
213 | 215 | |
214 | 216 | JPanel previewSpPane = new JPanel(); |
215 | 217 | BoxLayout boxlayout = new BoxLayout(previewSpPane, BoxLayout.LINE_AXIS); |
216 | 218 | previewSpPane.setLayout(boxlayout); |
217 | - | |
219 | + | |
218 | 220 | previewSpPane.add(opaqueSp); |
219 | 221 | previewSpPane.add(Box.createHorizontalStrut(3)); |
220 | 222 | previewSpPane.add(alphaSp); |
221 | - | |
223 | + | |
222 | 224 | previewSpPane.setBorder(BorderFactory.createCompoundBorder( |
223 | 225 | BorderFactory.createTitledBorder(strings.getProperty("preview")), |
224 | 226 | BorderFactory.createEmptyBorder(3, 3, 3, 3) |
@@ -235,10 +237,10 @@ public class UkagakaConvertDialog extends JDialog { | ||
235 | 237 | BorderFactory.createEmptyBorder(3, 3, 3, 3) |
236 | 238 | )); |
237 | 239 | centerPane.add(transparentColorPanel, BorderLayout.SOUTH); |
238 | - | |
239 | - | |
240 | + | |
241 | + | |
240 | 242 | GridBagConstraints gbc = new GridBagConstraints(); |
241 | - | |
243 | + | |
242 | 244 | radioAuto = new JRadioButton(strings.getProperty("radio.auto")); |
243 | 245 | radioAuto.addChangeListener(new ChangeListener() { |
244 | 246 | public void stateChanged(ChangeEvent e) { |
@@ -251,13 +253,13 @@ public class UkagakaConvertDialog extends JDialog { | ||
251 | 253 | onChange(!radioAuto.isSelected()); |
252 | 254 | } |
253 | 255 | }); |
254 | - | |
256 | + | |
255 | 257 | ButtonGroup btngroup = new ButtonGroup(); |
256 | 258 | btngroup.add(radioAuto); |
257 | 259 | btngroup.add(radioManual); |
258 | - | |
260 | + | |
259 | 261 | radioAuto.setSelected(!manualTransparentColorKey); |
260 | - | |
262 | + | |
261 | 263 | gbc.gridx = 0; |
262 | 264 | gbc.gridy = 0; |
263 | 265 | gbc.gridheight = 1; |
@@ -277,14 +279,14 @@ public class UkagakaConvertDialog extends JDialog { | ||
277 | 279 | gbc.gridy = 0; |
278 | 280 | transparentColorPanel.add(colorBox, gbc); |
279 | 281 | |
280 | - | |
282 | + | |
281 | 283 | contentPane.add(centerPane, BorderLayout.CENTER); |
282 | - | |
283 | - | |
284 | + | |
285 | + | |
284 | 286 | JPanel btnPanel = new JPanel(); |
285 | 287 | GridBagLayout gbl = new GridBagLayout(); |
286 | 288 | btnPanel.setLayout(gbl); |
287 | - | |
289 | + | |
288 | 290 | gbc.gridx = 0; |
289 | 291 | gbc.gridy = 0; |
290 | 292 | gbc.gridheight = 1; |
@@ -294,44 +296,50 @@ public class UkagakaConvertDialog extends JDialog { | ||
294 | 296 | gbc.insets = new Insets(3, 3, 3, 3); |
295 | 297 | gbc.anchor = GridBagConstraints.WEST; |
296 | 298 | gbc.fill = GridBagConstraints.BOTH; |
297 | - | |
299 | + | |
298 | 300 | chkOverwriteOption = new JCheckBox(strings.getProperty("chk.overwriteOriginalFile")); |
299 | - | |
301 | + | |
300 | 302 | if (showOverwriteOption) { |
301 | 303 | btnPanel.add(chkOverwriteOption, gbc); |
302 | 304 | |
303 | 305 | } else { |
304 | 306 | btnPanel.add(Box.createHorizontalGlue(), gbc); |
305 | 307 | } |
306 | - | |
308 | + | |
307 | 309 | gbc.gridx = Main.isLinuxOrMacOSX() ? 2 : 1; |
308 | 310 | gbc.gridy = 0; |
309 | 311 | gbc.weightx = 0.; |
310 | 312 | btnPanel.add(btnSave, gbc); |
311 | - | |
313 | + | |
312 | 314 | gbc.gridx = Main.isLinuxOrMacOSX() ? 1 : 2; |
313 | 315 | gbc.gridy = 0; |
314 | 316 | btnPanel.add(btnCancel, gbc); |
315 | - | |
317 | + | |
316 | 318 | btnPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 45)); |
317 | - | |
319 | + | |
318 | 320 | contentPane.add(btnPanel, BorderLayout.SOUTH); |
319 | - | |
321 | + | |
320 | 322 | JRootPane rootPane = getRootPane(); |
321 | 323 | InputMap im = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); |
322 | 324 | ActionMap am = rootPane.getActionMap(); |
323 | 325 | im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "closeExportWizDialog"); |
324 | 326 | im.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, tk.getMenuShortcutKeyMask()), "closeExportWizDialog"); |
325 | - | |
327 | + | |
326 | 328 | am.put("closeExportWizDialog", actCancel); |
327 | - | |
329 | + | |
328 | 330 | rootPane.setDefaultButton(btnSave); |
329 | - | |
331 | + | |
330 | 332 | rootPane.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); |
331 | 333 | |
332 | - setSize(450, 450); | |
334 | + Dimension dim = new Dimension(450, 450); | |
335 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
336 | + if (scaleSupport != null) { | |
337 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
338 | + dim = scaleSupport.manualScaled(dim); | |
339 | + } | |
340 | + setSize(dim); | |
333 | 341 | setLocationRelativeTo(getParent()); |
334 | - | |
342 | + | |
335 | 343 | // colorBoxの色変更イベントのハンドル |
336 | 344 | colorBox.addActionListener(new ActionListener() { |
337 | 345 | public void actionPerformed(ActionEvent e) { |
@@ -339,7 +347,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
339 | 347 | } |
340 | 348 | }); |
341 | 349 | } |
342 | - | |
350 | + | |
343 | 351 | /** |
344 | 352 | * 出力するイメージを設定する. |
345 | 353 | * @param img イメージ(TYPE_INT_ARGBのみ) |
@@ -352,7 +360,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
352 | 360 | if (img.getType() != BufferedImage.TYPE_INT_ARGB) { |
353 | 361 | throw new IllegalArgumentException("TYPE_INT_ARGB以外は指定できません。"); |
354 | 362 | } |
355 | - | |
363 | + | |
356 | 364 | if (colorKey == null) { |
357 | 365 | colorKey = Color.GREEN; |
358 | 366 | } |
@@ -362,15 +370,15 @@ public class UkagakaConvertDialog extends JDialog { | ||
362 | 370 | |
363 | 371 | rebuildImage(); |
364 | 372 | } |
365 | - | |
373 | + | |
366 | 374 | public BufferedImage getOpaqueImage() { |
367 | 375 | return opaqueImagePanel.getSamplePictrue(); |
368 | 376 | } |
369 | - | |
377 | + | |
370 | 378 | public BufferedImage getAlphaImage() { |
371 | 379 | return alphaImagePanel.getSamplePictrue(); |
372 | 380 | } |
373 | - | |
381 | + | |
374 | 382 | public void setAutoTransparentColor(boolean mode) { |
375 | 383 | if (mode) { |
376 | 384 | radioAuto.setSelected(true); |
@@ -381,55 +389,55 @@ public class UkagakaConvertDialog extends JDialog { | ||
381 | 389 | radioAuto.setSelected(false); |
382 | 390 | } |
383 | 391 | } |
384 | - | |
392 | + | |
385 | 393 | public Color getTransparentColorKey() { |
386 | 394 | return colorBox.getColorKey(); |
387 | 395 | } |
388 | - | |
396 | + | |
389 | 397 | public void setTransparentColorKey(Color colorKey) { |
390 | 398 | colorBox.setColorKey(colorKey); |
391 | 399 | } |
392 | - | |
400 | + | |
393 | 401 | public boolean isAutoTransparentColor() { |
394 | 402 | return radioAuto.isSelected(); |
395 | 403 | } |
396 | - | |
404 | + | |
397 | 405 | public boolean isOverwriteOriginalFile() { |
398 | 406 | return chkOverwriteOption.isSelected(); |
399 | 407 | } |
400 | - | |
408 | + | |
401 | 409 | public void setOverwriteOriginalFile(boolean overwriteOriginalFile) { |
402 | 410 | chkOverwriteOption.setSelected(overwriteOriginalFile); |
403 | 411 | } |
404 | - | |
412 | + | |
405 | 413 | protected void onClose() { |
406 | 414 | result = null; |
407 | 415 | dispose(); |
408 | 416 | } |
409 | - | |
417 | + | |
410 | 418 | protected void onSave() { |
411 | 419 | if (saveActionListener != null) { |
412 | 420 | ActionEvent e = new ActionEvent(this, 0, "save"); |
413 | 421 | saveActionListener.actionPerformed(e); |
414 | 422 | } |
415 | 423 | } |
416 | - | |
424 | + | |
417 | 425 | public void setSaveActionListener(ActionListener saveActionListener) { |
418 | 426 | this.saveActionListener = saveActionListener; |
419 | 427 | } |
420 | - | |
428 | + | |
421 | 429 | public ActionListener getSaveActionListener() { |
422 | 430 | return saveActionListener; |
423 | 431 | } |
424 | - | |
432 | + | |
425 | 433 | public Object getResult() { |
426 | 434 | return result; |
427 | 435 | } |
428 | - | |
436 | + | |
429 | 437 | public void setResult(Object result) { |
430 | - this.result = result; | |
438 | + this.result = result; | |
431 | 439 | } |
432 | - | |
440 | + | |
433 | 441 | public void setCaption(String text) { |
434 | 442 | if (text == null || text.length() == 0) { |
435 | 443 | caption.setText(""); |
@@ -440,11 +448,11 @@ public class UkagakaConvertDialog extends JDialog { | ||
440 | 448 | caption.setVisible(true); |
441 | 449 | } |
442 | 450 | } |
443 | - | |
451 | + | |
444 | 452 | public String getCaption() { |
445 | 453 | return caption.getText(); |
446 | 454 | } |
447 | - | |
455 | + | |
448 | 456 | /** |
449 | 457 | * 透過色のマニュアル選択.<br> |
450 | 458 | */ |
@@ -465,7 +473,7 @@ public class UkagakaConvertDialog extends JDialog { | ||
465 | 473 | rebuildImage(); |
466 | 474 | } |
467 | 475 | } |
468 | - | |
476 | + | |
469 | 477 | /** |
470 | 478 | * 伺か用のPNG/PNA画像を生成してプレビューに設定します.<br> |
471 | 479 | */ |
@@ -476,16 +484,16 @@ public class UkagakaConvertDialog extends JDialog { | ||
476 | 484 | UkagakaImageConverter conv = UkagakaImageConverter.getInstance(); |
477 | 485 | |
478 | 486 | BufferedImage pna = conv.createUkagakaPNA(originalImage); |
479 | - | |
487 | + | |
480 | 488 | Color transparentColorKey = null; |
481 | 489 | if (manualTransparentColorKey) { |
482 | 490 | transparentColorKey = colorBox.getColorKey(); |
483 | 491 | } else { |
484 | 492 | transparentColorKey = conv.detectTransparentColorKey(originalImage); |
485 | 493 | } |
486 | - | |
494 | + | |
487 | 495 | BufferedImage png = conv.createUkagakaPNG(originalImage, transparentColorKey); |
488 | - | |
496 | + | |
489 | 497 | opaqueImagePanel.setSamplePicture(png); |
490 | 498 | alphaImagePanel.setSamplePicture(pna); |
491 | 499 | } |
@@ -46,6 +46,7 @@ import charactermanaj.graphics.io.ImagePreviewFileChooser; | ||
46 | 46 | import charactermanaj.ui.model.PredefinedWallpaper; |
47 | 47 | import charactermanaj.ui.model.WallpaperInfo; |
48 | 48 | import charactermanaj.ui.model.WallpaperInfo.WallpaperResourceType; |
49 | +import charactermanaj.ui.util.ScaleSupport; | |
49 | 50 | import charactermanaj.util.LocalizedMessageComboBoxRender; |
50 | 51 | import charactermanaj.util.LocalizedResourcePropertyLoader; |
51 | 52 |
@@ -71,49 +72,49 @@ public class WallpaperDialog extends JDialog { | ||
71 | 72 | * 壁紙情報 |
72 | 73 | */ |
73 | 74 | private WallpaperInfo wallpaperInfo = new WallpaperInfo(); |
74 | - | |
75 | - | |
75 | + | |
76 | + | |
76 | 77 | /** |
77 | 78 | * 選択なしラジオ |
78 | 79 | */ |
79 | 80 | private JRadioButton radioNone; |
80 | - | |
81 | + | |
81 | 82 | /** |
82 | 83 | * ファイルから選択ラジオ |
83 | 84 | */ |
84 | 85 | private JRadioButton radioFile; |
85 | - | |
86 | + | |
86 | 87 | /** |
87 | 88 | * 定義済みから選択ラジオ |
88 | 89 | */ |
89 | 90 | private JRadioButton radioPredefined; |
90 | - | |
91 | + | |
91 | 92 | /** |
92 | 93 | * 定義済み壁紙リスト |
93 | 94 | */ |
94 | 95 | private JList listPredefinedWallpapers; |
95 | - | |
96 | + | |
96 | 97 | /** |
97 | 98 | * 背景画像の透過率 |
98 | 99 | */ |
99 | 100 | private JSpinner spinnerAlpha; |
100 | - | |
101 | + | |
101 | 102 | /** |
102 | 103 | * 選択ファイルフィールド |
103 | 104 | */ |
104 | 105 | private JTextField txtFile; |
105 | - | |
106 | + | |
106 | 107 | /** |
107 | 108 | * ファイルを選択アクション |
108 | 109 | */ |
109 | 110 | private AbstractAction actChooseFile; |
110 | - | |
111 | + | |
111 | 112 | /** |
112 | 113 | * 背景色選択コンポーネント |
113 | 114 | */ |
114 | 115 | private ColorBox colorBox; |
115 | 116 | |
116 | - | |
117 | + | |
117 | 118 | /** |
118 | 119 | * コンストラクタ |
119 | 120 | * @param parent 親フレーム |
@@ -127,16 +128,16 @@ public class WallpaperDialog extends JDialog { | ||
127 | 128 | onCancel(); |
128 | 129 | }; |
129 | 130 | }); |
130 | - | |
131 | + | |
131 | 132 | initPredefinedWallpapers(); |
132 | 133 | initComponent(); |
133 | - | |
134 | + | |
134 | 135 | } catch (RuntimeException ex) { |
135 | 136 | dispose(); |
136 | 137 | throw ex; |
137 | 138 | } |
138 | 139 | } |
139 | - | |
140 | + | |
140 | 141 | /** |
141 | 142 | * 定義済み壁紙リストを初期化する.<br> |
142 | 143 | * 既に初期化済みであれば何もしない.<br> |
@@ -147,7 +148,7 @@ public class WallpaperDialog extends JDialog { | ||
147 | 148 | } |
148 | 149 | predefinedWallpapers.addAll(PredefinedWallpaper.getPredefinedWallpapers()); |
149 | 150 | } |
150 | - | |
151 | + | |
151 | 152 | /** |
152 | 153 | * このダイアログのコンポーネントを初期化します.<br> |
153 | 154 | */ |
@@ -156,7 +157,7 @@ public class WallpaperDialog extends JDialog { | ||
156 | 157 | .getLocalizedProperties(WallpaperDialog.STRINGS_RESOURCE); |
157 | 158 | |
158 | 159 | setTitle(strings.getProperty("title")); |
159 | - | |
160 | + | |
160 | 161 | Container contentPane = getContentPane(); |
161 | 162 | contentPane.setLayout(new BorderLayout(3, 3)); |
162 | 163 | getRootPane().setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); |
@@ -164,15 +165,21 @@ public class WallpaperDialog extends JDialog { | ||
164 | 165 | JPanel wallpaperPanel = createWallpaperChoosePanel(strings); |
165 | 166 | JPanel bgcolorPanel = createBgColorPanel(strings); |
166 | 167 | JPanel btnPanel = createButtonPanel(strings); |
167 | - | |
168 | + | |
168 | 169 | contentPane.add(bgcolorPanel, BorderLayout.NORTH); |
169 | 170 | contentPane.add(wallpaperPanel, BorderLayout.CENTER); |
170 | 171 | contentPane.add(btnPanel, BorderLayout.SOUTH); |
171 | - | |
172 | - setSize(400, 350); | |
172 | + | |
173 | + Dimension dim = new Dimension(400, 350); | |
174 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(this); | |
175 | + if (scaleSupport != null) { | |
176 | + // HiDpi環境でのスケールを考慮したウィンドウサイズに補正する | |
177 | + dim = scaleSupport.manualScaled(dim); | |
178 | + } | |
179 | + setSize(dim); | |
173 | 180 | setLocationRelativeTo(getParent()); |
174 | 181 | } |
175 | - | |
182 | + | |
176 | 183 | private JPanel createButtonPanel(Properties strings) { |
177 | 184 | JPanel btnPanel = new JPanel(); |
178 | 185 |
@@ -188,14 +195,14 @@ public class WallpaperDialog extends JDialog { | ||
188 | 195 | onCancel(); |
189 | 196 | } |
190 | 197 | }; |
191 | - | |
198 | + | |
192 | 199 | JButton btnOK = new JButton(actOK); |
193 | 200 | JButton btnCancel = new JButton(actCancel); |
194 | 201 | |
195 | 202 | BoxLayout bl = new BoxLayout(btnPanel, BoxLayout.LINE_AXIS); |
196 | 203 | btnPanel.setLayout(bl); |
197 | 204 | btnPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 45)); |
198 | - | |
205 | + | |
199 | 206 | btnPanel.add(Box.createHorizontalGlue()); |
200 | 207 | if (Main.isLinuxOrMacOSX()) { |
201 | 208 | btnPanel.add(btnCancel); |
@@ -209,11 +216,11 @@ public class WallpaperDialog extends JDialog { | ||
209 | 216 | // Enter/Returnキーを既定ボタンにする. |
210 | 217 | JRootPane rootPane = getRootPane(); |
211 | 218 | rootPane.setDefaultButton(btnOK); |
212 | - | |
219 | + | |
213 | 220 | // CTRL-Wでウィンドウを非表示にする. (ESCでは非表示にしない) |
214 | 221 | InputMap im = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); |
215 | 222 | ActionMap am = rootPane.getActionMap(); |
216 | - | |
223 | + | |
217 | 224 | Toolkit tk = Toolkit.getDefaultToolkit(); |
218 | 225 | im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "closeWallpaperDialog"); |
219 | 226 | im.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, tk.getMenuShortcutKeyMask()), "closeWallpaperDialog"); |
@@ -221,7 +228,7 @@ public class WallpaperDialog extends JDialog { | ||
221 | 228 | |
222 | 229 | return btnPanel; |
223 | 230 | } |
224 | - | |
231 | + | |
225 | 232 | private JPanel createBgColorPanel(Properties strings) { |
226 | 233 | JPanel bgcolorPanel = new JPanel(); |
227 | 234 |
@@ -232,12 +239,12 @@ public class WallpaperDialog extends JDialog { | ||
232 | 239 | |
233 | 240 | GridBagLayout gbl = new GridBagLayout(); |
234 | 241 | bgcolorPanel.setLayout(gbl); |
235 | - | |
242 | + | |
236 | 243 | colorBox = new ColorBox(); |
237 | 244 | colorBox.getColorDisplayPanel().setPreferredSize(new Dimension(48, 20)); |
238 | 245 | |
239 | 246 | GridBagConstraints gbc = new GridBagConstraints(); |
240 | - | |
247 | + | |
241 | 248 | gbc.ipadx = 0; |
242 | 249 | gbc.ipady = 0; |
243 | 250 | gbc.insets = new Insets(0, 0, 0, 0); |
@@ -245,7 +252,7 @@ public class WallpaperDialog extends JDialog { | ||
245 | 252 | gbc.gridheight = 1; |
246 | 253 | gbc.anchor = GridBagConstraints.CENTER; |
247 | 254 | gbc.fill = GridBagConstraints.NONE; |
248 | - | |
255 | + | |
249 | 256 | bgcolorPanel.add(colorBox, gbc); |
250 | 257 | |
251 | 258 | return bgcolorPanel; |
@@ -253,25 +260,25 @@ public class WallpaperDialog extends JDialog { | ||
253 | 260 | |
254 | 261 | private JPanel createWallpaperChoosePanel(Properties strings) { |
255 | 262 | JPanel wallpaperPanel = new JPanel(); |
256 | - | |
263 | + | |
257 | 264 | wallpaperPanel.setBorder(BorderFactory.createTitledBorder(strings.getProperty("group.wallpaper"))); |
258 | 265 | |
259 | 266 | GridBagLayout gbl = new GridBagLayout(); |
260 | 267 | wallpaperPanel.setLayout(gbl); |
261 | - | |
268 | + | |
262 | 269 | radioNone = new JRadioButton(strings.getProperty("radio.none")); |
263 | 270 | radioFile = new JRadioButton(strings.getProperty("radio.file")); |
264 | 271 | radioPredefined = new JRadioButton(strings.getProperty("radio.predefined")); |
265 | - | |
272 | + | |
266 | 273 | ButtonGroup btnGroup = new ButtonGroup(); |
267 | 274 | btnGroup.add(radioNone); |
268 | 275 | btnGroup.add(radioFile); |
269 | 276 | btnGroup.add(radioPredefined); |
270 | - | |
277 | + | |
271 | 278 | radioNone.setSelected(true); |
272 | - | |
279 | + | |
273 | 280 | txtFile = new JTextField(); |
274 | - | |
281 | + | |
275 | 282 | actChooseFile = new AbstractAction(strings.getProperty("btn.chooseFile")) { |
276 | 283 | private static final long serialVersionUID = 1L; |
277 | 284 | public void actionPerformed(ActionEvent e) { |
@@ -283,13 +290,13 @@ public class WallpaperDialog extends JDialog { | ||
283 | 290 | listPredefinedWallpapers = new JList(predefinedWallpapers |
284 | 291 | .toArray(new PredefinedWallpaper[predefinedWallpapers.size()])); |
285 | 292 | listPredefinedWallpapers.setCellRenderer(new LocalizedMessageComboBoxRender(strings)); |
286 | - | |
293 | + | |
287 | 294 | SpinnerNumberModel alphaSpModel = new SpinnerNumberModel(100, 0, 100, 1); |
288 | 295 | spinnerAlpha = new JSpinner(alphaSpModel); |
289 | - | |
290 | - | |
296 | + | |
297 | + | |
291 | 298 | GridBagConstraints gbc = new GridBagConstraints(); |
292 | - | |
299 | + | |
293 | 300 | gbc.ipadx = 0; |
294 | 301 | gbc.ipady = 0; |
295 | 302 | gbc.insets = new Insets(0, 0, 0, 0); |
@@ -297,14 +304,14 @@ public class WallpaperDialog extends JDialog { | ||
297 | 304 | gbc.gridheight = 1; |
298 | 305 | gbc.anchor = GridBagConstraints.WEST; |
299 | 306 | gbc.fill = GridBagConstraints.BOTH; |
300 | - | |
307 | + | |
301 | 308 | gbc.gridx = 0; |
302 | 309 | gbc.gridy = 0; |
303 | 310 | gbc.gridwidth = 3; |
304 | 311 | gbc.weightx = 0.; |
305 | 312 | |
306 | 313 | wallpaperPanel.add(radioNone, gbc); |
307 | - | |
314 | + | |
308 | 315 | gbc.gridx = 0; |
309 | 316 | gbc.gridy = 1; |
310 | 317 | gbc.gridwidth = 3; |
@@ -316,23 +323,23 @@ public class WallpaperDialog extends JDialog { | ||
316 | 323 | gbc.gridy = 2; |
317 | 324 | gbc.gridwidth = 1; |
318 | 325 | gbc.weightx = 0.; |
319 | - | |
326 | + | |
320 | 327 | wallpaperPanel.add(Box.createHorizontalStrut(20), gbc); |
321 | - | |
328 | + | |
322 | 329 | gbc.gridx = 1; |
323 | 330 | gbc.gridy = 2; |
324 | 331 | gbc.gridwidth = 1; |
325 | 332 | gbc.weightx = 1.; |
326 | - | |
333 | + | |
327 | 334 | wallpaperPanel.add(txtFile, gbc); |
328 | 335 | |
329 | 336 | gbc.gridx = 2; |
330 | 337 | gbc.gridy = 2; |
331 | 338 | gbc.gridwidth = 1; |
332 | 339 | gbc.weightx = 0.; |
333 | - | |
340 | + | |
334 | 341 | wallpaperPanel.add(btnChooseFile, gbc); |
335 | - | |
342 | + | |
336 | 343 | gbc.gridx = 0; |
337 | 344 | gbc.gridy = 3; |
338 | 345 | gbc.gridwidth = 3; |
@@ -345,25 +352,25 @@ public class WallpaperDialog extends JDialog { | ||
345 | 352 | gbc.gridwidth = 2; |
346 | 353 | gbc.weightx = 1.; |
347 | 354 | gbc.weighty = 1.; |
348 | - | |
355 | + | |
349 | 356 | wallpaperPanel.add(new JScrollPane(listPredefinedWallpapers), gbc); |
350 | - | |
357 | + | |
351 | 358 | gbc.gridx = 0; |
352 | 359 | gbc.gridy = 5; |
353 | 360 | gbc.gridwidth = 3; |
354 | 361 | gbc.weightx = 0.; |
355 | 362 | gbc.weighty = 0.; |
356 | 363 | gbc.insets = new Insets(5, 0, 0, 0); |
357 | - | |
364 | + | |
358 | 365 | wallpaperPanel.add(new JLabel( |
359 | 366 | strings.getProperty("label.wallpaperImageAlpha")), gbc); |
360 | - | |
361 | - | |
367 | + | |
368 | + | |
362 | 369 | JPanel alphaPanel = new JPanel(new BorderLayout(3, 3)); |
363 | 370 | alphaPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); |
364 | 371 | alphaPanel.add(spinnerAlpha, BorderLayout.CENTER); |
365 | 372 | alphaPanel.add(new JLabel("%"), BorderLayout.EAST); |
366 | - | |
373 | + | |
367 | 374 | gbc.gridx = 1; |
368 | 375 | gbc.gridy = 6; |
369 | 376 | gbc.gridwidth = 2; |
@@ -375,7 +382,7 @@ public class WallpaperDialog extends JDialog { | ||
375 | 382 | gbc.anchor = GridBagConstraints.WEST; |
376 | 383 | |
377 | 384 | wallpaperPanel.add(alphaPanel, gbc); |
378 | - | |
385 | + | |
379 | 386 | // リスナ |
380 | 387 | listPredefinedWallpapers.addListSelectionListener(new ListSelectionListener() { |
381 | 388 | public void valueChanged(ListSelectionEvent e) { |
@@ -388,7 +395,7 @@ public class WallpaperDialog extends JDialog { | ||
388 | 395 | |
389 | 396 | protected void onChooseFile() { |
390 | 397 | File selectedFile = wallpaperInfo.getFile(); |
391 | - | |
398 | + | |
392 | 399 | final JFileChooser fileChooser = new ImagePreviewFileChooser(); |
393 | 400 | fileChooser.setSelectedFile(selectedFile); |
394 | 401 |
@@ -400,16 +407,16 @@ public class WallpaperDialog extends JDialog { | ||
400 | 407 | txtFile.setText(selectedFile == null ? "" : selectedFile.getPath()); |
401 | 408 | radioFile.setSelected(selectedFile != null); |
402 | 409 | } |
403 | - | |
410 | + | |
404 | 411 | /** |
405 | 412 | * 壁紙情報インスタンスの内容でコンポーネントを設定する. |
406 | 413 | */ |
407 | 414 | protected void applyByWallpaperInfo() { |
408 | - | |
415 | + | |
409 | 416 | // ファイル |
410 | 417 | File imageFile = wallpaperInfo.getFile(); |
411 | 418 | txtFile.setText(imageFile == null ? "" : imageFile.getPath()); |
412 | - | |
419 | + | |
413 | 420 | // リソース |
414 | 421 | PredefinedWallpaper selectedPredefinedWp = null; |
415 | 422 | String resource = wallpaperInfo.getResource(); |
@@ -419,20 +426,20 @@ public class WallpaperDialog extends JDialog { | ||
419 | 426 | } |
420 | 427 | } |
421 | 428 | listPredefinedWallpapers.setSelectedValue(selectedPredefinedWp, true); |
422 | - | |
429 | + | |
423 | 430 | // 透過率 |
424 | 431 | int alphaInt = (int)(wallpaperInfo.getAlpha() * 100); |
425 | 432 | spinnerAlpha.setValue(alphaInt); |
426 | - | |
433 | + | |
427 | 434 | // 背景色 |
428 | 435 | Color bgColor = wallpaperInfo.getBackgroundColor(); |
429 | 436 | colorBox.setColorKey(bgColor); |
430 | - | |
437 | + | |
431 | 438 | // タイプ |
432 | 439 | WallpaperResourceType typ = wallpaperInfo.getType(); |
433 | 440 | if (typ == WallpaperResourceType.FILE) { |
434 | 441 | radioFile.setSelected(true); |
435 | - | |
442 | + | |
436 | 443 | } else if (typ == WallpaperResourceType.PREDEFINED) { |
437 | 444 | radioPredefined.setSelected(true); |
438 | 445 |
@@ -458,7 +465,7 @@ public class WallpaperDialog extends JDialog { | ||
458 | 465 | } else if (radioPredefined.isSelected()) { |
459 | 466 | // リソース選択 |
460 | 467 | typ = WallpaperResourceType.PREDEFINED; |
461 | - | |
468 | + | |
462 | 469 | } else { |
463 | 470 | // それ以外は選択なし |
464 | 471 | typ = WallpaperResourceType.NONE; |
@@ -474,31 +481,31 @@ public class WallpaperDialog extends JDialog { | ||
474 | 481 | } |
475 | 482 | } |
476 | 483 | wallpaperInfo.setFile(selectedFile); |
477 | - | |
484 | + | |
478 | 485 | // 定義済みリソースの現在の選択 |
479 | 486 | PredefinedWallpaper predefinedWp = |
480 | 487 | (PredefinedWallpaper) listPredefinedWallpapers.getSelectedValue(); |
481 | 488 | wallpaperInfo.setResource(predefinedWp == null ? |
482 | 489 | null : predefinedWp.getResource()); |
483 | - | |
490 | + | |
484 | 491 | // タイプの設定 |
485 | 492 | wallpaperInfo.setType(typ); |
486 | - | |
493 | + | |
487 | 494 | // 背景画像の透過率 |
488 | 495 | int alphaInt = (Integer) spinnerAlpha.getValue(); |
489 | 496 | float alpha = (float) alphaInt / 100.f; |
490 | 497 | wallpaperInfo.setAlpha(alpha); |
491 | - | |
498 | + | |
492 | 499 | // 背景色 |
493 | 500 | Color bgColor = colorBox.getColorKey(); |
494 | 501 | wallpaperInfo.setBackgroundColor(bgColor); |
495 | - | |
502 | + | |
496 | 503 | return wallpaperInfo; |
497 | 504 | } |
498 | - | |
505 | + | |
499 | 506 | protected void onOK() { |
500 | 507 | WallpaperInfo wallpaperInfo = createWallpaperInfo(); |
501 | - | |
508 | + | |
502 | 509 | if (!checkValidate(wallpaperInfo)) { |
503 | 510 | return; |
504 | 511 | } |
@@ -506,12 +513,12 @@ public class WallpaperDialog extends JDialog { | ||
506 | 513 | this.wallpaperInfo = wallpaperInfo; |
507 | 514 | dispose(); |
508 | 515 | } |
509 | - | |
516 | + | |
510 | 517 | protected void onCancel() { |
511 | 518 | wallpaperInfo = null; |
512 | 519 | dispose(); |
513 | 520 | } |
514 | - | |
521 | + | |
515 | 522 | protected boolean checkValidate(WallpaperInfo wallpaperInfo) { |
516 | 523 | String messageid = null; |
517 | 524 | WallpaperResourceType typ = wallpaperInfo.getType(); |
@@ -530,7 +537,7 @@ public class WallpaperDialog extends JDialog { | ||
530 | 537 | messageid = "error.require.resource"; |
531 | 538 | } |
532 | 539 | } |
533 | - | |
540 | + | |
534 | 541 | if (messageid != null) { |
535 | 542 | Properties strings = LocalizedResourcePropertyLoader.getCachedInstance() |
536 | 543 | .getLocalizedProperties(WallpaperDialog.STRINGS_RESOURCE); |
@@ -538,21 +545,21 @@ public class WallpaperDialog extends JDialog { | ||
538 | 545 | String message = strings.getProperty(messageid); |
539 | 546 | JOptionPane.showMessageDialog(this, message, "ERROR", JOptionPane.ERROR_MESSAGE); |
540 | 547 | } |
541 | - | |
548 | + | |
542 | 549 | return messageid == null; |
543 | 550 | } |
544 | - | |
551 | + | |
545 | 552 | public void setWallpaperInfo(WallpaperInfo wallpaperInfo) { |
546 | 553 | if (wallpaperInfo == null) { |
547 | 554 | wallpaperInfo = new WallpaperInfo(); |
548 | 555 | } |
549 | 556 | this.wallpaperInfo = wallpaperInfo; |
550 | 557 | } |
551 | - | |
558 | + | |
552 | 559 | public WallpaperInfo getWallpaperInfo() { |
553 | 560 | return wallpaperInfo; |
554 | 561 | } |
555 | - | |
562 | + | |
556 | 563 | /** |
557 | 564 | * ダイアログを表示し、その結果を返す.<br> |
558 | 565 | * キャンセルされた場合はnullが返される.<br> |
@@ -0,0 +1,90 @@ | ||
1 | +package charactermanaj.ui.util; | |
2 | + | |
3 | +import java.awt.Component; | |
4 | +import java.awt.Dimension; | |
5 | +import java.awt.GraphicsConfiguration; | |
6 | +import java.awt.GraphicsDevice; | |
7 | +import java.awt.GraphicsEnvironment; | |
8 | +import java.awt.Toolkit; | |
9 | +import java.awt.geom.AffineTransform; | |
10 | + | |
11 | +/** | |
12 | + * スクリーンのスケールを取得する。 | |
13 | + * | |
14 | + * Java8であれば自動スケールがかかっていないので、マニュアルでスケール倍して座標を補正する。 | |
15 | + * Java11であれば自動スケールがかかっている。 | |
16 | + */ | |
17 | +public class ScaleSupport { | |
18 | + | |
19 | + private static final float scale; | |
20 | + | |
21 | + private double scaleX; | |
22 | + | |
23 | + private double scaleY; | |
24 | + | |
25 | + private double manualScaleX; | |
26 | + | |
27 | + private double manualScaleY; | |
28 | + | |
29 | + static { | |
30 | + Toolkit tk = Toolkit.getDefaultToolkit(); | |
31 | + int resolution = tk.getScreenResolution(); | |
32 | + | |
33 | + float dpi = System.getProperty("os.name").startsWith("Windows") ? 96f : 72f; | |
34 | + scale = resolution / dpi; | |
35 | + } | |
36 | + | |
37 | + private ScaleSupport(double scaleX, double scaleY) { | |
38 | + this.scaleX = scaleX; | |
39 | + this.scaleY = scaleY; | |
40 | + manualScaleX = scale / scaleX; | |
41 | + manualScaleY = scale / scaleX; | |
42 | + } | |
43 | + | |
44 | + /** | |
45 | + * コンポーネントのグラフィクス設定からスケールを取得する。 | |
46 | + * まだ画面に関連付けられていない場合はnullを返す。 | |
47 | + * @param comp | |
48 | + * @return | |
49 | + */ | |
50 | + public static ScaleSupport getInstance(Component comp) { | |
51 | + GraphicsConfiguration gconf = comp.getGraphicsConfiguration(); | |
52 | + if (gconf == null) { | |
53 | + return null; | |
54 | + } | |
55 | + return getInstance(gconf); | |
56 | + } | |
57 | + | |
58 | + public static ScaleSupport getDefault() { | |
59 | + GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
60 | + GraphicsDevice gdev = genv.getDefaultScreenDevice(); | |
61 | + return getInstance(gdev.getDefaultConfiguration()); | |
62 | + } | |
63 | + | |
64 | + public static ScaleSupport getInstance(GraphicsConfiguration gconf) { | |
65 | + AffineTransform trans = gconf.getDefaultTransform(); | |
66 | + double scaleX = trans.getScaleX(); | |
67 | + double scaleY = trans.getScaleY(); | |
68 | + return new ScaleSupport(scaleX, scaleY); | |
69 | + } | |
70 | + | |
71 | + public double getDefaultScaleX() { | |
72 | + return scaleX; | |
73 | + } | |
74 | + | |
75 | + public double getDefaultScaleY() { | |
76 | + return scaleY; | |
77 | + } | |
78 | + | |
79 | + public double getManualScaleX() { | |
80 | + return manualScaleX; | |
81 | + } | |
82 | + | |
83 | + public double getManualScaleY() { | |
84 | + return manualScaleY; | |
85 | + } | |
86 | + | |
87 | + public Dimension manualScaled(Dimension dim) { | |
88 | + return new Dimension((int) (dim.getWidth() * manualScaleX), (int) (dim.getHeight() * manualScaleY)); | |
89 | + } | |
90 | +} | |
\ No newline at end of file |
@@ -20,6 +20,8 @@ import javax.swing.JOptionPane; | ||
20 | 20 | import javax.swing.JScrollPane; |
21 | 21 | import javax.swing.JTextArea; |
22 | 22 | |
23 | +import charactermanaj.ui.util.ScaleSupport; | |
24 | + | |
23 | 25 | /** |
24 | 26 | * 例外を表示するダイアログ.<br> |
25 | 27 | * ログにも記録される.<br> |
@@ -77,7 +79,6 @@ public final class ErrorMessageHelper { | ||
77 | 79 | JOptionPane pane = new JOptionPane(scr, JOptionPane.ERROR_MESSAGE); |
78 | 80 | |
79 | 81 | Window window = getWindowForComponent(parent); |
80 | - System.out.println("window=" + window); | |
81 | 82 | |
82 | 83 | final JDialog dialog; |
83 | 84 | String title = "ERROR"; |
@@ -95,7 +96,10 @@ public final class ErrorMessageHelper { | ||
95 | 96 | contentPane.add(pane, BorderLayout.CENTER); |
96 | 97 | dialog.setResizable(true); |
97 | 98 | |
98 | - dialog.pack(); | |
99 | + ScaleSupport scaleSupport = ScaleSupport.getInstance(dialog); | |
100 | + Dimension wnddim = dialog.getPreferredSize(); | |
101 | + wnddim = scaleSupport.manualScaled(wnddim); | |
102 | + dialog.setSize(wnddim); | |
99 | 103 | dialog.setLocationRelativeTo(parent); |
100 | 104 | |
101 | 105 | pane.addPropertyChangeListener(JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() { |