From 5e457a6c11328afbb8b6eccfba0b04b12b9bcdf6 Mon Sep 17 00:00:00 2001 From: haya4 Date: Sun, 20 Oct 2019 12:08:05 +0900 Subject: [PATCH] =?utf8?q?doing:=20AdjustTime=20-=20=EF=BC=91=E3=80=9C?= =?utf8?q?=EF=BC=92=E3=83=91=E3=83=8D=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/osm/jp/gpx/matchtime/gui/AdjustTime.java | 189 ++++++++++++++------- .../gpx/matchtime/gui/ParameterPanelImageFile.java | 2 +- .../jp/gpx/matchtime/gui/ParameterPanelTime.java | 115 +++++++++++-- .../gpx/matchtime/gui/restamp/CardImageFile.java | 29 +++- .../matchtime/gui/restamp/DialogCorectTime.java | 50 ++++-- .../gpx/matchtime/gui/restamp/RestampDialog.java | 10 +- 6 files changed, 289 insertions(+), 106 deletions(-) diff --git a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java index d0a3fd7..a5fa756 100644 --- a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java +++ b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java @@ -3,21 +3,17 @@ package osm.jp.gpx.matchtime.gui; 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; /** * 本プログラムのメインクラス @@ -38,19 +34,18 @@ public class AdjustTime extends JFrame //{{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: セグメントの最初の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} @@ -62,13 +57,18 @@ public class AdjustTime extends JFrame 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; @@ -113,6 +113,7 @@ public class AdjustTime extends JFrame else if (object == miExit) { miExit_Action(event); } + /* else if (object == openButton) { imageView_Action(event); } @@ -129,6 +130,7 @@ public class AdjustTime extends JFrame selectImage_Action(event); imageView_Action(event); } + */ else if (object == outputIMG) { outputIMG_Action(event); } @@ -190,76 +192,98 @@ public class AdjustTime extends JFrame 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); @@ -270,11 +294,14 @@ public class AdjustTime extends JFrame // 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, @@ -283,13 +310,17 @@ public class AdjustTime extends JFrame ); 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")); @@ -299,11 +330,11 @@ public class AdjustTime extends JFrame 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); @@ -341,11 +372,11 @@ public class AdjustTime extends JFrame 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); @@ -428,6 +459,7 @@ public class AdjustTime extends JFrame AdjustTime.createImageIcon("images/media_playback_start.png") ); card.mainPanel.add(doButton, BorderLayout.SOUTH); + cardNo++; } //--------------------------------------------------------------------- @@ -465,9 +497,11 @@ public class AdjustTime extends JFrame 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); @@ -552,6 +586,20 @@ public class AdjustTime extends JFrame //(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; @@ -560,6 +608,7 @@ public class AdjustTime extends JFrame * 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。 * @param ev */ + /* @SuppressWarnings("UseSpecificCatch") public void imageView_Action(ActionEvent ev) { String path = (new File(arg1_srcFolder.getText(), arg2_baseTimeImg.getText())).getPath(); @@ -597,7 +646,9 @@ public class AdjustTime extends JFrame imageLabel.setIcon(refImage); repaint(); } + */ + /* public void zoomin_Action(ActionEvent ev) { if (refImage != null) { int size_x = imageLabel.getWidth(); @@ -608,7 +659,9 @@ public class AdjustTime extends JFrame repaint(); } } + */ + /* public void zoomout_Action(ActionEvent ev) { if (refImage != null) { int size_x = imageLabel.getWidth(); @@ -618,6 +671,7 @@ public class AdjustTime extends JFrame repaint(); } } + */ /** * ソースディレクトリが選択された時のアクション @@ -627,6 +681,7 @@ public class AdjustTime extends JFrame public void selectSource_Action(ActionEvent ev) { } + /* public void selectImage_Action(ActionEvent ev) { JFileChooser fc; @@ -663,6 +718,7 @@ public class AdjustTime extends JFrame //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 @@ -727,13 +783,14 @@ public class AdjustTime extends JFrame 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()); diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java index 84e40e7..2c99c17 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java @@ -56,7 +56,7 @@ public class ParameterPanelImageFile extends ParameterPanel { int returnVal = fc.showDialog(ParameterPanelImageFile.this, i18n.getString("dialog.select")); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); - argField.setText(file.getName()); + this.argField.setText(file.getName()); } fc.setSelectedFile(null); } diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java index e540e03..8b21ccb 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java @@ -1,13 +1,22 @@ 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; /** @@ -16,10 +25,17 @@ 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( @@ -44,13 +60,46 @@ public class ParameterPanelTime extends ParameterPanel { 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 { @@ -62,39 +111,69 @@ public class ParameterPanelTime extends ParameterPanel { @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()) { diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java index ca65bf0..836ed9e 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java @@ -2,12 +2,11 @@ package osm.jp.gpx.matchtime.gui.restamp; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.Dialog; +import java.awt.Window; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; -import osm.jp.gpx.matchtime.gui.AdjustTime; import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n; import osm.jp.gpx.matchtime.gui.Card; import osm.jp.gpx.matchtime.gui.PanelAction; @@ -28,19 +27,23 @@ public class CardImageFile extends Card implements PanelAction { * @param tabbe parent panel * @param arg_basetime // 開始画像の基準時刻: * @param owner - * @param first // true=開始画像, false=終了画像 + * @param text + * @param pre + * @param next */ public CardImageFile( JTabbedPane tabbe, ParameterPanelTime arg_basetime, - Dialog owner, - boolean first + Window owner, + String text, + int pre, int next ) { super( tabbe, - AdjustTime.i18n.getString(first ? "tab.restamp.200" : "tab.restamp.250"), - (first ? 0 : 1), - (first ? 2 : 3) + //AdjustTime.i18n.getString(first ? "tab.restamp.200" : "tab.restamp.250"), + text, pre, next + //(first ? 0 : 1), + //(first ? 2 : 3) ); arg_basetime.setOwner(owner); this.arg_baseTimeImg = arg_basetime.getImageFile(); @@ -58,6 +61,16 @@ public class CardImageFile extends Card implements PanelAction { argsPanel.add(packLine(new JLabel(i18n.getString("label.300")), new JPanel())); argsPanel.add(arg_basetime); + // ラジオボタン: 「EXIF日時を基準にする」 + if (arg_basetime.exifBase != null) { + argsPanel.add(arg_basetime.exifBase); + } + + // ラジオボタン: 「File更新日時を基準にする」 + if (arg_basetime.fupdateBase != null) { + argsPanel.add(arg_basetime.fupdateBase); + } + JPanel space = new JPanel(); space.setMinimumSize(new Dimension(40, 20)); space.setMaximumSize(new Dimension(40, Short.MAX_VALUE)); diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java b/src/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java index cc4dea3..175a2f1 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java @@ -5,8 +5,7 @@ import java.awt.Dialog; 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; @@ -26,8 +25,8 @@ import osm.jp.gpx.matchtime.gui.ParameterPanelTime; */ 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; @@ -41,8 +40,8 @@ public class DialogCorectTime extends JDialog implements PanelAction { * @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 @@ -69,9 +68,9 @@ public class DialogCorectTime extends JDialog implements PanelAction { 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); @@ -155,8 +154,37 @@ public class DialogCorectTime extends JDialog implements PanelAction { */ @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) { @@ -169,7 +197,7 @@ public class DialogCorectTime extends JDialog implements PanelAction { 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); @@ -219,6 +247,6 @@ public class DialogCorectTime extends JDialog implements PanelAction { */ @Override public boolean isEnable() { - return this.arg_basetime.isEnable(); + return this.basetime.isEnable(); } } diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java index dd11a0f..7c0d218 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java @@ -6,6 +6,7 @@ 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.ParameterPanelFolder; import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; @@ -152,7 +153,9 @@ public class RestampDialog extends JDialog implements Observer } ); - CardImageFile card = new CardImageFile(cardPanel, arg2_basetime, this, true); + CardImageFile card = new CardImageFile( + cardPanel, arg2_basetime, (Window)this, + AdjustTime.i18n.getString("tab.restamp.200"), 0, 2); cardPanel.addTab(card.getTitle(), card); cardPanel.setEnabledAt(cardNo, false); cards[cardNo] = card; @@ -184,7 +187,10 @@ public class RestampDialog extends JDialog implements Observer } ); - CardImageFile card = new CardImageFile(cardPanel, arg3_basetime, this, false); + CardImageFile card = new CardImageFile( + cardPanel, arg3_basetime, (Window)this, + AdjustTime.i18n.getString("tab.restamp.250"), 1, 3 + ); cardPanel.addTab(card.getTitle(), card); cardPanel.setEnabledAt(cardNo, false); cards[cardNo] = card; -- 2.11.0