-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinViewSetting.java
317 lines (258 loc) · 7.68 KB
/
WinViewSetting.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
package map;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.awt.TextField;
import java.awt.Label;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
* 地図情報
*/
public class WinViewSetting extends JDialog{
// 表示範囲 - データ
private int VAL_nPolygonW50 = 200; // 最大値
private int VAL_nPolygonH50 = 200; // 最大値
private int VAL_PolygonW50; // 現在値
private int VAL_PolygonH50; // 現在値
// 表示範囲 - スクロールバー
private JScrollBar SB_PolygonW50;
private JScrollBar SB_PolygonH50;
// 表示範囲 - 現在値表示
private Label LB_PolygonW50;
private Label LB_PolygonH50;
private Label LB_Polygon50;
// オブジェ
private JButton BT_ok = new JButton();
private JButton BT_cn = new JButton();
private String BT = "";
/**
* コンストラクタ
* arg
* settings[0] : 50m 東西方向へ描画する標高数
* settings[1] : 50m 南北方向へ描画する標高数
*/
public WinViewSetting(Frame parent, String[] settings){
super(parent);
try{
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
init(settings);
}
catch(Exception exception){
exception.printStackTrace();
}
}
/**
* 初期化
*/
private void init(String[] settings) throws Exception{
// Window
setTitle("表示設定");
setResizable(true);
JPanel content = (JPanel) getContentPane();
content.setLayout(null);
// 設定
VAL_PolygonW50 = Integer.parseInt(settings[0]);
VAL_PolygonH50 = Integer.parseInt(settings[1]);
// 設定情報 50m
Set50(content);
}
/**
* 地図情報
*/
private void Set50(JPanel content){
// オブジェ - ラベル
Label LB_title_PolygonEW;
Label LB_title_PolygonSN;
Label LB_title_Polygon;
int LB_x, LB_y, LB_w, LB_h;
int LB_x_init = 10;
int LB_y_init = 20;
int LB_titleW = 65;
int LB_titleH = 20;
// オブジェ - タイトルボーダー
TitledBorder BR_50 = new TitledBorder(new LineBorder(Color.BLACK), "50m メッシュ 設定", TitledBorder.LEFT, TitledBorder.TOP);
content.setBorder(BR_50);
// オブジェ - ポリゴン数 - 東西
LB_x = LB_x_init;
LB_y = LB_y_init;
LB_w = LB_titleW;
LB_h = LB_titleH;
LB_title_PolygonEW = new Label("南北標高数");
LB_title_PolygonEW.setBounds(LB_x, LB_y, LB_w, LB_h);
content.add(LB_title_PolygonEW);
LB_x += LB_w;
LB_w = 200;
SB_PolygonW50 = new JScrollBar(JScrollBar.HORIZONTAL, VAL_PolygonW50, 10, 10, VAL_nPolygonW50 + 10);
SB_PolygonW50.setSize(LB_h, LB_h - 3);
SB_PolygonW50.setBounds(LB_x, LB_y, LB_w, LB_h - 3);
SB_PolygonW50.addAdjustmentListener(new WinViewSetting_PolygonEW50(this));
content.add(SB_PolygonW50);
LB_x += LB_w + 5;
LB_w = 25;
LB_h = 17;
LB_PolygonW50 = new Label(String.valueOf(VAL_PolygonW50));
LB_PolygonW50.setBounds(LB_x, LB_y, LB_w, LB_h);
LB_PolygonW50.setAlignment(Label.RIGHT);
LB_PolygonW50.setBackground(Color.WHITE);
content.add(LB_PolygonW50);
// オブジェ - ポリゴン数 - 南北範囲
LB_y_init += LB_titleH;
LB_x = LB_x_init;
LB_y = LB_y_init + 3;
LB_w = LB_titleW;
LB_h = LB_titleH;
LB_title_PolygonSN = new Label("南北標高数");
LB_title_PolygonSN.setBounds(LB_x, LB_y, LB_w, LB_h);
content.add(LB_title_PolygonSN);
LB_x += LB_w;
LB_w = 200;
SB_PolygonH50 = new JScrollBar(JScrollBar.HORIZONTAL, VAL_PolygonH50, 10, 10, VAL_nPolygonH50 + 10);
SB_PolygonH50.setSize(LB_h, LB_h - 3);
SB_PolygonH50.setBounds(LB_x, LB_y, LB_w, LB_h - 3);
SB_PolygonH50.addAdjustmentListener(new WinViewSetting_PolygonSN50(this));
content.add(SB_PolygonH50);
LB_x += LB_w + 5;
LB_w = 25;
LB_h = 17;
LB_PolygonH50 = new Label(String.valueOf(VAL_PolygonH50));
LB_PolygonH50.setBounds(LB_x, LB_y, LB_w, LB_h);
LB_PolygonH50.setAlignment(Label.RIGHT);
LB_PolygonH50.setBackground(Color.WHITE);
content.add(LB_PolygonH50);
// オブジェ - ポリゴン数
LB_y_init += LB_titleH;
LB_x = LB_x_init;
LB_y = LB_y_init + 3;
LB_w = LB_titleW;
LB_h = LB_titleH;
LB_title_Polygon = new Label("ポリゴン数");
LB_title_Polygon.setBounds(LB_x, LB_y, LB_w, LB_h);
content.add(LB_title_Polygon);
LB_x += LB_w + 5;
LB_w = 38;
LB_h = 17;
LB_Polygon50 = new Label(String.valueOf(VAL_PolygonW50 * VAL_PolygonH50));
LB_Polygon50.setBounds(LB_x, LB_y, LB_w, LB_h);
LB_Polygon50.setAlignment(Label.RIGHT);
LB_Polygon50.setBackground(Color.WHITE);
content.add(LB_Polygon50);
// ボタン
LB_x = LB_x_init;
LB_y = 130;
LB_w = 100;
LB_h = 24;
BT_ok.setText("OK");
BT_ok.addActionListener(new WinViewSetting_OK(this));
BT_ok.setBounds(LB_x, LB_y, LB_w, LB_h);
content.add(BT_ok);
LB_x += LB_w + 5;
BT_cn.setText("キャンセル");
BT_cn.addActionListener(new WinViewSetting_CN(this));
BT_cn.setBounds(LB_x, LB_y, LB_w, LB_h);
content.add(BT_cn);
}
/**
* データ取得 - 表示範囲 - 東西
*/
public int getPolygonW50(){
return VAL_PolygonW50;
}
/**
* データ取得 - 表示範囲 - 南北
*/
public int getPolygonH50(){
return VAL_PolygonH50;
}
/**
* データ取得 - ボタン
*/
public String getBT(){
return BT;
}
/**
* メニュー - ポリゴン数 - 東西範囲
*/
void PolygonEW50(String val){
VAL_PolygonW50 = Integer.parseInt(val);
LB_PolygonW50.setText(val);
LB_Polygon50.setText(String.valueOf(VAL_PolygonW50 * VAL_PolygonH50));
}
/**
* メニュー - ポリゴン数 - 南北範囲
*/
void PolygonSN50(String val){
VAL_PolygonH50 = Integer.parseInt(val);
LB_PolygonH50.setText(val);
LB_Polygon50.setText(String.valueOf(VAL_PolygonW50 * VAL_PolygonH50));
}
/**
* ボタン - OK
*/
void BT(ActionEvent actionEvent){
if(actionEvent.getSource() == BT_ok){
BT = "OK";
}
dispose();
}
}
/**
* オブジェ - ポリゴン数 - 東西範囲
*/
class WinViewSetting_PolygonEW50 implements AdjustmentListener{
WinViewSetting adaptee;
// コンテキスト
WinViewSetting_PolygonEW50(WinViewSetting adaptee){
this.adaptee = adaptee;
}
public void adjustmentValueChanged(AdjustmentEvent actionEvent){
JScrollBar sb = (JScrollBar)actionEvent.getSource();
adaptee.PolygonEW50(String.valueOf(sb.getValue()));
}
}
/**
* オブジェ - ポリゴン数 - 南北範囲
*/
class WinViewSetting_PolygonSN50 implements AdjustmentListener{
WinViewSetting adaptee;
// コンテキスト
WinViewSetting_PolygonSN50(WinViewSetting adaptee){
this.adaptee = adaptee;
}
public void adjustmentValueChanged(AdjustmentEvent actionEvent){
JScrollBar sb = (JScrollBar)actionEvent.getSource();
adaptee.PolygonSN50(String.valueOf(sb.getValue()));
}
}
/**
* オブジェ - ボタン - OK
*/
class WinViewSetting_OK implements ActionListener{
WinViewSetting adaptee;
// コンテキスト
WinViewSetting_OK(WinViewSetting adaptee){
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent){
adaptee.BT(actionEvent);
}
}
/**
* オブジェ - ボタン - キャンセル
*/
class WinViewSetting_CN implements ActionListener{
WinViewSetting adaptee;
// コンテキスト
WinViewSetting_CN(WinViewSetting adaptee){
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent){
adaptee.BT(actionEvent);
}
}