import osm.jp.gpx.matchtime.gui.restamp.RestampDialog;
import java.awt.*;
import java.awt.event.ActionEvent;
-import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.ResourceBundle;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
+import javax.swing.event.DocumentEvent;
import osm.jp.gpx.*;
-import org.apache.commons.imaging.Imaging;
-import org.apache.commons.imaging.common.ImageMetadata;
-import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
-import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
-import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
+import osm.jp.gpx.matchtime.gui.restamp.CardImageFile;
+import osm.jp.gpx.matchtime.gui.restamp.CardSourceFolder;
/**
* 本プログラムのメインクラス
//{{DECLARE_CONTROLS
JTabbedPane cardPanel; // ウィザード形式パネル(タブ型)
- JPanel[] cards;
+ Card[] cards;
int cardPanelNo = 0;
JPanel argsPanel; // パラメータ設定パネル (上部)
JScrollPane imageSPane; // スクロールパネル
JLabel imageLabel; // 基準時刻画像表示
- ButtonGroup baseTimeGroup; // 基準時刻の指定グループ
- JRadioButton exifBase; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする)
- JRadioButton fupdateBase; // File更新日時を基準にする/ !(EXIF日時を基準にする)
+ //ButtonGroup baseTimeGroup; // 基準時刻の指定グループ
+ //JRadioButton exifBase; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする)
+ //JRadioButton fupdateBase; // File更新日時を基準にする/ !(EXIF日時を基準にする)
JCheckBox noFirstNode; // GPX: <trkseg>セグメントの最初の1ノードは無視する。 {ON | OFF}
JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF}
JTextArea textArea; // 実行結果表示領域
- ParameterPanelFolder arg1_srcFolder;
- ParameterPanelImageFile arg2_baseTimeImg;
+
ParameterPanel arg3_basetime; // 基準時刻:
JCheckBox outputIMG; // IMGの変換 する/しない
JCheckBox outputIMG_all; // 'out of GPX time'でもIMGの変換をする {ON | OFF}
ParameterPanelGpx arg4_gpxFolder; // GPXファイル・フォルダ
JPanel buttonPanel; // ボタンパネル (下部)
- JButton openButton; // [Fit]ボタン
- JButton zoomInButton; // [Zoom in]ボタン
- JButton zoomOutButton; // [Zoom out]ボタン
+ //JButton openButton; // [Fit]ボタン
+ //JButton zoomInButton; // [Zoom in]ボタン
+ //JButton zoomOutButton; // [Zoom out]ボタン
JButton doButton; // [処理実行]ボタン
//}}
+ //---入力フィールド----------------------------------------------------
+ ParameterPanelFolder arg1_srcFolder; // 対象フォルダ
+ ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス
+ ParameterPanelTime arg2_basetime; // 開始画像の基準時刻:
+
//{{DECLARE_MENUS
java.awt.MenuBar mainMenuBar;
java.awt.Menu menu1;
else if (object == miExit) {
miExit_Action(event);
}
+ /*
else if (object == openButton) {
imageView_Action(event);
}
selectImage_Action(event);
imageView_Action(event);
}
+ */
else if (object == outputIMG) {
outputIMG_Action(event);
}
cardPanel = new JTabbedPane(JTabbedPane.LEFT);
mainPanel.add(cardPanel, BorderLayout.CENTER);
- cards = new JPanel[5];
- cardPanelNo = 0;
+ cards = new Card[5];
+ int cardNo = 0;
//---------------------------------------------------------------------
// 1.[対象フォルダ]設定パネル
- int cardNo = 0;
{
- Card card = new Card(cardPanel, i18n.getString("tab.100"), -1, 1);
+ arg1_srcFolder = new ParameterPanelFolder(
+ i18n.getString("label.110") +": ",
+ params.getProperty(AppParameters.IMG_SOURCE_FOLDER)
+ );
+ arg1_srcFolder.argField
+ .getDocument()
+ .addDocumentListener(
+ new SimpleDocumentListener() {
+ @Override
+ public void update(DocumentEvent e) {
+ toEnable(0, arg1_srcFolder.isEnable());
+ }
+ }
+ );
+
+ Card card = new CardSourceFolder(cardPanel, arg1_srcFolder);
cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, true);
cards[cardNo] = card;
-
- JLabel label1 = new JLabel();
- label1.setText(i18n.getString("label.100"));
- card.mainPanel.add(label1, BorderLayout.NORTH);
-
- argsPanel = new JPanel();
- argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
- arg1_srcFolder = new ParameterPanelFolder(i18n.getString("label.110") +": ", params.getProperty(AppParameters.IMG_SOURCE_FOLDER));
- argsPanel.add(arg1_srcFolder);
- card.mainPanel.add(argsPanel, BorderLayout.CENTER);
+ cardNo++;
}
//---------------------------------------------------------------------
// 2.[基準時刻画像]設定パネル
- cardNo++;
+ // 2a.基準時刻の入力画面
{
- Card card = new Card(cardPanel, i18n.getString("tab.200"), 0, 2);
- cardPanel.addTab(card.getTitle(), card);
- cards[cardNo] = card;
-
- JLabel label2 = new JLabel();
- label2.setText(i18n.getString("label.200"));
- card.mainPanel.add(label2, BorderLayout.NORTH);
-
- argsPanel = new JPanel();
-
// 基準時刻画像
- argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
arg2_baseTimeImg = new ParameterPanelImageFile(
i18n.getString("label.210") +": ",
- params.getProperty(AppParameters.IMG_BASE_FILE),
+ null,
arg1_srcFolder
);
- argsPanel.add(arg2_baseTimeImg);
-
- baseTimeGroup = new ButtonGroup();
+ // 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());
+ }
+ }
+ );
+
// EXIFの日時を基準にする
- exifBase = new JRadioButton(i18n.getString("label.220"));
+ arg2_basetime.addExifBase(i18n.getString("label.220"), params);
+ //exifBase = new JRadioButton(i18n.getString("label.220"));
// ファイル更新日時を基準にする
- fupdateBase = new JRadioButton(i18n.getString("label.230"));
- baseTimeGroup.add(exifBase);
- baseTimeGroup.add(fupdateBase);
- argsPanel.add(exifBase);
- argsPanel.add(fupdateBase);
- if (params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME")) {
- fupdateBase.setSelected(false);
- exifBase.setSelected(true);
- }
- else {
- fupdateBase.setSelected(true);
- exifBase.setSelected(false);
- }
- card.mainPanel.add(argsPanel, BorderLayout.CENTER);
+ arg2_basetime.addFileUpdate(i18n.getString("label.230"), params);
+ //fupdateBase = new JRadioButton(i18n.getString("label.230"));
+
+ //baseTimeGroup = new ButtonGroup();
+ //baseTimeGroup.add(exifBase);
+ //baseTimeGroup.add(fupdateBase);
+ //argsPanel.add(exifBase);
+ //argsPanel.add(fupdateBase);
+ //if (params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME")) {
+ // fupdateBase.setSelected(false);
+ // exifBase.setSelected(true);
+ //}
+ //else {
+ // fupdateBase.setSelected(true);
+ // exifBase.setSelected(false);
+ //}
+
+ //JLabel label2 = new JLabel();
+ //label2.setText(i18n.getString("label.200"));
+ //card.mainPanel.add(label2, BorderLayout.NORTH);
+ //card.mainPanel.add(argsPanel, BorderLayout.CENTER);
+
+ CardImageFile card = new CardImageFile(
+ cardPanel, arg2_basetime, (Window)this,
+ AdjustTime.i18n.getString("tab.300"), 0, 2);
+ cardPanel.addTab(card.getTitle(), card);
+ cardPanel.setEnabledAt(cardNo, false);
+ cards[cardNo] = card;
+ cardNo++;
}
//---------------------------------------------------------------------
// 2a.基準時刻の入力画面
- cardNo++;
{
Card card = new Card(cardPanel, i18n.getString("tab.300"), 1, 3);
cardPanel.addTab(card.getTitle(), card);
// 3. 正確な撮影時刻を入力してください。
// カメラの時計が正確ならば、設定を変更する必要はありません。
+ /*
JLabel label3 = new JLabel();
label3.setText(i18n.getString("label.300"));
argsPanel.add(label3);
-
+ */
+
// 基準時刻:
+ /*
String str310 = String.format(" %s: ", i18n.getString("label.310"));
arg3_basetime = new ParameterPanelTime(
str310,
);
argsPanel.add(arg3_basetime);
card.mainPanel.add(argsPanel, BorderLayout.NORTH);
+ */
// 参考画像
+ /*
imageLabel = new JLabel();
imageSPane = new JScrollPane(imageLabel);
card.mainPanel.add(imageSPane, BorderLayout.CENTER);
+ */
// 画像ファイル選択ダイアログを起動するボタン
+ /*
buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
openButton = new JButton(createImageIcon("images/Fit16.gif"));
zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
buttonPanel.add(zoomOutButton);
card.mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ */
}
//---------------------------------------------------------------------
// 3.GPXファイル設定画面
- cardNo++;
{
// 3. GPXファイルを選択
Card card = new Card(cardPanel, i18n.getString("tab.400"), 2, 4);
gpxReuse.setEnabled(true);
tmpPanel4a.add(gpxReuse);
card.mainPanel.add(tmpPanel4a, BorderLayout.CENTER);
+ cardNo++;
}
//---------------------------------------------------------------------
// 4.EXIF更新設定画面
- cardNo++;
{
Card card = new Card(cardPanel, i18n.getString("tab.500"), 3, -1);
cardPanel.addTab(card.getTitle(), card);
AdjustTime.createImageIcon("images/media_playback_start.png")
);
card.mainPanel.add(doButton, BorderLayout.SOUTH);
+ cardNo++;
}
//---------------------------------------------------------------------
miAbout.addActionListener(lSymAction);
miRestamp.addActionListener(lSymAction);
miExit.addActionListener(lSymAction);
+ /*
openButton.addActionListener(lSymAction);
zoomOutButton.addActionListener(lSymAction);
zoomInButton.addActionListener(lSymAction);
+ */
//arg2_baseTimeImg.argField.addActionListener(lSymAction);
arg2_baseTimeImg.openButton.addActionListener(lSymAction);
doButton.addActionListener(lSymAction);
//(new hayashi.yuu.tools.gui.QuitDialog(this, true)).setVisible(true);
(new QuitDialog(this, true)).setVisible(true);
}
+
+ void toEnable(final int cardNo, final boolean enable) {
+ if ((cardNo >= 0) && (cardNo < cards.length)) {
+ cardPanel.setEnabledAt(cardNo, enable);
+ if ((cardNo -1) >= 0) {
+ cards[cardNo -1].nextButton.setEnabled(enable);
+ }
+ if ((cardNo +1) < cards.length) {
+ cardPanel.setEnabledAt(cardNo+1, enable);
+ cards[cardNo +1].backButton.setEnabled(enable);
+ cards[cardNo].nextButton.setEnabled(enable);
+ }
+ }
+ }
ImageIcon refImage;
* 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。
* @param ev
*/
+ /*
@SuppressWarnings("UseSpecificCatch")
public void imageView_Action(ActionEvent ev) {
String path = (new File(arg1_srcFolder.getText(), arg2_baseTimeImg.getText())).getPath();
imageLabel.setIcon(refImage);
repaint();
}
+ */
+ /*
public void zoomin_Action(ActionEvent ev) {
if (refImage != null) {
int size_x = imageLabel.getWidth();
repaint();
}
}
+ */
+ /*
public void zoomout_Action(ActionEvent ev) {
if (refImage != null) {
int size_x = imageLabel.getWidth();
repaint();
}
}
+ */
/**
* ソースディレクトリが選択された時のアクション
public void selectSource_Action(ActionEvent ev) {
}
+ /*
public void selectImage_Action(ActionEvent ev) {
JFileChooser fc;
//Reset the file chooser for the next time it's shown.
fc.setSelectedFile(null);
}
+ */
/** Returns an ImageIcon, or null if the path was invalid.
* @param path
this.params.setProperty(AppParameters.GPX_NO_FIRST_NODE, String.valueOf(noFirstNode.isSelected()));
this.params.setProperty(AppParameters.GPX_REUSE, String.valueOf(gpxReuse.isSelected()));
this.params.setProperty(AppParameters.GPX_SOURCE_FOLDER, arg4_gpxFolder.getText());
-
+ /*
if (exifBase.isSelected()) {
this.params.setProperty(AppParameters.GPX_BASETIME, "EXIF_TIME");
}
else {
this.params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
}
+ */
try {
this.params.setProperty(AppParameters.IMG_SOURCE_FOLDER, arg1_srcFolder.getText());
this.params.setProperty(AppParameters.IMG_BASE_FILE, arg2_baseTimeImg.getText());
package osm.jp.gpx.matchtime.gui;
-import java.awt.Dialog;
+import java.awt.Window;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import javax.swing.ButtonGroup;
import javax.swing.JButton;
+import javax.swing.JRadioButton;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
+import osm.jp.gpx.AppParameters;
import osm.jp.gpx.Restamp;
+import static osm.jp.gpx.matchtime.gui.AdjustTime.dfjp;
import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime;
/**
*/
public class ParameterPanelTime extends ParameterPanel {
SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance();
- ParameterPanelImageFile imageFile;
+ ParameterPanelImageFile imageFile; // 基準時刻画像
+
+
+ // 基準時刻の指定グループ (排他選択)
+ public ButtonGroup baseTimeGroup = new ButtonGroup();
+ public JRadioButton exifBase = null; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする)
+ public JRadioButton fupdateBase = null; // File更新日時を基準にする/ !(EXIF日時を基準にする)
+
public JButton updateButton;
public JButton resetButton;
- Dialog owner;
+ Window owner;
@SuppressWarnings("OverridableMethodCallInConstructor")
public ParameterPanelTime(
this.add(resetButton);
}
- public ParameterPanelTime setOwner(Dialog owner) {
+ public ParameterPanelTime setOwner(Window owner) {
this.owner = owner;
return this;
}
/**
- * ボタンのアクション
+ * 「EXIFの日時を基準にする」
+ * @param label テキスト
+ * @param params プロパティ
+ */
+ public void addExifBase(String label, AppParameters params) {
+ boolean selected = false;
+ if (params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME")) {
+ selected = true;
+ }
+ exifBase = new JRadioButton(label, selected);
+ baseTimeGroup.add(exifBase);
+ }
+
+ /**
+ * 「File更新日時を基準にする」
+ * @param label テキスト
+ * @param params プロパティ
+ */
+ public void addFileUpdate(String label, AppParameters params) {
+ boolean selected = false;
+ if (params.getProperty(AppParameters.GPX_BASETIME).equals("FILE_UPDATE_TIME")) {
+ selected = true;
+ }
+ fupdateBase = new JRadioButton(label, selected);
+ baseTimeGroup.add(fupdateBase);
+ }
+
+ public ParameterPanelImageFile getImageFile() {
+ return this.imageFile;
+ }
+
+
+ /**
+ * [変更...]ボタンのアクション
*/
class UpdateButtonAction implements java.awt.event.ActionListener
{
@SuppressWarnings("override")
public void actionPerformed(ActionEvent e) {
+ fileSelect_Action(param);
(new DialogCorectTime(param, owner)).setVisible(true);
}
}
/**
- * ボタンのアクション
+ * [再設定...]ボタンのアクション
*/
class ResetButtonAction implements java.awt.event.ActionListener
{
- ParameterPanelTime param;
+ ParameterPanelTime paramPanelTime;
public ResetButtonAction(ParameterPanelTime param) {
- this.param = param;
+ this.paramPanelTime = param;
}
@SuppressWarnings("override")
public void actionPerformed(ActionEvent e) {
- if (param.imageFile.isEnable()) {
- File file = param.imageFile.getImageFile();
- long lastModified = file.lastModified();
- sdf.applyPattern(Restamp.TIME_PATTERN);
- param.argField.setText(sdf.format(new Date(lastModified)));
+ fileSelect_Action(paramPanelTime);
+ }
+ }
+
+ /**
+ * 画像ファイルが選択されたときのアクション
+ * 1.ラジオボタンの選択を参照してTEXTフィールドにファイルの「日時」を設定する
+ * @param param
+ */
+ void fileSelect_Action(ParameterPanelTime param) {
+ if (imageFile.isEnable()) {
+ File timeFile = imageFile.getImageFile();
+
+ // Radio Selecter
+ sdf.applyPattern(Restamp.TIME_PATTERN);
+ if ((exifBase != null) && exifBase.isSelected()) {
+ try {
+ ImageMetadata meta = Imaging.getMetadata(timeFile);
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+ if (jpegMetadata != null) {
+ TiffImageMetadata exif = jpegMetadata.getExif();
+ if (exif != null) {
+ String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];
+ long lastModifyTime = sdf.parse(dateTimeOriginal).getTime();
+ param.argField.setText(dfjp.format(new Date(lastModifyTime)));
+ }
+ else {
+ param.argField.setText("exif == null");
+ }
+ }
+ }
+ catch (Exception ex) {
+ while(true);
+ }
}
else {
- param.argField.setText("");
+ long lastModified = timeFile.lastModified();
+ param.argField.setText(sdf.format(new Date(lastModified)));
}
}
+ else {
+ param.argField.setText("");
+ }
}
- public ParameterPanelImageFile getImageFile() {
- return this.imageFile;
- }
-
@Override
public boolean isEnable() {
if (this.imageFile.isEnable()) {
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.io.File;
+import java.awt.Window;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
*/
public class DialogCorectTime extends JDialog implements PanelAction {
public JPanel mainPanel;
- ParameterPanelTime arg_basetime; // 開始画像の基準時刻:
- ParameterPanelTime basetime; // 開始画像の基準時刻:
+ ParameterPanelTime arg_basetime; // 開始画像の基準時刻(parent)
+ ParameterPanelTime basetime; // 開始画像の基準時刻(tempolarry)
java.awt.Button closeButton;
JButton expandButton;
JButton zoomInButton;
* @param owner
*/
@SuppressWarnings("OverridableMethodCallInConstructor")
- public DialogCorectTime(ParameterPanelTime arg3_basetime, Dialog owner) {
- super(owner, AdjustTime.i18n.getString("tab.restamp.300"), false);
+ public DialogCorectTime(ParameterPanelTime arg3_basetime, Window owner) {
+ super(owner, AdjustTime.i18n.getString("tab.restamp.300"), Dialog.ModalityType.DOCUMENT_MODAL);
this.arg_basetime = arg3_basetime;
// INIT_CONTROLS
argsPanel.add(label3);
basetime = new ParameterPanelTime(
- arg3_basetime.argLabel.getText(),
+ arg_basetime.argLabel.getText(),
"",
- arg3_basetime.getImageFile()
+ arg_basetime.getImageFile()
);
basetime.updateButton.setVisible(false);
basetime.resetButton.setVisible(true);
*/
@SuppressWarnings("UseSpecificCatch")
public void imageView_Action() {
+ String path = basetime.getImageFile().getImageFile().getAbsolutePath();
+
+ // Radio Selecter
+ /*
+ File timeFile = new File(path);
+ if ((arg_basetime.exifBase != null) && arg_basetime.exifBase.isSelected()) {
+ try {
+ ImageMetadata meta = Imaging.getMetadata(timeFile);
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+ if (jpegMetadata != null) {
+ TiffImageMetadata exif = jpegMetadata.getExif();
+ if (exif != null) {
+ String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];
+ long lastModifyTime = (new SimpleDateFormat("yyyy:MM:dd HH:mm:ss")).parse(dateTimeOriginal).getTime();
+ arg_basetime.argField.setText(dfjp.format(new Date(lastModifyTime)));
+ }
+ else {
+ arg_basetime.argField.setText("exif == null");
+ }
+ }
+ }
+ catch (Exception e) {}
+ }
+ else {
+ long lastModifyTime = timeFile.lastModified();
+ arg_basetime.argField.setText(dfjp.format(new Date(lastModifyTime)));
+ }
+ */
+
+ // View Image File
int size_x = imageSPane.getWidth() - 8;
- String path = arg_basetime.getImageFile().getImageFile().getAbsolutePath();
ImageIcon tmpIcon = new ImageIcon(path);
refImage = tmpIcon;
if (tmpIcon.getIconWidth() > size_x) {
public void zoomin_Action() {
if (refImage != null) {
int size_x = imageLabel.getWidth();
- String path = arg_basetime.getImageFile().getImageFile().getAbsolutePath();
+ String path = basetime.getImageFile().getImageFile().getAbsolutePath();
ImageIcon tmpIcon = new ImageIcon(path);
refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x * 2, -1, Image.SCALE_DEFAULT));
imageLabel.setIcon(refImage);
*/
@Override
public boolean isEnable() {
- return this.arg_basetime.isEnable();
+ return this.basetime.isEnable();
}
}