From 2111be290505df4aabc616398e8ef13dc81f1821 Mon Sep 17 00:00:00 2001 From: haya4 Date: Sun, 20 Oct 2019 22:45:14 +0900 Subject: [PATCH 1/1] =?utf8?q?=E3=82=BF=E3=83=96=E3=83=91=E3=83=8D?= =?utf8?q?=E3=83=AB=E3=80=8C=EF=BC=93=EF=BC=8EGPX=E3=83=95=E3=82=A1?= =?utf8?q?=E3=82=A4=E3=83=AB=E3=81=AE=E9=81=B8=E6=8A=9E=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/osm/jp/gpx/matchtime/gui/AdjustTime.java | 116 ++++++--------------- .../jp/gpx/matchtime/gui/ParameterPanelFolder.java | 14 ++- .../jp/gpx/matchtime/gui/ParameterPanelGpx.java | 58 +++++++++-- .../jp/gpx/matchtime/gui/restamp/CardGpxFile.java | 51 ++++----- 4 files changed, 117 insertions(+), 122 deletions(-) diff --git a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java index db5f45d..926e28e 100644 --- a/src/osm/jp/gpx/matchtime/gui/AdjustTime.java +++ b/src/osm/jp/gpx/matchtime/gui/AdjustTime.java @@ -12,6 +12,7 @@ import java.util.logging.Logger; import javax.swing.*; import javax.swing.event.DocumentEvent; import osm.jp.gpx.*; +import osm.jp.gpx.matchtime.gui.restamp.CardGpxFile; import osm.jp.gpx.matchtime.gui.restamp.CardImageFile; import osm.jp.gpx.matchtime.gui.restamp.CardSourceFolder; @@ -39,11 +40,11 @@ public class AdjustTime extends JFrame JPanel argsPanel; // パラメータ設定パネル (上部) JScrollPane imageSPane; // スクロールパネル JLabel imageLabel; // 基準時刻画像表示 - JCheckBox noFirstNode; // GPX: セグメントの最初の1ノードは無視する。 {ON | OFF} - JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF} + //JCheckBox noFirstNode; // GPX: セグメントの最初の1ノードは無視する。 {ON | OFF} + //JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF} JTextArea textArea; // 実行結果表示領域 - ParameterPanel arg3_basetime; // 基準時刻: + //ParameterPanel arg3_basetime; // 基準時刻: JCheckBox outputIMG; // IMGの変換 する/しない JCheckBox outputIMG_all; // 'out of GPX time'でもIMGの変換をする {ON | OFF} JCheckBox exifON; // EXIF 書き出しモード / !(EXIFの書き換えはしない) @@ -51,7 +52,6 @@ public class AdjustTime extends JFrame JCheckBox gpxOverwriteMagvar; // ソースGPXのを無視する JCheckBox gpxOutputSpeed; // GPXにを書き出す ParameterPanelFolder arg5_outputFolder; // EXIF 書き出しフォルダ - ParameterPanelGpx arg4_gpxFolder; // GPXファイル・フォルダ JPanel buttonPanel; // ボタンパネル (下部) @@ -61,7 +61,8 @@ public class AdjustTime extends JFrame //---入力フィールド---------------------------------------------------- ParameterPanelFolder arg1_srcFolder; // 対象フォルダ ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス - ParameterPanelTime arg2_basetime; // 開始画像の基準時刻: + ParameterPanelTime arg2_basetime; // 開始画像の基準時刻: + ParameterPanelGpx arg3_gpxFile; // GPX file or Folder //{{DECLARE_MENUS java.awt.MenuBar mainMenuBar; @@ -110,18 +111,6 @@ public class AdjustTime extends JFrame else if (object == outputIMG) { outputIMG_Action(event); } - else if (object == outputIMG_all) { - outputIMGall_Action(event); - } - else if (object == exifON) { - exifON_Action(event); - } - else if (object == gpxOutputWpt) { - gpxOutputWpt_Action(event); - } - else if (object == gpxOutputSpeed) { - gpxOutputSpeed_Action(event); - } else if (object == doButton) { doButton_Action(event); } @@ -168,7 +157,7 @@ public class AdjustTime extends JFrame cardPanel = new JTabbedPane(JTabbedPane.LEFT); mainPanel.add(cardPanel, BorderLayout.CENTER); - cards = new Card[5]; + cards = new Card[4]; int cardNo = 0; //--------------------------------------------------------------------- @@ -240,42 +229,33 @@ public class AdjustTime extends JFrame //--------------------------------------------------------------------- // 3.GPXファイル設定画面 { - // 3. GPXファイルを選択 - Card card = new Card(cardPanel, i18n.getString("tab.400"), 2, 4); - cardPanel.addTab(card.getTitle(), card); - cards[cardNo] = card; - - // 4. ヒモ付を行うGPXファイルを選択してください。 - // - フォルダを指定すると、フォルダ内のすべてのGPXファイルを対象とします。 - JLabel label4 = new JLabel(); - label4.setText(i18n.getString("label.400")); - card.mainPanel.add(label4, BorderLayout.NORTH); - - JPanel tmpPanel4a = new JPanel(); - tmpPanel4a.setLayout(new BoxLayout(tmpPanel4a, BoxLayout.Y_AXIS)); - - // "GPXフォルダ: " - arg4_gpxFolder = new ParameterPanelGpx( + // 3. GPXファイル選択パラメータ + arg3_gpxFile = new ParameterPanelGpx( i18n.getString("label.410") + ": ", params.getProperty(AppParameters.GPX_SOURCE_FOLDER) ); - tmpPanel4a.add(arg4_gpxFolder); + arg3_gpxFile.argField.getDocument().addDocumentListener( + new SimpleDocumentListener() { + @Override + public void update(DocumentEvent e) { + toEnable(2, arg3_gpxFile.isEnable()); + } + } + ); // "セグメント'trkseg'の最初の1ノードは無視する。" - noFirstNode = new JCheckBox( - i18n.getString("label.420"), - params.getProperty(AppParameters.GPX_NO_FIRST_NODE).equals("ON") - ); - tmpPanel4a.add(noFirstNode); + arg3_gpxFile.addNoFirstNode(i18n.getString("label.420"), params); // "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする" - gpxReuse = new JCheckBox( - i18n.getString("label.430"), - params.getProperty(AppParameters.GPX_REUSE).equals("ON") - ); - gpxReuse.setEnabled(true); - tmpPanel4a.add(gpxReuse); - card.mainPanel.add(tmpPanel4a, BorderLayout.CENTER); + arg3_gpxFile.addGpxReuse(i18n.getString("label.430"), params); + + // 3. GPXファイルを選択 + CardGpxFile card = new CardGpxFile( + cardPanel, arg3_gpxFile, (Window)this, + AdjustTime.i18n.getString("tab.400"), 1, 3); + cardPanel.addTab(card.getTitle(), card); + cardPanel.setEnabledAt(cardNo, false); + cards[cardNo] = card; cardNo++; } @@ -406,8 +386,6 @@ public class AdjustTime extends JFrame outputIMG_all.addActionListener(lSymAction); exifON.addActionListener(lSymAction); gpxOutputSpeed.addActionListener(lSymAction); - noFirstNode.addActionListener(lSymAction); - gpxReuse.addActionListener(lSymAction); //}} } @@ -533,34 +511,6 @@ public class AdjustTime extends JFrame } /** - * checkbox[GPXファイル時間外のファイルもコピーする]を変更した場合のアクション - * @param event - */ - void outputIMGall_Action (ActionEvent event) { - } - - /** - * checkbox[EXIF書き出し]を変更した場合のアクション - * @param event - */ - void exifON_Action (ActionEvent event) { - } - - /** - * checkbox[GPXのを出力する]を変更した場合のアクション - * @param event - */ - void gpxOutputWpt_Action (ActionEvent event) { - } - - /** - * checkbox[GPXのを書き換える]を変更した場合のアクション - * @param event - */ - void gpxOutputSpeed_Action (ActionEvent event) { - } - - /** * [実行]ボタンをクリックしたときの動作 * @param event */ @@ -569,21 +519,19 @@ public class AdjustTime extends JFrame doButton.setEnabled(false); String[] argv = new String[0]; - 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_NO_FIRST_NODE, String.valueOf(arg3_gpxFile.isNoFirstNodeSelected())); + this.params.setProperty(AppParameters.GPX_REUSE, String.valueOf(arg3_gpxFile.isGpxReuseSelected())); + this.params.setProperty(AppParameters.GPX_SOURCE_FOLDER, arg3_gpxFile.getText()); + if ((arg2_basetime.exifBase != null) && arg2_basetime.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()); - this.params.setProperty(AppParameters.IMG_TIME, ImportPicture.toUTCString(dfjp.parse(arg3_basetime.getText()))); + this.params.setProperty(AppParameters.IMG_TIME, ImportPicture.toUTCString(dfjp.parse(arg2_basetime.getText()))); this.params.setProperty(AppParameters.IMG_OUTPUT, String.valueOf(outputIMG.isSelected())); this.params.setProperty(AppParameters.IMG_OUTPUT_FOLDER, arg5_outputFolder.getText()); this.params.setProperty(AppParameters.IMG_OUTPUT_ALL, String.valueOf(outputIMG_all.isSelected())); diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java index 8365f92..894e81e 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java @@ -14,6 +14,16 @@ public class ParameterPanelFolder extends ParameterPanel implements ActionListen JButton selectButton; int chooser; + /** + * コンストラクタ + * ディレクトリのみ選択可能なダイアログ + * @param label + * @param text + */ + public ParameterPanelFolder(String label, String text) { + this(label, text, JFileChooser.DIRECTORIES_ONLY); + } + @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) public ParameterPanelFolder(String label, String text, int chooser) { super(label, text); @@ -30,10 +40,6 @@ public class ParameterPanelFolder extends ParameterPanel implements ActionListen this.add(selectButton); } - public ParameterPanelFolder(String label, String text) { - this(label, text, JFileChooser.DIRECTORIES_ONLY); - } - public void setEnable(boolean f) { super.setEnabled(f); selectButton.setEnabled(f); diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java index 4fe3267..43c8cf4 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java @@ -5,27 +5,39 @@ import java.awt.event.ActionListener; import java.io.File; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JFileChooser; +import osm.jp.gpx.AppParameters; @SuppressWarnings("serial") public class ParameterPanelGpx extends ParameterPanel implements ActionListener { JFileChooser fc; - JButton openButton; - + JButton selectButton; + public JCheckBox noFirstNode; // CheckBox: "セグメント'trkseg'の最初の1ノードは無視する。" + public JCheckBox gpxReuse; // CheckBox: "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする" + + /** + * コンストラクタ + * @param label + * @param text + */ @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) public ParameterPanelGpx(String label, String text) { super(label, text); // "選択..." - openButton = new JButton(i18n.getString("button.select"), AdjustTime.createImageIcon("images/Open16.gif")); - openButton.addActionListener(this); - this.add(openButton); + selectButton = new JButton( + i18n.getString("button.select"), + AdjustTime.createImageIcon("images/Open16.gif") + ); + selectButton.addActionListener(this); + this.add(selectButton); } @Override public void actionPerformed(ActionEvent e) { - if (e.getSource() == openButton){ + if (e.getSource() == selectButton){ System.out.println("ParameterPanelGpx.actionPerformed(openButton)"); File sdir = new File(this.argField.getText()); if (sdir.exists()) { @@ -55,6 +67,40 @@ public class ParameterPanelGpx extends ParameterPanel implements ActionListener } /** + * "セグメント'trkseg'の最初の1ノードは無視する。" + * @param label テキスト + * @param params プロパティ + */ + public void addNoFirstNode(String label, AppParameters params) { + boolean selected = false; + if (params.getProperty(AppParameters.GPX_NO_FIRST_NODE).equals("ON")) { + selected = true; + } + noFirstNode = new JCheckBox(label, selected); + } + + public boolean isNoFirstNodeSelected() { + return (noFirstNode != null) && noFirstNode.isSelected(); + } + + /** + * "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする" + * @param label テキスト + * @param params プロパティ + */ + public void addGpxReuse(String label, AppParameters params) { + boolean selected = false; + if (params.getProperty(AppParameters.GPX_REUSE).equals("ON")) { + selected = true; + } + gpxReuse = new JCheckBox(label, selected); + } + + public boolean isGpxReuseSelected() { + return (gpxReuse != null) && gpxReuse.isSelected(); + } + + /** * このフィールドに有効な値が設定されているかどうか * @return */ diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardGpxFile.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardGpxFile.java index 5a84225..4610ee8 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/CardGpxFile.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardGpxFile.java @@ -2,12 +2,11 @@ package osm.jp.gpx.matchtime.gui.restamp; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.Window; import javax.swing.BoxLayout; -import javax.swing.JCheckBox; 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; @@ -20,42 +19,47 @@ import osm.jp.gpx.matchtime.gui.ParameterPanelGpx; public class CardGpxFile extends Card implements PanelAction { //JPanel argsPanel; // パラメータ設定パネル (上部) ParameterPanelGpx arg_gpxFile; - JCheckBox noFirstNode; // GPX: セグメントの最初の1ノードは無視する。 {ON | OFF} - JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF} - private final boolean gpxReuseV; + //JCheckBox noFirstNode; // GPX: セグメントの最初の1ノードは無視する。 {ON | OFF} + //JCheckBox gpxReuse; // 生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も対象にする。 {ON | OFF} + //private final boolean gpxReuseV; /** * コンストラクタ * @param tabbe parent panel * @param arg_gpxFile // 開始画像の基準時刻: - * @param noFirstNodeV - * @param gpxReuseV + * @param owner + * @param text + * @param pre + * @param next */ public CardGpxFile( JTabbedPane tabbe, ParameterPanelGpx arg_gpxFile, - boolean noFirstNodeV, - boolean gpxReuseV + Window owner, + String text, + int pre, int next + //boolean noFirstNodeV, + //boolean gpxReuseV ) { - super(tabbe, AdjustTime.i18n.getString("tab.400"), 2, 4); + super(tabbe, text, 2, 4); this.arg_gpxFile = arg_gpxFile; + // 4. ヒモ付を行うGPXファイルを選択してください。 + // - フォルダを指定すると、フォルダ内のすべてのGPXファイルを対象とします。 JPanel argsPanel = new JPanel(); argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS)); argsPanel.add(packLine(new JLabel(i18n.getString("label.400")), new JPanel())); argsPanel.add(arg_gpxFile); // "セグメント'trkseg'の最初の1ノードは無視する。" - noFirstNode = new JCheckBox( - i18n.getString("label.420"), - noFirstNodeV - ); - argsPanel.add(noFirstNode); + if (arg_gpxFile.noFirstNode != null) { + argsPanel.add(arg_gpxFile.noFirstNode); + } // "生成されたGPXファイル(ファイル名が'_.gpx'で終わるもの)も変換の対象にする" - gpxReuse = new JCheckBox(i18n.getString("label.430"), gpxReuseV); - gpxReuse.setEnabled(true); - argsPanel.add(gpxReuse); + if (arg_gpxFile.gpxReuse != null) { + argsPanel.add(arg_gpxFile.gpxReuse); + } JPanel space = new JPanel(); space.setMinimumSize(new Dimension(40, 20)); @@ -63,17 +67,8 @@ public class CardGpxFile extends Card implements PanelAction { argsPanel.add(space); this.mainPanel.add(argsPanel, BorderLayout.CENTER); - this.gpxReuseV = gpxReuseV; } - - /** - * "セグメント'trkseg'の最初の1ノードは無視する。" - * @return - */ - public boolean getNoFirstNode() { - return noFirstNode.isSelected(); - } - + /** * 入力条件が満たされているかどうか * @return -- 2.11.0