diff --git a/src/i18n.properties b/src/i18n.properties index af470a9..ebda465 100644 --- a/src/i18n.properties +++ b/src/i18n.properties @@ -3,6 +3,10 @@ dialog.msg1=Quit this program. dialog.select=Selection +menu.tools=Tools +menu.restamp=Restamp +button.close=Close + menu.quit=Quit? button.next=Next button.previous=Previous @@ -14,13 +18,16 @@ label.110=Image Folder tab.200=2. Set correct shooting time +tab.restamp.200=2. Set correct shooting time (start) label.200=

2. Choose an image whose exact shooting time can be known.

label.210=Reference time image label.220=Based on EXIF date and time label.230=Based on FILE UPDATE time tab.300=2a. Set correct shooting time +tab.restamp.300=2a. Set correct shooting time (start) label.300=

3. enter the correct shooting time.

label.310=Reference time +label.restamp.310=Reference time (start) tab.400=3. Select GPX files label.400=

4. Please select a GPX file to perform the matching.

diff --git a/src/i18n_ja_JP.properties b/src/i18n_ja_JP.properties index 7504efd..7c93dba 100644 --- a/src/i18n_ja_JP.properties +++ b/src/i18n_ja_JP.properties @@ -3,6 +3,10 @@ dialog.msg1=\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002 dialog.select=\u9078\u629e +menu.tools=\u30c4\u30fc\u30eb +menu.restamp=Restamp +button.close=\u9589\u3058\u308b + menu.quit=\u7d42\u4e86... button.next=\u6b21\u3078 button.previous=\u623b\u308b @@ -14,14 +18,17 @@ label.110=\u5bfe\u8c61\u30d5\u30a9\u30eb\u30c0 tab.200=2. \u57fa\u6e96\u3068\u3059\u308b\u753b\u50cf\u306e\u9078\u629e +tab.restamp.200=2. \u57fa\u6e96\u3068\u3059\u308b\u753b\u50cf(\u958b\u59cb\u753b\u50cf)\u306e\u9078\u629e label.200=

2. \u6b63\u78ba\u306a\u64ae\u5f71\u6642\u523b\u304c\u5224\u660e\u3067\u304d\u308b\u753b\u50cf\u3092\u9078\u3093\u3067\u304f\u3060\u3055\u3044\u3002

label.210=\u57fa\u6e96\u6642\u523b\u753b\u50cf label.220=EXIF\u306e\u65e5\u6642\u3092\u57fa\u6e96\u306b\u3059\u308b label.230=\u30d5\u30a1\u30a4\u30eb\u66f4\u65b0\u65e5\u6642\u3092\u57fa\u6e96\u306b\u3059\u308b tab.300=2a. \u672c\u5f53\u306e\u6642\u523b\u3092\u8a2d\u5b9a +tab.restamp.300=2a. \u958b\u59cb\u753b\u50cf\u306e\u672c\u5f53\u306e\u6642\u523b\u3092\u8a2d\u5b9a label.300=

3. \u6b63\u78ba\u306a\u64ae\u5f71\u6642\u523b\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002

label.310=\u57fa\u6e96\u6642\u523b +label.restamp.310=\u57fa\u6e96\u6642\u523b(\u958b\u59cb\u753b\u50cf) tab.400=3. GPX\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e label.400=

4. \u30d2\u30e2\u4ed8\u3092\u884c\u3046GPX\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002

