1 package osm.jp.gpx.matchtime.gui.restamp;
3 import java.awt.BorderLayout;
4 import java.awt.Dialog;
5 import java.awt.GridLayout;
7 import java.awt.Rectangle;
8 import java.awt.Window;
9 import javax.swing.BoxLayout;
10 import javax.swing.ImageIcon;
11 import javax.swing.JButton;
12 import javax.swing.JDialog;
13 import javax.swing.JLabel;
14 import javax.swing.JPanel;
15 import javax.swing.JScrollPane;
16 import osm.jp.gpx.matchtime.gui.AdjustTime;
17 import static osm.jp.gpx.matchtime.gui.AdjustTime.createImageIcon;
18 import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
19 import osm.jp.gpx.matchtime.gui.PanelAction;
20 import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
26 public class DialogCorectTime extends JDialog implements PanelAction {
27 public JPanel mainPanel;
28 ParameterPanelTime arg_basetime; // 開始画像の基準時刻(parent)
29 ParameterPanelTime basetime; // 開始画像の基準時刻(tempolarry)
30 java.awt.Button closeButton;
33 JButton zoomOutButton;
34 JLabel imageLabel; // 開始画像の基準時刻画像表示
35 JScrollPane imageSPane; // スクロールパネル
39 * @param arg3_basetime 開始画像の基準時刻:
42 @SuppressWarnings("OverridableMethodCallInConstructor")
43 public DialogCorectTime(ParameterPanelTime arg3_basetime, Window owner) {
44 super(owner, AdjustTime.i18n.getString("tab.restamp.300"), Dialog.ModalityType.DOCUMENT_MODAL);
45 this.arg_basetime = arg3_basetime;
48 setLayout(new BorderLayout());
50 getInsets().left + getInsets().right + 720,
51 getInsets().top + getInsets().bottom + 480
55 JPanel centerPanel = new JPanel();
56 centerPanel.setLayout(new BorderLayout());
57 add(centerPanel, BorderLayout.CENTER);
59 //---- CENTER.NORTH -----
60 JPanel argsPanel; // パラメータ設定パネル (上部)
61 argsPanel = new JPanel();
62 argsPanel.setLayout(new GridLayout(2, 1));
64 // 3. 正確な撮影時刻を入力してください。
65 // カメラの時計が正確ならば、設定を変更する必要はありません。
66 JLabel label3 = new JLabel();
67 label3.setText(i18n.getString("label.300"));
68 argsPanel.add(label3);
70 basetime = new ParameterPanelTime(
71 arg_basetime.argLabel.getText(),
73 arg_basetime.getImageFile()
75 basetime.updateButton.setVisible(false);
76 basetime.resetButton.setVisible(true);
77 argsPanel.add(basetime);
78 centerPanel.add(argsPanel, BorderLayout.NORTH);
80 //---- CENTER.CENTER -----
82 imageLabel = new JLabel();
83 imageSPane = new JScrollPane(imageLabel);
84 centerPanel.add(imageSPane, BorderLayout.CENTER);
86 //---- CENTER.SOUTH -----
87 // 画像ファイル選択ダイアログを起動するボタン
88 JPanel buttonPanel = new JPanel();
89 buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
90 expandButton = new JButton(createImageIcon(java.util.ResourceBundle.getBundle("i18n_ja_JP").getString("IMAGES/FIT16.GIF")));
91 buttonPanel.add(expandButton);
92 zoomInButton = new JButton(createImageIcon("images/ZoomIn16.gif"));
93 buttonPanel.add(zoomInButton);
94 zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
95 buttonPanel.add(zoomOutButton);
96 centerPanel.add(buttonPanel, BorderLayout.SOUTH);
99 closeButton = new java.awt.Button();
100 closeButton.setLabel(i18n.getString("button.close") );
101 closeButton.setBounds(145,65,66,27);
102 add(closeButton, BorderLayout.SOUTH);
107 //{{REGISTER_LISTENERS
108 SymWindow aSymWindow = new SymWindow();
109 this.addWindowListener(aSymWindow);
110 SymAction lSymAction = new SymAction();
111 closeButton.addActionListener(lSymAction);
112 expandButton.addActionListener(lSymAction);
113 zoomInButton.addActionListener(lSymAction);
114 zoomOutButton.addActionListener(lSymAction);
118 class SymWindow extends java.awt.event.WindowAdapter
121 public void windowClosing(java.awt.event.WindowEvent event) {
122 Object object = event.getSource();
123 if (object == DialogCorectTime.this) {
124 dialog_WindowClosing();
129 class SymAction implements java.awt.event.ActionListener
132 public void actionPerformed(java.awt.event.ActionEvent event) {
133 Object object = event.getSource();
134 if (object == closeButton) {
135 dialog_WindowClosing();
137 else if (object == expandButton) {
140 else if (object == zoomInButton) {
143 else if (object == zoomOutButton) {
153 * 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。
155 @SuppressWarnings("UseSpecificCatch")
156 public void imageView_Action() {
157 String path = basetime.getImageFile().getImageFile().getAbsolutePath();
160 int size_x = imageSPane.getWidth() - 8;
161 ImageIcon tmpIcon = new ImageIcon(path);
163 if (tmpIcon.getIconWidth() > size_x) {
164 refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x, -1, Image.SCALE_DEFAULT));
166 imageLabel.setIcon(refImage);
170 public void zoomin_Action() {
171 if (refImage != null) {
172 int size_x = imageLabel.getWidth();
173 String path = basetime.getImageFile().getImageFile().getAbsolutePath();
174 ImageIcon tmpIcon = new ImageIcon(path);
175 refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x * 2, -1, Image.SCALE_DEFAULT));
176 imageLabel.setIcon(refImage);
181 public void zoomout_Action() {
182 if (refImage != null) {
183 int size_x = imageLabel.getWidth();
184 ImageIcon tmpIcon = refImage;
185 refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x / 2, -1, Image.SCALE_DEFAULT));
186 imageLabel.setIcon(refImage);
192 * ダイアログが閉じられるときのアクション
194 void dialog_WindowClosing() {
195 String workStr = basetime.getText();
196 arg_basetime.setText(workStr);
201 public void setVisible(boolean b) {
203 Rectangle bounds = getParent().getBounds();
204 Rectangle abounds = getBounds();
205 setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
206 bounds.y + (bounds.height - abounds.height)/2);
212 @SuppressWarnings("empty-statement")
213 public void openAction() {
222 public boolean isEnable() {
223 return this.basetime.isEnable();