• R/O
  • SSH
  • HTTPS

zenjiro: 提交


Commit MetaInfo

修訂137 (tree)
時間2010-11-29 23:13:00
作者zenjiro

Log Message

終了時のウィンドウサイズを保持するようにした。
プロパティの初期値を使うようにした。

Change Summary

差異

--- osmap/trunk/Main.java (revision 136)
+++ osmap/trunk/Main.java (revision 137)
@@ -1,5 +1,4 @@
11 import java.awt.BorderLayout;
2-import java.awt.Dimension;
32 import java.awt.Graphics;
43 import java.awt.Graphics2D;
54 import java.awt.Image;
@@ -52,23 +51,23 @@
5251 /**
5352 * 縮尺
5453 */
55- static int zoom = 5;
54+ static int zoom;
5655 /**
5756 * 列
5857 */
59- static int col = 27;
58+ static int col;
6059 /**
6160 * 行
6261 */
63- static int row = 12;
62+ static int row;
6463 /**
6564 * x座標
6665 */
67- static int offsetX = 20;
66+ static int offsetX;
6867 /**
6968 * y座標
7069 */
71- static int offsetY = 150;
70+ static int offsetY;
7271 /**
7372 * マウスドラッグが開始されたx座標
7473 */
@@ -87,14 +86,14 @@
8786 final Properties properties = new Properties();
8887 try {
8988 properties.load(new FileInputStream(CONFIGURATION_FILE));
90- zoom = properties.containsKey("zoom") ? Integer.parseInt(properties.getProperty("zoom")) : zoom;
91- col = properties.containsKey("col") ? Integer.parseInt(properties.getProperty("col")) : col;
92- row = properties.containsKey("row") ? Integer.parseInt(properties.getProperty("row")) : row;
93- offsetX = properties.containsKey("offsetX") ? Integer.parseInt(properties.getProperty("offsetX")) : offsetX;
94- offsetY = properties.containsKey("offsetY") ? Integer.parseInt(properties.getProperty("offsetY")) : offsetY;
9589 } catch (final FileNotFoundException exception) {
9690 // do nothing
9791 }
92+ zoom = Integer.parseInt(properties.getProperty("zoom", "5"));
93+ col = Integer.parseInt(properties.getProperty("col", "27"));
94+ row = Integer.parseInt(properties.getProperty("row", "12"));
95+ offsetX = Integer.parseInt(properties.getProperty("offsetX", "20"));
96+ offsetY = Integer.parseInt(properties.getProperty("offsetY", "150"));
9897 final Map<String, Image> images = new HashMap<String, Image>();
9998 final JFrame frame = new JFrame("OSMap");
10099 final Timer timer = new Timer();
@@ -126,7 +125,6 @@
126125 zoom, col, row, offsetX, offsetY).toString());
127126 }
128127 };
129- panel.setPreferredSize(new Dimension(640, 480));
130128 frame.add(panel, BorderLayout.CENTER);
131129 frame.add(label, BorderLayout.SOUTH);
132130 panel.addMouseWheelListener(new MouseWheelListener() {
@@ -185,7 +183,9 @@
185183 panel.repaint();
186184 }
187185 });
188- frame.pack();
186+ frame.setExtendedState(Integer.parseInt(properties.getProperty("frame.extendedState", "0")));
187+ frame.setSize(Integer.parseInt(properties.getProperty("frame.width", "800")),
188+ Integer.parseInt(properties.getProperty("frame.height", "600")));
189189 frame.addWindowListener(new WindowAdapter() {
190190 @Override
191191 public void windowClosed(final WindowEvent event) {
@@ -196,6 +196,11 @@
196196 properties.put("row", Integer.toString(row));
197197 properties.put("offsetX", Integer.toString(offsetX));
198198 properties.put("offsetY", Integer.toString(offsetY));
199+ properties.put("frame.extendedState", Integer.toString(frame.getExtendedState()));
200+ if (frame.getExtendedState() == 0) {
201+ properties.put("frame.width", Integer.toString(frame.getWidth()));
202+ properties.put("frame.height", Integer.toString(frame.getHeight()));
203+ }
199204 properties.store(new FileWriter(CONFIGURATION_FILE), "OSMap configuration");
200205 } catch (final IOException exception) {
201206 exception.printStackTrace();
Show on old repository browser