diff --git a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java index 999f895..3029c3a 100644 --- a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java +++ b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java @@ -1,5 +1,6 @@ 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; @@ -8,6 +9,8 @@ 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 osm.jp.gpx.*; import org.apache.commons.imaging.Imaging; @@ -24,14 +27,14 @@ { public static final String PROGRAM_NAME = "AdjustTime for JOSM"; public static final String PROGRAM_VARSION = "5.01"; - public static final String PROGRAM_UPDATE = "2019/08/25"; + public static final String PROGRAM_UPDATE = "2019/09/11"; AppParameters params; - SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + public static SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); // Used for addNotify check. boolean fComponentsAdjusted = false; - public ResourceBundle i18n = ResourceBundle.getBundle("i18n"); + public static ResourceBundle i18n = ResourceBundle.getBundle("i18n"); //{{DECLARE_CONTROLS JTabbedPane cardPanel; // ウィザード形式パネル(タブ型) @@ -73,6 +76,8 @@ java.awt.MenuItem miDoDirSize; java.awt.MenuItem miDoReadXML; java.awt.MenuItem miExit; + java.awt.Menu menu2; + java.awt.MenuItem miRestamp; java.awt.Menu menu3; java.awt.MenuItem miAbout; //}} @@ -98,6 +103,13 @@ if (object == miAbout) { miAbout_Action(event); } + else if (object == miRestamp) { + try { + miRestamp_Action(event); + } catch (IOException ex) { + Logger.getLogger(AdjustTime.class.getName()).log(Level.SEVERE, null, ex); + } + } else if (object == miExit) { miExit_Action(event); } @@ -216,7 +228,11 @@ // 基準時刻画像 argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS)); - arg2_baseTimeImg = new ParameterPanelImageFile(i18n.getString("label.210") +": ", params.getProperty(AppParameters.IMG_BASE_FILE), arg1_srcFolder); + arg2_baseTimeImg = new ParameterPanelImageFile( + i18n.getString("label.210") +": ", + params.getProperty(AppParameters.IMG_BASE_FILE), + arg1_srcFolder + ); argsPanel.add(arg2_baseTimeImg); baseTimeGroup = new ButtonGroup(); @@ -416,6 +432,13 @@ miExit.setFont(new Font("Dialog", Font.PLAIN, 12)); menu1.add(miExit); + miRestamp = new java.awt.MenuItem(i18n.getString("menu.restamp") + "..."); + miRestamp.setFont(new Font("Dialog", Font.PLAIN, 12)); + + menu2 = new java.awt.Menu(i18n.getString("menu.tools")); + menu2.setFont(new Font("Dialog", Font.PLAIN, 12)); + menu2.add(miRestamp); + miAbout = new java.awt.MenuItem("About..."); miAbout.setFont(new Font("Dialog", Font.PLAIN, 12)); @@ -426,6 +449,7 @@ mainMenuBar = new java.awt.MenuBar(); mainMenuBar.setHelpMenu(menu3); mainMenuBar.add(menu1); + mainMenuBar.add(menu2); mainMenuBar.add(menu3); setMenuBar(mainMenuBar); @@ -434,6 +458,7 @@ this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); miAbout.addActionListener(lSymAction); + miRestamp.addActionListener(lSymAction); miExit.addActionListener(lSymAction); openButton.addActionListener(lSymAction); zoomOutButton.addActionListener(lSymAction); @@ -513,6 +538,10 @@ (new AboutDialog(this, true)).setVisible(true); } + void miRestamp_Action(java.awt.event.ActionEvent event) throws IOException { + (new RestampDialog(this, true)).setVisible(true); + } + void miExit_Action(java.awt.event.ActionEvent event) { // Action from Exit Create and show as modal //(new hayashi.yuu.tools.gui.QuitDialog(this, true)).setVisible(true); @@ -690,13 +719,6 @@ doButton.setEnabled(false); String[] argv = new String[0]; - /* - argv[0] = arg1_srcFolder.getText(); - argv[1] = arg2_baseTimeImg.getText(); - argv[2] = arg3_basetiome.getText(); - argv[3] = arg5_outputFolder.getText(); - argv[4] = arg4_gpxFolder.getText(); - */ 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()); diff --git a/src/osm/jp/gpx/matchtime/gui/Card.java b/src/osm/jp/gpx/matchtime/gui/Card.java index 78617a5..f01e7da 100644 --- a/src/osm/jp/gpx/matchtime/gui/Card.java +++ b/src/osm/jp/gpx/matchtime/gui/Card.java @@ -2,25 +2,20 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; -import java.util.ResourceBundle; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTabbedPane; +import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n; -/** - * - * @author yuu - */ public class Card extends JPanel { - public ResourceBundle i18n = ResourceBundle.getBundle("i18n"); JTabbedPane tabbe; public JPanel mainPanel; String title; int backNumber = -1; int nextNumber = -1; - JButton nextButton; // [次へ]ボタン - JButton backButton; // [戻る]ボタン + public JButton nextButton; // [次へ]ボタン + public JButton backButton; // [戻る]ボタン public Card(JTabbedPane tabbe, String title, int backNumber, int nextNumber) { super(); @@ -47,21 +42,40 @@ SymAction lSymAction = new SymAction(); if (nextNumber >= 0) { nextButton = new JButton(i18n.getString("button.next")); + nextButton.setEnabled(false); buttonPanel.add(nextButton, BorderLayout.EAST); nextButton.addActionListener(lSymAction); } if (backNumber >= 0) { backButton = new JButton(i18n.getString("button.previous")); + backButton.setEnabled(false); buttonPanel.add(backButton, BorderLayout.WEST); backButton.addActionListener(lSymAction); } //}} } + public void setEnabled(boolean enabled) { + this.tabbe.setEnabledAt(nextNumber - 1, enabled); + } + public String getTitle() { return this.title; } + + class SymAction implements java.awt.event.ActionListener { + @Override + public void actionPerformed(java.awt.event.ActionEvent event) { + Object object = event.getSource(); + if (object == nextButton) { + nextButton_Action(event); + } + else if (object == backButton) { + backButton_Action(event); + } + } + } /** * [次へ]ボタンをクリックした時の動作 @@ -78,17 +92,4 @@ void backButton_Action(ActionEvent event) { this.tabbe.setSelectedIndex(this.backNumber); } - - class SymAction implements java.awt.event.ActionListener { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == nextButton) { - nextButton_Action(event); - } - else if (object == backButton) { - backButton_Action(event); - } - } - } } diff --git a/src/osm/jp/gpx/matchtime/gui/PanelAction.java b/src/osm/jp/gpx/matchtime/gui/PanelAction.java new file mode 100644 index 0000000..facc908 --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/PanelAction.java @@ -0,0 +1,5 @@ +package osm.jp.gpx.matchtime.gui; + +public interface PanelAction { + void openAction(); +} diff --git a/src/osm/jp/gpx/matchtime/gui/ParamAction.java b/src/osm/jp/gpx/matchtime/gui/ParamAction.java new file mode 100644 index 0000000..ffd0bcf --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/ParamAction.java @@ -0,0 +1,5 @@ +package osm.jp.gpx.matchtime.gui; + +public interface ParamAction { + boolean isEnable(); +} diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanel.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanel.java index ac629c7..80de385 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanel.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanel.java @@ -1,7 +1,7 @@ package osm.jp.gpx.matchtime.gui; import java.awt.Dimension; -import java.awt.LayoutManager; +import java.awt.event.ActionListener; import java.util.ResourceBundle; import javax.swing.BoxLayout; @@ -13,7 +13,7 @@ * パラメータを設定する為のパネル。 * この1インスタンスで、1パラメータをあらわす。 */ -public class ParameterPanel extends JPanel { +public abstract class ParameterPanel extends JPanel implements ActionListener,ParamAction { private static final long serialVersionUID = 4629824800747170556L; public JTextField argField; public JLabel argLabel; @@ -21,34 +21,34 @@ @SuppressWarnings("OverridableMethodCallInConstructor") public ParameterPanel(String label, String text) { + this(); + this.argLabel.setText(label); + this.argField.setText(text); + } + + public ParameterPanel() { super(); - argLabel = new JLabel(label); - argField = new JTextField(text); + argLabel = new JLabel(); + argField = new JTextField(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setMaximumSize(new Dimension(1920, 40)); this.add(argLabel); this.add(argField); } - + + public ParameterPanel setLabel(String label) { + this.argLabel.setText(label); + return this; + } + + public ParameterPanel setText(String text) { + this.argField.setText(text); + return this; + } + public String getText() { return this.argField.getText(); } - - public ParameterPanel(boolean isDoubleBuffered) { - super(isDoubleBuffered); - // TODO 自動生成されたコンストラクター・スタブ - } - - public ParameterPanel(LayoutManager layout) { - super(layout); - // TODO 自動生成されたコンストラクター・スタブ - } - - public ParameterPanel(LayoutManager layout, boolean isDoubleBuffered) { - super(layout, isDoubleBuffered); - // TODO 自動生成されたコンストラクター・スタブ - } - } diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java index fb2a4e6..bc92217 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java @@ -1,13 +1,13 @@ package osm.jp.gpx.matchtime.gui; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.io.File; +import java.io.FileNotFoundException; import javax.swing.JButton; import javax.swing.JFileChooser; @SuppressWarnings("serial") -public class ParameterPanelFolder extends ParameterPanel implements ActionListener +public class ParameterPanelFolder extends ParameterPanel { JFileChooser fc; JButton openButton; @@ -37,26 +37,50 @@ super.setEnabled(f); openButton.setEnabled(f); } + + public File getDirectory() throws FileNotFoundException { + String path = this.argField.getText(); + if (path == null) { + throw new FileNotFoundException("Image folder is Not specifiyed yet."); + } + File sdir = new File(path); + if (!sdir.exists()) { + throw new FileNotFoundException(String.format("Image folder '%s' is Not exists.", path)); + } + if (!sdir.isDirectory()) { + throw new FileNotFoundException(String.format("Image folder '%s' is Not directory.", path)); + } + return sdir; + } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == openButton){ - System.out.println("ParameterPanelFolder.actionPerformed(openButton)"); - File sdir = new File(this.argField.getText()); - if (sdir.exists()) { - this.fc = new JFileChooser(sdir); - } - else { - this.fc = new JFileChooser(); - } - this.fc.setFileSelectionMode(this.chooser); - - int returnVal = this.fc.showOpenDialog(ParameterPanelFolder.this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = this.fc.getSelectedFile(); - this.argField.setText(file.getAbsolutePath()); + try { + System.out.println("ParameterPanelFolder.actionPerformed(openButton)"); + File sdir = getDirectory(); + if (sdir.exists()) { + this.fc = new JFileChooser(sdir); + } + else { + this.fc = new JFileChooser(); + } + this.fc.setFileSelectionMode(this.chooser); + + int returnVal = this.fc.showOpenDialog(ParameterPanelFolder.this); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = this.fc.getSelectedFile(); + this.argField.setText(file.getAbsolutePath()); + } + } catch (FileNotFoundException ex) { + this.argField.setText(ex.toString()); } } } + + @Override + public boolean isEnable() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } } \ No newline at end of file diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java index e672786..ea2db23 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java @@ -1,15 +1,15 @@ package osm.jp.gpx.matchtime.gui; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.io.File; import javax.swing.JButton; import javax.swing.JFileChooser; @SuppressWarnings("serial") -public class ParameterPanelImageFile extends ParameterPanel implements ActionListener { +public class ParameterPanelImageFile extends ParameterPanel { JFileChooser fc; - JButton openButton; - ParameterPanelFolder paramDir; + public JButton openButton; + public ParameterPanelFolder paramDir; @SuppressWarnings("OverridableMethodCallInConstructor") public ParameterPanelImageFile(String label, String text, ParameterPanelFolder paramDir) { @@ -17,11 +17,7 @@ // "選択..." openButton = new JButton(i18n.getString("button.select")); - - /* openButton.addActionListener(this); - */ - this.add(openButton); //Create a file chooser @@ -30,19 +26,18 @@ @SuppressWarnings("override") public void actionPerformed(ActionEvent e) { - /* //Set up the file chooser. - File sdir = new File(paramDir.getText()); - System.out.println(sdir.toPath()); - if (sdir.isDirectory()) { - fc = new JFileChooser(sdir); - } - else { - fc = new JFileChooser(); - } + File sdir = new File(paramDir.getText()); + System.out.println(sdir.toPath()); + if (sdir.isDirectory()) { + fc = new JFileChooser(sdir); + } + else { + fc = new JFileChooser(); + } - //Add a custom file filter and disable the default - //(Accept All) file filter. + //Add a custom file filter and disable the default + //(Accept All) file filter. fc.addChoosableFileFilter(new ImageFilter()); fc.setAcceptAllFileFilterUsed(false); @@ -63,6 +58,14 @@ //Reset the file chooser for the next time it's shown. fc.setSelectedFile(null); - */ + } + + /** + * + * @return + */ + @Override + public boolean isEnable() { + throw new UnsupportedOperationException("Not supported yet."); } } \ No newline at end of file diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java index 19a0e63..bb01845 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java @@ -22,4 +22,13 @@ @Override public void actionPerformed(ActionEvent e) { } + + /** + * このフィールドに有効な値が設定されているかどうか + * @return + */ + @Override + public boolean isEnable() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } } \ No newline at end of file diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardCorectTime.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardCorectTime.java new file mode 100644 index 0000000..9b5f30d --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardCorectTime.java @@ -0,0 +1,71 @@ +package osm.jp.gpx.matchtime.gui.restamp; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import osm.jp.gpx.ImportPicture; +import osm.jp.gpx.matchtime.gui.AdjustTime; +import static osm.jp.gpx.matchtime.gui.AdjustTime.createImageIcon; +import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n; +import osm.jp.gpx.matchtime.gui.Card; +import osm.jp.gpx.matchtime.gui.PanelAction; +import osm.jp.gpx.matchtime.gui.ParameterPanel; + +/** + * [基準画像(開始)]選択パネル + * @author yuu + */ +public class CardCorectTime extends Card { + JPanel argsPanel; // パラメータ設定パネル (上部) + ParameterPanel arg3_basetime; // 基準時刻: + + /** + * コンストラクタ + * @param tabbe parent panel + * @param arg3_basetime + */ + public CardCorectTime(JTabbedPane tabbe, ParameterPanel arg3_basetime) { + super(tabbe, AdjustTime.i18n.getString("tab.restamp.300"), 1, 3); + + argsPanel = new JPanel(); + argsPanel.setLayout(new GridLayout(2, 1)); + + //---- CENTER ----- + this.mainPanel.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + + // 3. 正確な撮影時刻を入力してください。 + // カメラの時計が正確ならば、設定を変更する必要はありません。 + JLabel label3 = new JLabel(); + label3.setText(i18n.getString("label.300")); + argsPanel.add(label3); + + // 基準時刻: + this.arg3_basetime = arg3_basetime; + arg3_basetime.setLabel(String.format("  %s: ", i18n.getString("label.310"))); + arg3_basetime.setLabel(ImportPicture.TIME_FORMAT_STRING); + argsPanel.add(arg3_basetime); + this.mainPanel.add(argsPanel, BorderLayout.NORTH); + + // 参考画像 + JLabel imageLabel = new JLabel(); + JScrollPane imageSPane = new JScrollPane(imageLabel); + this.mainPanel.add(imageSPane, BorderLayout.CENTER); + + // 画像ファイル選択ダイアログを起動するボタン + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); + JButton openButton = new JButton(createImageIcon("images/Fit16.gif")); + buttonPanel.add(openButton); + JButton zoomInButton = new JButton(createImageIcon("images/ZoomIn16.gif")); + buttonPanel.add(zoomInButton); + JButton zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif")); + buttonPanel.add(zoomOutButton); + this.mainPanel.add(buttonPanel, BorderLayout.SOUTH); + } +} diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java new file mode 100644 index 0000000..f542caa --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java @@ -0,0 +1,52 @@ +package osm.jp.gpx.matchtime.gui.restamp; + +import java.awt.BorderLayout; +import java.io.File; +import java.io.FileNotFoundException; +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; +import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; + +/** + * [基準画像(開始)]選択パネル + * @author yuu + */ +public class CardFirstFile extends Card implements PanelAction { + JPanel argsPanel; // パラメータ設定パネル (上部) + ParameterPanelImageFile arg2_baseTimeImg; + + /** + * コンストラクタ + * @param tabbe parent panel + * @param arg2_baseTimeImg + */ + public CardFirstFile(JTabbedPane tabbe, ParameterPanelImageFile arg2_baseTimeImg) { + super(tabbe, AdjustTime.i18n.getString("tab.restamp.200"), 0, 2); + this.arg2_baseTimeImg = arg2_baseTimeImg; + + this.mainPanel.add(new JLabel(i18n.getString("label.200")), BorderLayout.NORTH); + + argsPanel = new JPanel(); + argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS)); + argsPanel.add(arg2_baseTimeImg); + this.mainPanel.add(argsPanel, BorderLayout.CENTER); + } + + @Override + public void openAction() { + try { + File dir = arg2_baseTimeImg.paramDir.getDirectory(); + } catch (FileNotFoundException ex) { + arg2_baseTimeImg.setText(null); + } + if (arg2_baseTimeImg.getText() == null) { + } + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java new file mode 100644 index 0000000..799d1de --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java @@ -0,0 +1,40 @@ +package osm.jp.gpx.matchtime.gui.restamp; + +import java.awt.BorderLayout; +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; +import osm.jp.gpx.matchtime.gui.ParameterPanelFolder; + +/** + * [対象フォルダ]設定パネル + * @author yuu + */ +public class CardSourceFolder extends Card implements PanelAction { + + /** + * コンストラクタ + * @param tabbe parent panel + * @param arg1_srcFolder 対象フォルダ + */ + public CardSourceFolder(JTabbedPane tabbe, ParameterPanelFolder arg1_srcFolder) { + super(tabbe, AdjustTime.i18n.getString("tab.100"), -1, 1); + this.mainPanel.add(new JLabel(i18n.getString("label.100")), BorderLayout.NORTH); + + JPanel argsPanel = new JPanel(); // パラメータ設定パネル (上部) + argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS)); + argsPanel.add(arg1_srcFolder); + this.mainPanel.add(argsPanel, BorderLayout.CENTER); + } + + @Override + @SuppressWarnings("empty-statement") + public void openAction() { + ; // 何もしない + } +} diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java new file mode 100644 index 0000000..7e4cee2 --- /dev/null +++ b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java @@ -0,0 +1,269 @@ +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 javax.swing.*; +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.ParameterPanel; +import osm.jp.gpx.matchtime.gui.ParameterPanelFolder; +import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; +import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n; + +@SuppressWarnings("serial") +public class RestampDialog extends Dialog +{ + //{{DECLARE_CONTROLS + java.awt.Label label1; + java.awt.Button closeButton; + java.awt.Label label2; + JLabel imageLabel; // 開始画像の基準時刻画像表示 + JTabbedPane cardPanel; // ウィザード形式パネル(タブ型) + JScrollPane imageSPane; // スクロールパネル + JPanel[] cards; + ParameterPanelFolder arg1_srcFolder; // 対象フォルダ + ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス + ParameterPanel arg3_basetime; // 開始画像の基準時刻: + AppParameters params; + //}} + + // Used for addNotify redundency check. + boolean fComponentsAdjusted = false; + + class SymWindow extends java.awt.event.WindowAdapter + { + @Override + public void windowClosing(java.awt.event.WindowEvent event) { + Object object = event.getSource(); + if (object == RestampDialog.this) { + AboutDialog_WindowClosing(event); + } + } + } + + class SymAction implements java.awt.event.ActionListener + { + @Override + 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); + } + } + } + + @SuppressWarnings("OverridableMethodCallInConstructor") + public RestampDialog(Frame parent, boolean modal) throws IOException { + super(parent, modal); + + // INIT_CONTROLS + setLayout(new BorderLayout()); + setSize( + getInsets().left + getInsets().right + 720, + getInsets().top + getInsets().bottom + 480 + ); + setTitle(i18n.getString("menu.restamp") + "... "); + + //---- CENTER ----- + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout()); + add(mainPanel, BorderLayout.CENTER); + + //---- SOUTH ----- + JPanel southPanel = new JPanel(new BorderLayout()); + southPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); + southPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH); + add(southPanel, BorderLayout.SOUTH); + + //---- SPACE ----- + add(Box.createVerticalStrut(30), BorderLayout.NORTH); + add(Box.createHorizontalStrut(10), BorderLayout.WEST); + add(Box.createHorizontalStrut(10), BorderLayout.EAST); + + closeButton = new java.awt.Button(); + closeButton.setLabel(i18n.getString("button.close") ); + closeButton.setBounds(145,65,66,27); + southPanel.add(closeButton); + //}} + + //--------------------------------------------------------------------- + params = new AppParameters(); + cards = new JPanel[3]; + cardPanel = new JTabbedPane(JTabbedPane.LEFT); + mainPanel.add(cardPanel, BorderLayout.CENTER); + int cardNo = 0; + + //--------------------------------------------------------------------- + // 1.[対象フォルダ]設定パネル + { + arg1_srcFolder = new ParameterPanelFolder( + i18n.getString("label.110") +": ", + params.getProperty(AppParameters.IMG_SOURCE_FOLDER) + ); + + Card card = new CardSourceFolder(cardPanel, arg1_srcFolder); + cardPanel.addTab(card.getTitle(), card); + cardPanel.setEnabledAt(cardNo, true); + cards[cardNo] = card; + cardNo++; + } + + //--------------------------------------------------------------------- + // 2. [基準画像(開始)]選択パネル + { + // 基準時刻画像 + arg2_baseTimeImg = new ParameterPanelImageFile( + i18n.getString("label.210") +": ", + null, + arg1_srcFolder + ); + + CardFirstFile card = new CardFirstFile(cardPanel, arg2_baseTimeImg); + cardPanel.addTab(card.getTitle(), card); + cardPanel.setEnabledAt(cardNo, false); + cards[cardNo] = card; + cardNo++; + } + + //--------------------------------------------------------------------- + // 2a. 開始画像の本当の時刻を設定の入力画面 + { + // 2a. 基準時刻: + arg3_basetime = new ParameterPanel(); + + CardCorectTime card = new CardCorectTime(cardPanel, arg3_basetime); + cardPanel.addTab(card.getTitle(), card); + cardPanel.setEnabledAt(cardNo, false); + cards[cardNo] = card; + cardNo++; + } + + //{{REGISTER_LISTENERS + SymWindow aSymWindow = new SymWindow(); + this.addWindowListener(aSymWindow); + SymAction lSymAction = new SymAction(); + closeButton.addActionListener(lSymAction); + //}} + } + + @SuppressWarnings("OverridableMethodCallInConstructor") + public RestampDialog(Frame parent, String title, boolean modal) throws IOException { + this(parent, modal); + setTitle(title); + } + + @Override + public void addNotify() { + // Record the size of the window prior to calling parents addNotify. + + super.addNotify(); + + // Only do this once. + if (fComponentsAdjusted) { + return; + } + + // Adjust components according to the insets + setSize(getInsets().left + getInsets().right + getSize().width, getInsets().top + getInsets().bottom + getSize().height); + Component components[] = getComponents(); + for (Component component : components) { + Point p = component.getLocation(); + p.translate(getInsets().left, getInsets().top); + component.setLocation(p); + } + + // Used for addNotify check. + fComponentsAdjusted = true; + } + + /** + * Shows or hides the component depending on the boolean flag b. + * @param b if true, show the component; otherwise, hide the component. + * @see java.awt.Component#isVisible + */ + @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); + } + + 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(); + arg3_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); + } +}