package osm.jp.gpx.matchtime.gui.restamp;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.io.File;
import java.io.IOException;
-import java.util.Date;
import java.util.Observable;
import java.util.Observer;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import osm.jp.gpx.AppParameters;
-import osm.jp.gpx.matchtime.gui.AdjustTime;
import osm.jp.gpx.matchtime.gui.Card;
-import osm.jp.gpx.matchtime.gui.ImageFileView;
-import osm.jp.gpx.matchtime.gui.ImageFilter;
-import osm.jp.gpx.matchtime.gui.ImagePreview;
import osm.jp.gpx.matchtime.gui.ParameterPanelFolder;
import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile;
import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
public class RestampDialog extends Dialog implements Observer
{
//{{DECLARE_CONTROLS
- java.awt.Label label1;
java.awt.Button closeButton;
- java.awt.Label label2;
- JLabel imageLabel; // 開始画像の基準時刻画像表示
JTabbedPane cardPanel; // ウィザード形式パネル(タブ型)
- JScrollPane imageSPane; // スクロールパネル
Card[] cards;
ParameterPanelFolder arg1_srcFolder; // 対象フォルダ
ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス
ParameterPanelTime arg2_basetime; // 開始画像の基準時刻:
+ ParameterPanelImageFile arg3_baseTimeImg; // 終了画像ファイルパス
+ ParameterPanelTime arg3_basetime; // 終了画像の基準時刻:
AppParameters params;
//}}
- // Used for addNotify redundency check.
- boolean fComponentsAdjusted = false;
-
/**
*
* @param arg0
public void windowClosing(java.awt.event.WindowEvent event) {
Object object = event.getSource();
if (object == RestampDialog.this) {
- AboutDialog_WindowClosing(event);
+ dispose();
}
}
}
public void actionPerformed(java.awt.event.ActionEvent event) {
Object object = event.getSource();
if (object == closeButton) {
- closeButton_Clicked(event);
- }
- else if (object == arg2_baseTimeImg.argField) {
- imageView_Action(event);
- }
- else if (object == arg2_baseTimeImg.openButton) {
- selectImage_Action(event);
- imageView_Action(event);
+ dispose();
}
}
}
null,
arg1_srcFolder
);
- arg2_baseTimeImg.argField
- .getDocument()
- .addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(1, arg2_baseTimeImg.isEnable());
- }
+
+ // 2a. 基準時刻:
+ arg2_basetime = new ParameterPanelTime(
+ i18n.getString("label.310"),
+ null,
+ arg2_baseTimeImg
+ );
+ arg2_basetime.argField.getDocument().addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(1, arg2_basetime.isEnable());
}
- );
+ }
+ );
- CardFirstFile card = new CardFirstFile(cardPanel, arg2_baseTimeImg);
+ CardImageFile card = new CardImageFile(cardPanel, arg2_basetime, this, true);
cardPanel.addTab(card.getTitle(), card);
cardPanel.setEnabledAt(cardNo, false);
cards[cardNo] = card;
}
//---------------------------------------------------------------------
- // 2a. 開始画像の本当の時刻を設定の入力画面
+ // 3. 最終画像の本当の時刻を設定の入力画面
{
- // 2a. 基準時刻:
- arg2_basetime = new ParameterPanelTime(
+ // 基準時刻画像
+ arg3_baseTimeImg = new ParameterPanelImageFile(
+ i18n.getString("label.210") +": ",
+ null,
+ arg1_srcFolder
+ );
+
+ // 3a. 基準時刻:
+ arg3_basetime = new ParameterPanelTime(
i18n.getString("label.310"),
null,
- arg2_baseTimeImg
+ arg3_baseTimeImg
);
- arg2_basetime.argField
- .getDocument()
- .addDocumentListener(
- new SimpleDocumentListener() {
- @Override
- public void update(DocumentEvent e) {
- toEnable(2, arg2_basetime.isEnable());
- }
+ arg3_basetime.argField.getDocument().addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(2, arg3_basetime.isEnable());
}
- );
+ }
+ );
- CardCorectTime card = new CardCorectTime(cardPanel, arg2_basetime);
+ CardImageFile card = new CardImageFile(cardPanel, arg3_basetime, this, false);
cardPanel.addTab(card.getTitle(), card);
cardPanel.setEnabledAt(cardNo, false);
cards[cardNo] = card;
setTitle(title);
}
+ // Used for addNotify redundency check.
+ boolean fComponentsAdjusted = false;
+
@Override
public void addNotify() {
// Record the size of the window prior to calling parents addNotify.
-
super.addNotify();
// Only do this once.
}
super.setVisible(b);
}
-
- void AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
- dispose();
- }
-
- void closeButton_Clicked(java.awt.event.ActionEvent event) {
- //{{CONNECTION
- // Clicked from okButton Hide the Dialog
- dispose();
- //}}
- }
-
- ImageIcon refImage;
-
- /**
- * 選択された画像ファイルを表示する
- * 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。
- * @param ev
- */
- @SuppressWarnings("UseSpecificCatch")
- public void imageView_Action(ActionEvent ev) {
- String path = (new File(arg1_srcFolder.getText(), arg2_baseTimeImg.getText())).getPath();
-
- File timeFile = new File(path);
- long lastModifyTime = timeFile.lastModified();
- arg2_basetime.argField.setText(AdjustTime.dfjp.format(new Date(lastModifyTime)));
-
- int size_x = imageSPane.getWidth() - 8;
- ImageIcon tmpIcon = new ImageIcon(path);
- refImage = tmpIcon;
- if (tmpIcon.getIconWidth() > size_x) {
- refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x, -1, Image.SCALE_DEFAULT));
- }
- imageLabel.setIcon(refImage);
- repaint();
- }
-
- public void selectImage_Action(ActionEvent ev) {
- JFileChooser fc;
-
- File sdir = new File(arg1_srcFolder.getText());
- System.out.println(sdir.getPath());
- if (sdir.isDirectory()) {
- fc = new JFileChooser(sdir);
- }
- else {
- fc = new JFileChooser();
- }
-
- fc.addChoosableFileFilter(new ImageFilter());
- fc.setAcceptAllFileFilterUsed(false);
- fc.setFileView(new ImageFileView());
- fc.setAccessory(new ImagePreview(fc));
-
- //Show it. "選択"
- int returnVal = fc.showDialog(this, i18n.getString("dialog.select"));
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- arg2_baseTimeImg.argField.setText(file.getName());
- }
- fc.setSelectedFile(null);
- }
}