import java.awt.Dialog;
import java.awt.event.ActionEvent;
+import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Date;
import javax.swing.JButton;
import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime;
* この1インスタンスで、1パラメータをあらわす。
*/
public class ParameterPanelTime extends ParameterPanel {
+ static final String TIME_PATTERN = "yyyy.MM.dd HH:mm:ss z";
SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance();
ParameterPanelImageFile imageFile;
public JButton updateButton;
+ public JButton resetButton;
Dialog owner;
@SuppressWarnings("OverridableMethodCallInConstructor")
updateButton = new JButton(i18n.getString("button.update"));
updateButton.addActionListener(buttonAction);
this.add(updateButton);
+
+ // "ボタン[再設定...]"
+ ResetButtonAction resetAction = new ResetButtonAction(this);
+ resetButton = new JButton(i18n.getString("button.reset"));
+ resetButton.addActionListener(resetAction);
+ resetButton.setVisible(false);
+ this.add(resetButton);
}
public ParameterPanelTime setOwner(Dialog owner) {
this.owner = owner;
return this;
- }
+ }
/**
* ボタンのアクション
}
}
+ /**
+ * ボタンのアクション
+ */
+ class ResetButtonAction implements java.awt.event.ActionListener
+ {
+ ParameterPanelTime param;
+
+ public ResetButtonAction(ParameterPanelTime param) {
+ this.param = param;
+ }
+
+ @SuppressWarnings("override")
+ public void actionPerformed(ActionEvent e) {
+ if (param.imageFile.isEnable()) {
+ File file = param.imageFile.getImageFile();
+ long lastModified = file.lastModified();
+ sdf.applyPattern(TIME_PATTERN);
+ param.argField.setText(sdf.format(new Date(lastModified)));
+ }
+ else {
+ param.argField.setText("");
+ }
+ }
+ }
+
public ParameterPanelImageFile getImageFile() {
return this.imageFile;
}
String text = this.argField.getText();
if (text != null) {
try {
- sdf.applyPattern("yyyy.MM.dd HH:mm:ss z");
+ sdf.applyPattern(TIME_PATTERN);
sdf.parse(text);
return true;
}
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.GridLayout;
+import java.awt.Rectangle;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
*/
public class DialogCorectTime extends JDialog implements PanelAction {
public JPanel mainPanel;
- JPanel argsPanel; // パラメータ設定パネル (上部)
ParameterPanelTime arg_basetime; // 開始画像の基準時刻:
+ ParameterPanelTime basetime; // 開始画像の基準時刻:
+ java.awt.Button closeButton;
/**
* コンストラクタ
*/
public DialogCorectTime(ParameterPanelTime arg3_basetime, Dialog owner) {
super(owner, AdjustTime.i18n.getString("tab.restamp.300"), false);
+ this.arg_basetime = arg3_basetime;
- argsPanel = new JPanel();
- argsPanel.setLayout(new GridLayout(2, 1));
-
+ // INIT_CONTROLS
+ setLayout(new BorderLayout());
+ setSize(
+ getInsets().left + getInsets().right + 720,
+ getInsets().top + getInsets().bottom + 480
+ );
+
//---- CENTER -----
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BorderLayout());
add(centerPanel, BorderLayout.CENTER);
+ //---- CENTER.NORTH -----
+ JPanel argsPanel; // パラメータ設定パネル (上部)
+ argsPanel = new JPanel();
+ argsPanel.setLayout(new GridLayout(2, 1));
+
// 3. 正確な撮影時刻を入力してください。
// カメラの時計が正確ならば、設定を変更する必要はありません。
JLabel label3 = new JLabel();
label3.setText(i18n.getString("label.300"));
argsPanel.add(label3);
- // 基準時刻:
- this.arg_basetime = arg3_basetime;
- //arg3_basetime.setLabel(String.format(" %s: ", i18n.getString("label.310")));
- //arg3_basetime.setLabel(ImportPicture.TIME_FORMAT_STRING);
- //argsPanel.add(arg3_basetime);
- //centerPanel.add(argsPanel, BorderLayout.NORTH);
+ basetime = new ParameterPanelTime(
+ arg3_basetime.argLabel.getText(),
+ "",
+ arg3_basetime.getImageFile()
+ );
+ basetime.updateButton.setVisible(false);
+ basetime.resetButton.setVisible(true);
+ argsPanel.add(basetime);
+ centerPanel.add(argsPanel, BorderLayout.NORTH);
+ //---- CENTER.CENTER -----
// 参考画像
JLabel imageLabel = new JLabel();
JScrollPane imageSPane = new JScrollPane(imageLabel);
centerPanel.add(imageSPane, BorderLayout.CENTER);
+ //---- CENTER.SOUTH -----
// 画像ファイル選択ダイアログを起動するボタン
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
JButton zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
buttonPanel.add(zoomOutButton);
centerPanel.add(buttonPanel, BorderLayout.SOUTH);
+
+ //---- SOUTH -----
+ closeButton = new java.awt.Button();
+ closeButton.setLabel(i18n.getString("button.close") );
+ closeButton.setBounds(145,65,66,27);
+ add(closeButton, BorderLayout.SOUTH);
+
+ //{{REGISTER_LISTENERS
+ SymWindow aSymWindow = new SymWindow();
+ this.addWindowListener(aSymWindow);
+ SymAction lSymAction = new SymAction();
+ closeButton.addActionListener(lSymAction);
+ //}}
+ }
+
+ class SymWindow extends java.awt.event.WindowAdapter
+ {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent event) {
+ Object object = event.getSource();
+ if (object == DialogCorectTime.this) {
+ dialog_WindowClosing();
+ }
+ }
+ }
+
+ class SymAction implements java.awt.event.ActionListener
+ {
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent event) {
+ Object object = event.getSource();
+ if (object == closeButton) {
+ dialog_WindowClosing();
+ }
+ }
+ }
+
+ /**
+ * ダイアログが閉じられるときのアクション
+ */
+ void dialog_WindowClosing() {
+ String workStr = basetime.getText();
+ arg_basetime.setText(workStr);
+ dispose();
+ }
+
+ @Override
+ public void setVisible(boolean b) {
+ if(b) {
+ Rectangle bounds = getParent().getBounds();
+ Rectangle abounds = getBounds();
+ setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
+ bounds.y + (bounds.height - abounds.height)/2);
+ }
+ super.setVisible(b);
}
@Override