diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java deleted file mode 100644 index 2069c61..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/AboutDialog.java +++ /dev/null @@ -1,128 +0,0 @@ -package osm.jp.gpx.matchtime.gui; -import java.awt.*; - -@SuppressWarnings("serial") -public class AboutDialog extends Dialog -{ - //{{DECLARE_CONTROLS - java.awt.Label label1; - java.awt.Button okButton; - java.awt.Label label2; - //}} - - // 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 == AboutDialog.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 == okButton) { - okButton_Clicked(event); - } - } - } - - public AboutDialog(Frame parent, boolean modal) { - super(parent, modal); - - // This code is automatically generated by Visual Cafe when you add - // components to the visual environment. It instantiates and initializes - // the components. To modify the code, only use code syntax that matches - // what Visual Cafe can generate, or Visual Cafe may be unable to back - // parse your Java file into its visual environment. - - - //{{INIT_CONTROLS - setLayout(null); - setVisible(false); - setSize(360,114); - label1 = new java.awt.Label(AdjustTerra.PROGRAM_NAME +" Version "+ AdjustTerra.PROGRAM_VARSION +" ("+ AdjustTerra.PROGRAM_UPDATE +")", Label.CENTER); - label1.setBounds(10,10,340,20); - add(label1); - okButton = new java.awt.Button(); - okButton.setLabel("OK"); - okButton.setBounds(145,65,66,27); - add(okButton); - label2 = new java.awt.Label("Copyright(C) 2014,2018,2020 yuuhayashi \n The MIT License (MIT).",Label.RIGHT); - label2.setBounds(10,40,340,20); - add(label2); - setTitle("About... "+ AdjustTerra.PROGRAM_NAME); - //}} - - //{{REGISTER_LISTENERS - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - okButton.addActionListener(lSymAction); - //}} - } - - public AboutDialog(Frame parent, String title, boolean modal) { - 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 okButton_Clicked(java.awt.event.ActionEvent event) { - //{{CONNECTION - // Clicked from okButton Hide the Dialog - dispose(); - //}} - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java b/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java deleted file mode 100644 index d5d84a6..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/AdjustTerra.java +++ /dev/null @@ -1,416 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import osm.jp.gpx.matchtime.gui.restamp.RestampDialog; -import java.awt.*; -import java.io.IOException; -import java.text.SimpleDateFormat; -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 osm.jp.gpx.matchtime.gui.restamp.CardImageFile; -import osm.jp.gpx.matchtime.gui.restamp.CardSourceFolder; - -/** - * 本プログラムのメインクラス - */ -@SuppressWarnings("serial") -public class AdjustTerra extends JFrame -{ - public static final String PROGRAM_NAME = "AdjustTerra for JOSM"; - public static final String PROGRAM_VARSION = "5.2"; - public static final String PROGRAM_UPDATE = "2020/02/02"; - - AppParameters params; - public static SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - public static ResourceBundle i18n = ResourceBundle.getBundle("i18n"); - - //{{DECLARE_CONTROLS - JTabbedPane cardPanel; // ウィザード形式パネル(タブ型) - Card[] cards; - //}} - - //---入力フィールド---------------------------------------------------- - ParameterPanelFolder arg1_srcFolder; // 対象フォルダ - ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス - ParameterPanelTime arg2_basetime; // 開始画像の基準時刻: - ParameterPanelGpx arg3_gpxFile; // GPX file or Folder - ParameterPanelOutput arg4_output; // EXIF & 書き出しフォルダ - - //{{DECLARE_MENUS - java.awt.MenuBar mainMenuBar; - java.awt.Menu menu1; - java.awt.MenuItem miDoNewFileList; - 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; - //}} - - class SymWindow extends java.awt.event.WindowAdapter { - /** - * このFrameが閉じられるときの動作。 - * このパネルが閉じられたら、このアプリケーションも終了させる。 - */ - @Override - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == AdjustTerra.this) { - DbMang_WindowClosing(event); - } - } - } - - class SymAction implements java.awt.event.ActionListener { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == miAbout) { - miAbout_Action(event); - } - else if (object == miRestamp) { - try { - miRestamp_Action(event); - } catch (IOException ex) { - Logger.getLogger(AdjustTerra.class.getName()).log(Level.SEVERE, null, ex); - } - } - else if (object == miExit) { - miExit_Action(event); - } - } - } - - /** - * データベース内のテーブルを一覧で表示するFrame - * @throws IOException - */ - public AdjustTerra() throws IOException - { - dfjp.setTimeZone(TimeZone.getTimeZone("JST")); - - // INIT_CONTROLS - Container container = getContentPane(); - container.setLayout(new BorderLayout()); - setSize( - getInsets().left + getInsets().right + 720, - getInsets().top + getInsets().bottom + 480 - ); - setTitle(AdjustTerra.PROGRAM_NAME +" v"+ AdjustTerra.PROGRAM_VARSION); - - //---- CENTER ----- - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - container.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); - container.add(southPanel, BorderLayout.SOUTH); - - //---- SPACE ----- - container.add(Box.createVerticalStrut(30), BorderLayout.NORTH); - container.add(Box.createHorizontalStrut(10), BorderLayout.WEST); - container.add(Box.createHorizontalStrut(10), BorderLayout.EAST); - - params = new AppParameters(); - - //--------------------------------------------------------------------- - cardPanel = new JTabbedPane(JTabbedPane.LEFT); - mainPanel.add(cardPanel, BorderLayout.CENTER); - - cards = new Card[4]; - int cardNo = 0; - - //--------------------------------------------------------------------- - // 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; - cardNo++; - } - - //--------------------------------------------------------------------- - // 2.[基準時刻画像]設定パネル - // 2a.基準時刻の入力画面 - { - // 基準時刻画像 - arg2_baseTimeImg = new ParameterPanelImageFile( - i18n.getString("label.210") +": ", - null, - arg1_srcFolder - ); - - // 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の日時を基準にする - arg2_basetime.addExifBase(i18n.getString("label.220"), params); - - // ファイル更新日時を基準にする - arg2_basetime.addFileUpdate(i18n.getString("label.230"), params); - - CardImageFile card = new CardImageFile( - cardPanel, arg2_basetime, (Window)this, - AdjustTerra.i18n.getString("tab.300"), 0, 2); - cardPanel.addTab(card.getTitle(), card); - cardPanel.setEnabledAt(cardNo, false); - cards[cardNo] = card; - cardNo++; - } - - //--------------------------------------------------------------------- - // 3.GPXファイル設定画面 - { - // 3. GPXファイル選択パラメータ - arg3_gpxFile = new ParameterPanelGpx( - i18n.getString("label.410") + ": ", - params.getProperty(AppParameters.GPX_SOURCE_FOLDER) - ); - arg3_gpxFile.argField.getDocument().addDocumentListener( - new SimpleDocumentListener() { - @Override - public void update(DocumentEvent e) { - toEnable(2, arg3_gpxFile.isEnable()); - } - } - ); - - // "セグメント'trkseg'の最初の1ノードは無視する。" - arg3_gpxFile.addNoFirstNode(i18n.getString("label.420"), params); - - // 3. GPXファイルを選択 - CardGpxFile card = new CardGpxFile( - cardPanel, arg3_gpxFile, - AdjustTerra.i18n.getString("tab.400"), 1, 3); - cardPanel.addTab(card.getTitle(), card); - cardPanel.setEnabledAt(cardNo, false); - cards[cardNo] = card; - cardNo++; - } - - //--------------------------------------------------------------------- - // 4.EXIF更新設定画面 & 実行画面 - { - // 4. ファイル変換・実行パラメータ - // "出力フォルダ: " - arg4_output = new ParameterPanelOutput( - i18n.getString("label.530") + ": ", - params.getProperty(AppParameters.IMG_OUTPUT_FOLDER) - ); - arg4_output.argField.getDocument().addDocumentListener( - new SimpleDocumentListener() { - @Override - public void update(DocumentEvent e) { - toEnable(3, arg4_output.isEnable()); - } - } - ); - - // "IMGの変換をする" - arg4_output.addCheckChangeImage(i18n.getString("label.510"), params); - - // "GPXファイル時間外のファイルもコピーする" - arg4_output.addCheckOutofGpxTime(i18n.getString("label.520"), params); - - // "EXIFの変換をする" - arg4_output.addCheckOutputExif(i18n.getString("label.540"), params); - - // "ソースGPXのを無視する" - arg4_output.addCheckIgnoreMagvar(i18n.getString("label.560"), params); - - // "出力GPXに[SPEED]を上書きする" - arg4_output.addCheckOutputSpeed(i18n.getString("label.570"), params); - - // パネル表示 - CardExifPerform card = new CardExifPerform( - cardPanel, - arg2_basetime, arg3_gpxFile, arg4_output, - AdjustTerra.i18n.getString("tab.500"), - 2, -1 - ); - cardPanel.addTab(card.getTitle(), card); - cardPanel.setEnabledAt(cardNo, false); - cards[cardNo] = card; - } - - //--------------------------------------------------------------------- - // INIT_MENUS - menu1 = new java.awt.Menu("File"); - miExit = new java.awt.MenuItem(i18n.getString("menu.quit")); - 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)); - - menu3 = new java.awt.Menu("Help"); - menu3.setFont(new Font("Dialog", Font.PLAIN, 12)); - menu3.add(miAbout); - - mainMenuBar = new java.awt.MenuBar(); - mainMenuBar.setHelpMenu(menu3); - mainMenuBar.add(menu1); - mainMenuBar.add(menu2); - mainMenuBar.add(menu3); - setMenuBar(mainMenuBar); - - //{{REGISTER_LISTENERS - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - miAbout.addActionListener(lSymAction); - miRestamp.addActionListener(lSymAction); - miExit.addActionListener(lSymAction); - arg2_baseTimeImg.openButton.addActionListener(lSymAction); - //}} - } - - /** - * Shows or hides the component depending on the boolean flag b. - * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す. - * @see java.awt.Component#isVisible - */ - @Override - public void setVisible(boolean b) { - if(b) { - setLocation(50, 50); - } - super.setVisible(b); - } - - /** - * このクラスをインスタンスを生成して表示する。 - * コマンドラインの引数はありません。 - * @param args - */ - static public void main(String args[]) { - SwingUtilities.invokeLater(() -> { - try { - createAndShowGUI(); - } catch (Exception e) { - e.printStackTrace(); - } - }); - } - private static void createAndShowGUI() throws IOException { - (new AdjustTerra()).setVisible(true); - } - - @Override - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) - return; - - // Adjust components according to the insets - setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height); - Component components[] = getComponents(); - for (Component component : components) { - Point p = component.getLocation(); - p.translate(getInsets().left, getInsets().top); - component.setLocation(p); - } - fComponentsAdjusted = true; - } - - void DbMang_WindowClosing(java.awt.event.WindowEvent event) { - setVisible(false); // hide the Manager - dispose(); // free the system resources - System.exit(0); // close the application - } - - void miAbout_Action(java.awt.event.ActionEvent event) { - // Action from About Create and show as modal - (new AboutDialog(this, true)).setVisible(true); - } - - void miRestamp_Action(java.awt.event.ActionEvent event) throws IOException { - (new RestampDialog(this, false)).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); - (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; - - /** Returns an ImageIcon, or null if the path was invalid. - * @param path - * @return */ - public static ImageIcon createImageIcon(String path) { - java.net.URL imgURL = AdjustTerra.class.getResource(path); - if (imgURL != null) { - return new ImageIcon(imgURL); - } else { - System.err.println("Couldn't find file: " + path); - return null; - } - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/Card.java b/src/main/java/osm/jp/gpx/matchtime/gui/Card.java deleted file mode 100644 index bc14b82..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/Card.java +++ /dev/null @@ -1,124 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; - -public class Card extends JPanel { - private static final long serialVersionUID = 9050047381377607421L; - JTabbedPane tabbe; - public JPanel mainPanel; - String title; - int backNumber = -1; - int nextNumber = -1; - public JButton nextButton; // [次へ]ボタン - public JButton backButton; // [戻る]ボタン - - public Card(JTabbedPane tabbe, String title, int backNumber, int nextNumber) { - super(); - this.tabbe = tabbe; - this.title = title; - this.backNumber = backNumber; - this.nextNumber = nextNumber; - - // INIT_CONTROLS - this.setLayout(new BorderLayout()); - - //---- CENTER ----- - mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - this.add(mainPanel, BorderLayout.CENTER); - - //---- SOUTH ----- - JPanel buttonPanel = new JPanel(new BorderLayout()); - buttonPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); - buttonPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH); - this.add(buttonPanel, BorderLayout.SOUTH); - - //{{REGISTER_LISTENERS - 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 static JPanel packLine(JComponent[] components, JPanel panel) { - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - int max = 0; - for (JComponent component : components) { - panel.add(component); - Dimension size = component.getMaximumSize(); - if (max < size.height) { - max = size.height; - } - } - Dimension size = new Dimension(); - size.width = Short.MAX_VALUE; - size.height = max; - panel.setMaximumSize(size); - return panel; - } - - public static JPanel packLine(JComponent component, JPanel panel) { - ArrayList array = new ArrayList<>(); - array.add(component); - return packLine(array.toArray(new JComponent[array.size()]), panel); - } - - @Override - 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); - } - } - } - - /** - * [次へ]ボタンをクリックした時の動作 - * @param event - */ - void nextButton_Action(ActionEvent event) { - this.tabbe.setSelectedIndex(this.nextNumber); - } - - /** - * [戻る]ボタンをクリックした時の動作 - * @param event - */ - void backButton_Action(ActionEvent event) { - this.tabbe.setSelectedIndex(this.backNumber); - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java b/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java deleted file mode 100644 index 2c79270..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/CardExifPerform.java +++ /dev/null @@ -1,190 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import osm.jp.gpx.AppParameters; -import osm.jp.gpx.ImportPicture; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.dfjp; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; - -/** - * 実行パネル - * @author yuu - */ -public class CardExifPerform extends Card implements PanelAction { - private static final long serialVersionUID = 8902284630791931118L; - ParameterPanelTime arg_basetime; // 画像の基準時刻: - ParameterPanelGpx arg_gpxFile; // GPX file or Folder - ParameterPanelOutput arg_output; // EXIF & 書き出しフォルダ - JButton doButton; // [処理実行]ボタン - - /** - * コンストラクタ - * @param tabbe parent panel - * @param arg_basetime // 開始画像の基準時刻: - * @param arg_gpxFile // GPX file or Folder: - * @param arg_output // EXIF & 書き出しフォルダ - * @param text - * @param pre - * @param next - */ - public CardExifPerform( - JTabbedPane tabbe, - ParameterPanelTime arg_basetime, - ParameterPanelGpx arg_gpxFile, - ParameterPanelOutput arg_output, - String text, - int pre, int next - ) { - super(tabbe, text, pre, next); - this.arg_basetime = arg_basetime; - this.arg_gpxFile = arg_gpxFile; - this.arg_output = arg_output; - - SymAction lSymAction = new SymAction(); - JPanel argsPanel = new JPanel(); - argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS)); - - // 5. EXIF変換を行うかどうかを選択してください。 - // - EXIF変換を行う場合には、変換ファイルを出力するフォルダも指定する必要があります。 - // - 出力フォルダには、書き込み権限と、十分な空き容量が必要です。 - JLabel label5 = new JLabel(); - label5.setText( - String.format( - "

5. %s

", - i18n.getString("label.500"), - i18n.getString("label.501"), - i18n.getString("label.502") - ) - ); - argsPanel.add(packLine(label5, new JPanel())); - - // 出力フォルダ - //argsPanel.add(packLine(new JLabel(i18n.getString("label.530")), new JPanel())); - argsPanel.add(arg_output); - - // チェックボックス "IMGの変換をする" - if (arg_output.outputIMG != null) { - arg_output.outputIMG.addActionListener(lSymAction); - argsPanel.add(arg_output.outputIMG); - } - - // チェックボックス "IMGの変換をする" - if (arg_output.outputIMG_all != null) { - argsPanel.add(arg_output.outputIMG_all); - } - - // チェックボックス "EXIFの変換をする" - if (arg_output.exifON != null) { - argsPanel.add(arg_output.exifON); - } - - // チェックボックス "ソースGPXのを無視する" - if (arg_output.gpxOverwriteMagvar != null) { - argsPanel.add(arg_output.gpxOverwriteMagvar); - } - - // チェックボックス "出力GPXに[SPEED]を上書きする" - if (arg_output.gpxOutputSpeed != null) { - argsPanel.add(arg_output.gpxOutputSpeed); - } - - // [処理実行]ボタン - doButton = new JButton( - i18n.getString("button.execute"), - AdjustTerra.createImageIcon("/images/media_playback_start.png") - ); - argsPanel.add(doButton); - - this.mainPanel.add(argsPanel, BorderLayout.CENTER); - - //{{REGISTER_LISTENERS - doButton.addActionListener(lSymAction); - //}} - } - - class SymAction implements java.awt.event.ActionListener { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == doButton) { - doButton_Action(event); - } - else if (object == arg_output.outputIMG) { - outputIMG_Action(event); - } - } - } - - /** - * checkbox[IMG変換]を変更した場合のアクション - * ON ー> IMG出力フォルダのフィールドを有効にする - * OFF -> IMG出力フォルダのフィールドを無効にする - * @param event - */ - void outputIMG_Action (ActionEvent event) { - setEnabled(isEnabled()); - } - - /** - * [実行]ボタンをクリックしたときの動作 - * @param event - */ - void doButton_Action(java.awt.event.ActionEvent event) { - doButton.setEnabled(false); - - ParameterPanelImageFile arg_baseTimeImg = arg_basetime.imageFile; // 基準時刻画像 - ParameterPanelFolder arg_srcFolder = arg_baseTimeImg.paramDir; - - try { - AppParameters params = new AppParameters(); - - params.setProperty(AppParameters.GPX_NO_FIRST_NODE, String.valueOf(arg_gpxFile.isNoFirstNodeSelected())); - params.setProperty(AppParameters.GPX_SOURCE_FOLDER, arg_gpxFile.getText()); - if ((arg_basetime.exifBase != null) && arg_basetime.exifBase.isSelected()) { - params.setProperty(AppParameters.GPX_BASETIME, "EXIF_TIME"); - } - else { - params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE"); - } - params.setProperty(AppParameters.IMG_SOURCE_FOLDER, arg_srcFolder.getText()); - params.setProperty(AppParameters.IMG_BASE_FILE, arg_baseTimeImg.getText()); - params.setProperty(AppParameters.IMG_TIME, ImportPicture.toUTCString(dfjp.parse(arg_basetime.getText()))); - - params.setProperty(AppParameters.IMG_OUTPUT, String.valueOf(arg_output.outputIMG.isSelected())); - params.setProperty(AppParameters.IMG_OUTPUT_ALL, String.valueOf(arg_output.outputIMG_all.isSelected())); - params.setProperty(AppParameters.IMG_OUTPUT_FOLDER, arg_output.getText()); - - params.setProperty(AppParameters.IMG_OUTPUT_EXIF, String.valueOf(arg_output.exifON.isSelected())); - params.setProperty(AppParameters.GPX_OVERWRITE_MAGVAR, String.valueOf(arg_output.gpxOverwriteMagvar.isSelected())); - params.setProperty(AppParameters.GPX_OUTPUT_SPEED, String.valueOf(arg_output.gpxOutputSpeed.isSelected())); - params.store(); - } - catch(Exception e) { - e.printStackTrace(); - } - - (new DoDialog(new String[0])).setVisible(true); - - doButton.setEnabled(true); - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return (arg_basetime.isEnable() && arg_gpxFile.isEnable()); - } - - @Override - public void openAction() { - ; // 何もしない - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java deleted file mode 100644 index 64d825b..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/CardGpxFile.java +++ /dev/null @@ -1,69 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import javax.swing.BoxLayout; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; - -/** - * [GPXファイル]選択パネル - * @author haya4 - */ -public class CardGpxFile extends Card implements PanelAction { - private static final long serialVersionUID = -6130918418152241845L; - ParameterPanelGpx arg_gpxFile; - - /** - * コンストラクタ - * @param tabbe parent panel - * @param arg_gpxFile // 開始画像の基準時刻: - * @param text - * @param pre - * @param next - */ - public CardGpxFile( - JTabbedPane tabbe, - ParameterPanelGpx arg_gpxFile, - String text, - int pre, int next - ) { - super(tabbe, text, pre, next); - 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ノードは無視する。" - if (arg_gpxFile.noFirstNode != null) { - argsPanel.add(arg_gpxFile.noFirstNode); - } - - JPanel space = new JPanel(); - space.setMinimumSize(new Dimension(40, 20)); - space.setMaximumSize(new Dimension(40, Short.MAX_VALUE)); - argsPanel.add(space); - - this.mainPanel.add(argsPanel, BorderLayout.CENTER); - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return (arg_gpxFile.isEnable()); - } - - @Override - public void openAction() { - ; // 何もしない - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/Command.java b/src/main/java/osm/jp/gpx/matchtime/gui/Command.java deleted file mode 100644 index cb0f78e..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/Command.java +++ /dev/null @@ -1,70 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.lang.reflect.InvocationTargetException; -import java.text.SimpleDateFormat; - -public class Command extends Thread { - String[] args; // コマンドパラメータ - private String commandName = ""; // コマンド名 - @SuppressWarnings({ "rawtypes" }) - private final Class cmd; // 実行対象インスタンス - - /** - * コンストラクタ:実行対象のインスタンスを得る - * @param cmd - */ - public Command(Class cmd) { - super(); - this.cmd = cmd; - this.commandName = cmd.getName(); - this.args = new String[0]; - } - - /** - * コマンドパラメータの設定 - * @param args - */ - public void setArgs(String[] args) { - this.args = args; - } - - public void setCommandName(String name) { - this.commandName = name; - } - public String getCommandName() { - return this.commandName; - } - - @SuppressWarnings("unchecked") - @Override - public void run() { - System.out.println("[START:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); - for (int i=0; i < args.length; i++) { - System.out.println(" args["+ i +"]: "+ this.args[i]); - } - System.out.println(); - - try { - try { - java.lang.reflect.Method method = this.cmd.getMethod("main", new Class[] {String[].class}); - method.setAccessible(true); - method.invoke(null, new Object[]{this.args}); - - System.out.println(); - System.out.println("[END:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); - } - catch (InvocationTargetException e) { - System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); - throw e; - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException e) { - System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); - throw e; - } - } - catch(InvocationTargetException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException e) { - e.printStackTrace(System.out); - } - System.out.println(); - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java deleted file mode 100644 index a558bd0..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/DoDialog.java +++ /dev/null @@ -1,227 +0,0 @@ -package osm.jp.gpx.matchtime.gui; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.io.*; -import javax.swing.*; - -/** - * 処理 - */ -@SuppressWarnings("serial") -public class DoDialog extends JDialog { - public static final String TITLE = "Do Command"; - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - String[] args; - - //{{DECLARE_CONTROLS - JPanel buttonPanel; // ボタン配置パネル (下部) - JButton closeButton; // [クローズ]ボタン - JButton doButton; // [実行]ボタン - JTextArea textArea; // 実行結果を表示するJTextArea (中央) - //}} - - public DoDialog(String[] args) { - super(); // モーダルダイアログを基盤にする - this.args = args; - - // INIT_CONTROLS - Container container = getContentPane(); - container.setLayout(new BorderLayout()); - //parentFrame.setVisible(false); - setSize(getInsets().left + getInsets().right + 980, getInsets().top + getInsets().bottom + 480); - setTitle(DoDialog.TITLE); - - // コントロールパネル - buttonPanel = new JPanel(); - - doButton = new JButton("実行"); - doButton.setToolTipText("処理を実行します."); - doButton.setEnabled(true); - doButton.addActionListener((ActionEvent event) -> { - // 処理中であることを示すため - // ボタンの文字列を変更し,使用不可にする - doButton.setText("処理中..."); - doButton.setEnabled(false); - - // SwingWorker を生成し,実行する - LongTaskWorker worker = new LongTaskWorker(doButton); - worker.execute(); - }); - buttonPanel.add(doButton); - - closeButton = new JButton("閉じる"); - closeButton.setToolTipText("処理を終了します."); - closeButton.addActionListener((ActionEvent event) -> { - dispose(); - }); - buttonPanel.add(closeButton); - - this.getContentPane().add("South", buttonPanel); - - // 説明文 - textArea = new JTextArea(); - JScrollPane sc=new JScrollPane(textArea); - textArea.setFont(new Font(Font.MONOSPACED,Font.PLAIN,12)); - textArea.setTabSize(4); - this.getContentPane().add("Center", sc); - - try { - textArea.append("> java -cp importPicture.jar osm.jp.gpx.ImportPicture"); - for (String arg : args) { - textArea.append(" '" + arg + "'"); - } - textArea.append("\n\n"); - } - catch (Exception e) { - System.out.println(e.toString()); - } - - // JFrameの表示 - //parentFrame.setVisible(true); - } - - /** - * Shows or hides the component depending on the boolean flag b. - * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す. - * @see java.awt.Component#isVisible - */ - @Override - public void setVisible(boolean b) { - if(b) { - setLocation(80, 80); - } - super.setVisible(b); - } - - @Override - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) { - return; - } - - // Adjust components according to the insets - setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height); - Component components[] = getComponents(); - for (Component component : components) { - Point p = component.getLocation(); - p.translate(getInsets().left, getInsets().top); - component.setLocation(p); - } - fComponentsAdjusted = true; - } - - - /** - * JTextAreaに書き出すOutputStream - */ - public static class JTextAreaOutputStream extends OutputStream { - private final ByteArrayOutputStream os; - - /** 書き出し対象 */ - private final JTextArea textArea; - private final String encode; - - public JTextAreaOutputStream(JTextArea textArea, String encode) { - this.textArea = textArea; - this.encode = encode; - this.os = new ByteArrayOutputStream(); - } - - /** - * OutputStream#write(byte[])のオーバーライド - * @param arg - * @throws java.io.IOException - */ - @Override - public void write(int arg) throws IOException { - this.os.write(arg); - } - - /** - * flush()でJTextAreaに書き出す - * @throws java.io.IOException - */ - @Override - public void flush() throws IOException { - // 文字列のエンコード - final String str = new String(this.os.toByteArray(), this.encode); - // 実際の書き出し処理 - SwingUtilities.invokeLater( - new Runnable(){ - @Override - public void run() { - JTextAreaOutputStream.this.textArea.append(str); - } - } - ); - // 書き出した内容はクリアする - this.os.reset(); - } - } - - // 非同期に行う処理を記述するためのクラス - class LongTaskWorker extends SwingWorker { - private final JButton button; - - public LongTaskWorker(JButton button) { - this.button = button; - } - - // 非同期に行われる処理 - @Override - public Object doInBackground() { - // ながーい処理 - PrintStream defOut = System.out; - PrintStream defErr = System.err; - - OutputStream os = new JTextAreaOutputStream(textArea, "UTF-8"); - PrintStream stdout = new PrintStream(os, true); // 自動flushをtrueにしておく - - // System.out にJTextAreaOutputStreamに書き出すPrintStreamを設定 - System.setOut(stdout); - System.setErr(stdout); - - try { - Command command = new Command(osm.jp.gpx.ImportPicture.class); - command.setArgs(args); - command.start(); // コマンドを実行 - while (command.isAlive()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) {} - } - } - catch(Exception e) { - e.printStackTrace(stdout); - } - finally { - System.setOut(defOut); - System.setErr(defErr); - doButton.setEnabled(true); - } - - return null; - } - - // 非同期処理後に実行 - @Override - protected void done() { - // 処理が終了したので,文字列を元に戻し - // ボタンを使用可能にする - button.setText("実行"); - button.setEnabled(true); - } - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/GpxAndFolderFilter.java b/src/main/java/osm/jp/gpx/matchtime/gui/GpxAndFolderFilter.java deleted file mode 100644 index 3c075cd..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/GpxAndFolderFilter.java +++ /dev/null @@ -1,25 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.io.File; -import javax.swing.filechooser.*; - -public class GpxAndFolderFilter extends FileFilter { - - @Override - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } - - String extension = Utils.getExtension(f); - if (extension != null) { - return extension.equals("gpx"); - } - return false; - } - - @Override - public String getDescription() { - return "Just GPXs"; - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java b/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java deleted file mode 100644 index 708c25a..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFileView.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle or the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package osm.jp.gpx.matchtime.gui; - -import java.io.File; -import javax.swing.*; -import javax.swing.filechooser.*; - -/* ImageFileView.java is used by FileChooserDemo2.java. */ -public class ImageFileView extends FileView { - ImageIcon jpgIcon = Utils.createImageIcon("/images/jpgIcon.gif"); - ImageIcon gifIcon = Utils.createImageIcon("/images/gifIcon.gif"); - ImageIcon tiffIcon = Utils.createImageIcon("/images/tiffIcon.gif"); - ImageIcon pngIcon = Utils.createImageIcon("/images/pngIcon.png"); - - @Override - public String getName(File f) { - return null; //let the L&F FileView figure this out - } - - @Override - public String getDescription(File f) { - return null; //let the L&F FileView figure this out - } - - @Override - public Boolean isTraversable(File f) { - return null; //let the L&F FileView figure this out - } - - @Override - public String getTypeDescription(File f) { - String extension = Utils.getExtension(f); - String type = null; - - if (extension != null) { - switch (extension) { - case Utils.JPEG: - case Utils.JPG: - type = "JPEG Image"; - break; - case Utils.GIF: - type = "GIF Image"; - break; - case Utils.TIFF: - case Utils.TIF: - type = "TIFF Image"; - break; - case Utils.PNG: - type = "PNG Image"; - break; - default: - break; - } - } - return type; - } - - @Override - public Icon getIcon(File f) { - String extension = Utils.getExtension(f); - Icon icon = null; - - if (extension != null) { - switch (extension) { - case Utils.JPEG: - case Utils.JPG: - icon = jpgIcon; - break; - case Utils.GIF: - icon = gifIcon; - break; - case Utils.TIFF: - case Utils.TIF: - icon = tiffIcon; - break; - case Utils.PNG: - icon = pngIcon; - break; - default: - break; - } - } - return icon; - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFilter.java b/src/main/java/osm/jp/gpx/matchtime/gui/ImageFilter.java deleted file mode 100644 index 012eeb6..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ImageFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle or the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package osm.jp.gpx.matchtime.gui; - -import java.io.File; -import javax.swing.filechooser.*; - -/* ImageFilter.java is used by FileChooserDemo2.java. */ -public class ImageFilter extends FileFilter { - - //Accept all directories and all gif, jpg, tiff, or png files. - @Override - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } - - String extension = Utils.getExtension(f); - if (extension != null) { - return extension.equals(Utils.TIFF) || - extension.equals(Utils.TIF) || - extension.equals(Utils.GIF) || - extension.equals(Utils.JPEG) || - extension.equals(Utils.JPG) || - extension.equals(Utils.PNG); - } - return false; - } - - //The description of this filter - @Override - public String getDescription() { - return "Just Images"; - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java b/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java deleted file mode 100644 index d07d90f..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ImagePreview.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle or the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package osm.jp.gpx.matchtime.gui; - -import javax.swing.*; - -import java.beans.*; -import java.awt.*; -import java.io.File; - -/* ImagePreview.java by FileChooserDemo2.java. */ -@SuppressWarnings("serial") -public class ImagePreview extends JComponent implements PropertyChangeListener { - ImageIcon thumbnail = null; - File file = null; - static int IMAGE_SIZE_X = 320; - static int IMAGE_SIZE_Y = 240; - - @SuppressWarnings({}) - public ImagePreview(JFileChooser fc) { - setPreferredSize(new Dimension(IMAGE_SIZE_X + 10, IMAGE_SIZE_Y + 10)); - fc.addPropertyChangeListener(this); - } - - public void loadImage() { - if (file == null) { - thumbnail = null; - return; - } - - //Don't use createImageIcon (which is a wrapper for getResource) - //because the image we're trying to load is probably not one - //of this program's own resources. - ImageIcon tmpIcon = new ImageIcon(file.getPath()); - if (tmpIcon.getIconWidth() > IMAGE_SIZE_X) { - thumbnail = new ImageIcon(tmpIcon.getImage(). - getScaledInstance(IMAGE_SIZE_X, -1, Image.SCALE_DEFAULT)); - } else { //no need to miniaturize - thumbnail = tmpIcon; - } - } - - @Override - public void propertyChange(PropertyChangeEvent e) { - boolean update = false; - String prop = e.getPropertyName(); - - if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) { - file = null; - update = true; - } - else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) { - file = (File) e.getNewValue(); - update = true; - } - if (update) { - thumbnail = null; - if (isShowing()) { - loadImage(); - repaint(); - } - } - } - - @Override - protected void paintComponent(Graphics g) { - if (thumbnail == null) { - loadImage(); - } - if (thumbnail != null) { - int x = getWidth()/2 - thumbnail.getIconWidth()/2; - int y = getHeight()/2 - thumbnail.getIconHeight()/2; - - if (y < 0) { - y = 0; - } - - if (x < 5) { - x = 5; - } - thumbnail.paintIcon(this, g, x, y); - } - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/PanelAction.java b/src/main/java/osm/jp/gpx/matchtime/gui/PanelAction.java deleted file mode 100644 index 88085dc..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/PanelAction.java +++ /dev/null @@ -1,11 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -public interface PanelAction { - void openAction(); - - /** - * 入力条件が満たされているかどうか - * @return - */ - boolean isEnable(); -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParamAction.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParamAction.java deleted file mode 100644 index d09db2e..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParamAction.java +++ /dev/null @@ -1,7 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -public interface ParamAction { - boolean isEnable(); - void setText(String text); - String getText(); -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterData.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterData.java deleted file mode 100644 index 76eb082..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterData.java +++ /dev/null @@ -1,23 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.util.Observable; - -public class ParameterData extends Observable { - String content = ""; - - String getContent() { - return content; - } - - void setContent(String content) { - this.content = content; - setChanged(); - super.notifyObservers(content); - clearChanged(); - } - - @Override - public void notifyObservers(Object arg) { - setContent(arg.toString()); - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java deleted file mode 100644 index d26be5e..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanel.java +++ /dev/null @@ -1,53 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.Dimension; -import java.util.ResourceBundle; - -import javax.swing.BoxLayout; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -/** - * パラメータを設定する為のパネル。 - * この1インスタンスで、1パラメータをあらわす。 - */ -public abstract class ParameterPanel extends JPanel implements ParamAction { - private static final long serialVersionUID = 4629824800747170556L; - public JTextField argField; - public JLabel argLabel; - public ResourceBundle i18n = ResourceBundle.getBundle("i18n"); - - public ParameterPanel(String label, String text) { - this(); - this.argLabel.setText(label); - this.argField.setText(text); - } - - public ParameterPanel() { - super(); - - 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; - } - - @Override - public void setText(String text) { - this.argField.setText(text); - } - - @Override - public String getText() { - return this.argField.getText(); - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java deleted file mode 100644 index b6dae01..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelFolder.java +++ /dev/null @@ -1,107 +0,0 @@ -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 -{ - JFileChooser fc; - JButton selectButton; - int chooser; - - /** - * コンストラクタ - * ディレクトリのみ選択可能なダイアログ - * @param label - * @param text - */ - public ParameterPanelFolder(String label, String text) { - this(label, text, JFileChooser.DIRECTORIES_ONLY); - } - - public ParameterPanelFolder(String label, String text, int chooser) { - super(label, text); - - // Create a file chooser - this.chooser = chooser; - - // "選択..." - selectButton = new JButton( - i18n.getString("button.select"), - AdjustTerra.createImageIcon("/images/Open16.gif") - ); - selectButton.addActionListener(this); - this.add(selectButton); - } - - public void setEnable(boolean f) { - super.setEnabled(f); - selectButton.setEnabled(f); - } - - public File getDirectory() throws FileNotFoundException { - String path = this.argField.getText(); - if (path == null) { - throw new FileNotFoundException("Folder is Not specifiyed yet."); - } - File sdir = new File(path); - if (!sdir.exists()) { - throw new FileNotFoundException(String.format("Folder '%s' is Not exists.", path)); - } - if (!sdir.isDirectory()) { - throw new FileNotFoundException(String.format("Folder '%s' is Not directory.", path)); - } - return sdir; - } - - @Override - public void actionPerformed(ActionEvent e) { - if (e.getSource() == selectButton){ - File sdir; - try { - sdir = getDirectory(); - } catch (FileNotFoundException ex) { - sdir = new File("."); - this.argField.setText(sdir.getAbsolutePath()); - } - 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()); - } - } - } - - /** - * 有効な値が設定されているかどうか - * @return - */ - @Override - public boolean isEnable() { - String text = this.argField.getText(); - if (text == null) { - return false; - } - try { - File dir = new File(text); - return (dir.exists() && dir.isDirectory()); - } - catch (Exception e) { - return false; - } - } -} \ No newline at end of file diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java deleted file mode 100644 index ddb975e..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelGpx.java +++ /dev/null @@ -1,107 +0,0 @@ -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.JCheckBox; -import javax.swing.JFileChooser; -import osm.jp.gpx.AppParameters; - -@SuppressWarnings("serial") -public class ParameterPanelGpx extends ParameterPanel implements ActionListener -{ - JFileChooser fc; - JButton selectButton; - public JCheckBox noFirstNode; // CheckBox: "セグメント'trkseg'の最初の1ノードは無視する。" - - /** - * コンストラクタ - * @param label - * @param text - */ - public ParameterPanelGpx(String label, String text) { - super(label, text); - - // "選択..." - selectButton = new JButton( - i18n.getString("button.select"), - AdjustTerra.createImageIcon("/images/Open16.gif") - ); - selectButton.addActionListener(this); - this.add(selectButton); - } - - @Override - public void actionPerformed(ActionEvent e) { - if (e.getSource() == selectButton){ - System.out.println("ParameterPanelGpx.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(JFileChooser.FILES_AND_DIRECTORIES); - this.fc.addChoosableFileFilter(new GpxAndFolderFilter()); - this.fc.setAcceptAllFileFilterUsed(false); - - int returnVal = this.fc.showOpenDialog(ParameterPanelGpx.this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = this.fc.getSelectedFile(); - this.argField.setText(file.getAbsolutePath()); - } - } - } - - public File getGpxFile() { - if (isEnable()) { - return new File(getText()); - } - return null; - } - - /** - * "セグメント'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("true")) { - selected = true; - } - noFirstNode = new JCheckBox(label, selected); - } - - public boolean isNoFirstNodeSelected() { - return (noFirstNode != null) && noFirstNode.isSelected(); - } - - /** - * このフィールドに有効な値が設定されているかどうか - * @return - */ - @Override - public boolean isEnable() { - String text = this.argField.getText(); - if (text != null) { - File file = new File(text); - if (file.exists()) { - if (file.isFile()) { - String name = file.getName().toUpperCase(); - if (name.endsWith(".GPX")) { - return true; - } - } - else if (file.isDirectory()) { - return true; - } - } - } - return false; - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java deleted file mode 100644 index 829a8a1..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java +++ /dev/null @@ -1,107 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileNotFoundException; -import javax.swing.JButton; -import javax.swing.JFileChooser; - -@SuppressWarnings("serial") -public class ParameterPanelImageFile extends ParameterPanel { - JFileChooser fc; - public JButton openButton; - public ParameterPanelFolder paramDir; - - public ParameterPanelImageFile( - String label, String text, - ParameterPanelFolder paramDir - ) { - super(label, text); - - // "選択..." - SelectButtonAction buttonAction = new SelectButtonAction(); - openButton = new JButton(i18n.getString("button.select")); - openButton.addActionListener(buttonAction); - this.add(openButton); - - //Create a file chooser - this.paramDir = paramDir; - } - - class SelectButtonAction implements java.awt.event.ActionListener - { - public void actionPerformed(ActionEvent e) { - selectImage_Action(e); - } - } - - public void selectImage_Action(ActionEvent ev) { - File sdir = new File(paramDir.getText()); - System.out.println(sdir.toPath()); - 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(ParameterPanelImageFile.this, i18n.getString("dialog.select")); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - this.argField.setText(file.getName()); - } - fc.setSelectedFile(null); - } - - public File getImageFile() { - if (this.paramDir.isEnable()) { - String text = this.argField.getText(); - if (text != null) { - try { - File dir = this.paramDir.getDirectory(); - File file = new File(dir, text); - if (file.exists() && file.isFile()) { - return file; - } - } - catch (FileNotFoundException e) { - return null; - } - } - } - return null; - } - - /** - * - * @return - */ - @Override - public boolean isEnable() { - if (this.paramDir.isEnable()) { - String text = this.argField.getText(); - if (text != null) { - try { - File dir = this.paramDir.getDirectory(); - File file = new File(dir, text); - if (file.exists() && file.isFile()) { - String name = file.getName().toUpperCase(); - if (name.endsWith(".JPG") || name.endsWith(".JPEG")) { - return true; - } - } - } - catch (FileNotFoundException e) { - return false; - } - } - } - return false; - } -} \ No newline at end of file diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java deleted file mode 100644 index 07059b2..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelOutput.java +++ /dev/null @@ -1,108 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import javax.swing.JCheckBox; -import javax.swing.JFileChooser; -import osm.jp.gpx.AppParameters; - -@SuppressWarnings("serial") -public class ParameterPanelOutput extends ParameterPanelFolder -{ - JCheckBox outputIMG; // IMGの変換 する/しない - JCheckBox outputIMG_all; // 'out of GPX time'でもIMGの変換をする {ON | OFF} - JCheckBox exifON; // EXIF 書き出しモード / !(EXIFの書き換えはしない) - JCheckBox gpxOverwriteMagvar; // ソースGPXのを無視する - JCheckBox gpxOutputSpeed; // GPXにを書き出す - - /** - * コンストラクタ - * ディレクトリのみ選択可能なダイアログ - * @param label - * @param text - */ - public ParameterPanelOutput(String label, String text) { - super(label, text, JFileChooser.DIRECTORIES_ONLY); - } - - /** - * チェックボックス "IMGの変換をする" - * @param label テキスト - * @param params プロパティ - */ - public void addCheckChangeImage(String label, AppParameters params) { - boolean selected = false; - if (params.getProperty(AppParameters.IMG_OUTPUT).equals("true")) { - selected = true; - } - outputIMG = new JCheckBox(label, selected); - } - - /** - * チェックボックス "GPXファイル時間外のファイルもコピーする" - * @param label - * @param params - */ - public void addCheckOutofGpxTime(String label, AppParameters params) { - boolean selected = false; - if (params.getProperty(AppParameters.IMG_OUTPUT_ALL).equals("true")) { - selected = true; - } - outputIMG_all = new JCheckBox(label, selected); - } - - /** - * チェックボックス "EXIFの変換をする" - * @param label - * @param params - */ - public void addCheckOutputExif(String label, AppParameters params) { - boolean selected = false; - if (params.getProperty(AppParameters.IMG_OUTPUT_EXIF).equals("true")) { - selected = true; - } - exifON = new JCheckBox(label, selected); - } - - /** - * チェックボックス "ソースGPXの<MAGVAR>を無視する" - * @param label - * @param params - */ - public void addCheckIgnoreMagvar(String label, AppParameters params) { - boolean selected = false; - if (params.getProperty(AppParameters.GPX_OVERWRITE_MAGVAR).equals("true")) { - selected = true; - } - gpxOverwriteMagvar = new JCheckBox(label, selected); - gpxOverwriteMagvar.setEnabled(true); - } - - /** - * チェックボックス "出力GPXに[SPEED]を上書きする" - * @param label - * @param params - */ - public void addCheckOutputSpeed(String label, AppParameters params) { - boolean selected = false; - if (params.getProperty(AppParameters.GPX_OUTPUT_SPEED).equals("true")) { - selected = true; - } - gpxOutputSpeed = new JCheckBox(label, selected); - gpxOutputSpeed.setEnabled(true); - } - - /** - * checkbox[IMG変換]を変更した場合のアクション - * ON ー> IMG出力フォルダのフィールドを有効にする - * OFF -> IMG出力フォルダのフィールドを無効にする - * @param event - */ - class ChangeImageAction implements java.awt.event.ActionListener { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == outputIMG) { - setEnabled(outputIMG.isEnabled()); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java deleted file mode 100644 index 251710f..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelSelecter.java +++ /dev/null @@ -1,44 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - -@SuppressWarnings("serial") -public class ParameterPanelSelecter extends JPanel implements ActionListener { - public static final int ITEM_WIDTH_1 = 160; - public static final int ITEM_WIDTH_2 = 240; - public static final int LINE_WIDTH = ITEM_WIDTH_1 + ITEM_WIDTH_2; - public static final int LINE_HEIGHT = 18; - public JLabel label; - public JComboBox field; - public String value; - - public ParameterPanelSelecter(String title, String[] items) { - super(null); - this.value = items[0]; - - this.label = new JLabel(title, JLabel.RIGHT); - this.label.setBounds(0, 0, ITEM_WIDTH_1 - 6, LINE_HEIGHT); - add(this.label); - - this.field = new JComboBox<>(); - this.field.addActionListener(this); - for (String item : items) { - this.field.addItem(item); - } - this.field.setBounds(ITEM_WIDTH_1, 0, ITEM_WIDTH_2, LINE_HEIGHT); - add(this.field); - - setPreferredSize(new Dimension(ITEM_WIDTH_1, LINE_HEIGHT)); - } - - @Override - public void actionPerformed(ActionEvent e) { - this.value = (String)this.field.getSelectedItem(); - } -} \ No newline at end of file diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java b/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java deleted file mode 100644 index 1202e7e..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java +++ /dev/null @@ -1,193 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -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.ImageReadException; -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.AdjustTerra.dfjp; -import osm.jp.gpx.matchtime.gui.restamp.DialogCorectTime; - -/** - * パラメータを設定する為のパネル。 - * この1インスタンスで、1パラメータをあらわす。 - */ -public class ParameterPanelTime extends ParameterPanel { - private static final long serialVersionUID = 1683226418990348336L; - SimpleDateFormat sdf = (SimpleDateFormat)DateFormat.getDateTimeInstance(); - ParameterPanelImageFile imageFile; // 基準時刻画像 - - - // 基準時刻の指定グループ (排他選択) - public ButtonGroup baseTimeGroup = new ButtonGroup(); - public JRadioButton exifBase = null; // EXIF日時を基準にする/ !(ファイル更新日時を基準にする) - public JRadioButton fupdateBase = null; // File更新日時を基準にする/ !(EXIF日時を基準にする) - - public JButton updateButton; - public JButton resetButton; - Window owner; - - public ParameterPanelTime( - String label, - String text, - ParameterPanelImageFile imageFile - ) { - super(label, text); - this.imageFile = imageFile; - - // "ボタン[変更...]" - UpdateButtonAction buttonAction = new UpdateButtonAction(this); - updateButton = new JButton(i18n.getString("button.update")); - updateButton.addActionListener(buttonAction); - this.add(updateButton); - - // "ボタン[再設定...]" - ResetButtonAction resetAction = new ResetButtonAction(this); - resetButton = new JButton(i18n.getString("button.reset")); - resetButton.addActionListener(resetAction); - resetButton.setVisible(false); - this.add(resetButton); - } - - 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")) { - selected = true; - } - fupdateBase = new JRadioButton(label, selected); - baseTimeGroup.add(fupdateBase); - } - - public ParameterPanelImageFile getImageFile() { - return this.imageFile; - } - - - /** - * [変更...]ボタンのアクション - */ - class UpdateButtonAction implements java.awt.event.ActionListener - { - ParameterPanelTime param; - - public UpdateButtonAction(ParameterPanelTime param) { - this.param = param; - } - - public void actionPerformed(ActionEvent e) { - fileSelect_Action(param); - (new DialogCorectTime(param, owner)).setVisible(true); - } - } - - /** - * [再設定...]ボタンのアクション - */ - class ResetButtonAction implements java.awt.event.ActionListener - { - ParameterPanelTime paramPanelTime; - - public ResetButtonAction(ParameterPanelTime param) { - this.paramPanelTime = param; - } - - public void actionPerformed(ActionEvent e) { - 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 (IOException | ParseException | ImageReadException ex) {} - } - else { - long lastModified = timeFile.lastModified(); - param.argField.setText(sdf.format(new Date(lastModified))); - } - } - else { - param.argField.setText(""); - } - } - - @Override - public boolean isEnable() { - if (this.imageFile.isEnable()) { - String text = this.argField.getText(); - if (text != null) { - try { - sdf.applyPattern(Restamp.TIME_PATTERN); - sdf.parse(text); - return true; - } - catch (ParseException e) { - return false; - } - } - } - return false; - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java deleted file mode 100644 index 9f63cba..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/QuitDialog.java +++ /dev/null @@ -1,106 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import java.awt.Font; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.Window; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.util.ResourceBundle; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; - -@SuppressWarnings("serial") -public class QuitDialog extends JDialog implements WindowListener -{ - JButton yesButton; - JButton noButton; - JLabel label1; - - public QuitDialog(JFrame parent, boolean modal) { - super(parent, modal); - - ResourceBundle i18n = ResourceBundle.getBundle("i18n"); - - addWindowListener((WindowListener) this); - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - setLayout(null); - setSize(getInsets().left + getInsets().right + 337, getInsets().top + getInsets().bottom + 135); - - yesButton = new JButton(String.format(" %s ", i18n.getString("dialog.quit"))); - yesButton.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent((Window)getParent(), 201)); - System.exit(0); - } - }); - yesButton.setBounds(getInsets().left + 72, getInsets().top + 80, 79, 22); - yesButton.setFont(new Font("Dialog", 1, 12)); - add(yesButton); - - noButton = new JButton(i18n.getString("dialog.cancel")); - noButton.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(QuitDialog.this, WindowEvent.WINDOW_CLOSING)); - setVisible(false); - } - }); - noButton.setBounds(getInsets().left + 185, getInsets().top + 80, 99, 22); - noButton.setFont(new Font("Dialog", 1, 12)); - add(noButton); - - label1 = new JLabel(i18n.getString("dialog.msg1"), JLabel.CENTER); - label1.setBounds(78, 33, 180, 23); - add(label1); - setTitle(i18n.getString("dialog.msg1")); - setResizable(false); - setVisible(true); - } - - @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); - } - - - @Override - public void windowActivated(WindowEvent e) { - } - - @Override - public void windowClosed(WindowEvent e) { - setVisible(false); - } - - @Override - public void windowClosing(WindowEvent e) { - setVisible(false); - } - - @Override - public void windowDeactivated(WindowEvent e) { - } - - @Override - public void windowDeiconified(WindowEvent e) { - } - - @Override - public void windowIconified(WindowEvent e) { - } - - @Override - public void windowOpened(WindowEvent e) { - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/SimpleDocumentListener.java b/src/main/java/osm/jp/gpx/matchtime/gui/SimpleDocumentListener.java deleted file mode 100644 index 735c6ee..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/SimpleDocumentListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package osm.jp.gpx.matchtime.gui; - -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -@FunctionalInterface -public interface SimpleDocumentListener extends DocumentListener { - void update(DocumentEvent e); - - @Override - default void insertUpdate(DocumentEvent e) { - update(e); - } - - @Override - default void removeUpdate(DocumentEvent e) { - update(e); - } - - @Override - default void changedUpdate(DocumentEvent e) { - update(e); - } -} - diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/Utils.java b/src/main/java/osm/jp/gpx/matchtime/gui/Utils.java deleted file mode 100644 index 2f3880f..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/Utils.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Oracle or the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package osm.jp.gpx.matchtime.gui; - -import java.io.File; -import javax.swing.ImageIcon; - -/* Utils.java is used by FileChooserDemo2.java. */ -public class Utils { - - /** - * - */ - public final static String JPEG = "jpeg"; - public final static String JPG = "jpg"; - public final static String GIF = "gif"; - public final static String TIFF = "tiff"; - public final static String TIF = "tif"; - public final static String PNG = "png"; - - /* - * Get the extension of a file. - */ - public static String getExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); - - if (i > 0 && i < s.length() - 1) { - ext = s.substring(i+1).toLowerCase(); - } - return ext; - } - - /** Returns an ImageIcon, or null if the path was invalid. - * @param path - * @return - */ - protected static ImageIcon createImageIcon(String path) { - java.net.URL imgURL = Utils.class.getResource(path); - if (imgURL != null) { - return new ImageIcon(imgURL); - } else { - System.err.println("Couldn't find file: " + path); - return null; - } - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java deleted file mode 100644 index 9ebcd0a..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardImageFile.java +++ /dev/null @@ -1,89 +0,0 @@ -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.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; -import osm.jp.gpx.matchtime.gui.Card; -import osm.jp.gpx.matchtime.gui.PanelAction; -import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; -import osm.jp.gpx.matchtime.gui.ParameterPanelTime; - -/** - * [基準画像(開始/終了)]選択パネル - * @author haya4 - */ -public class CardImageFile extends Card implements PanelAction { - private static final long serialVersionUID = 1L; - ParameterPanelImageFile arg_baseTimeImg; - ParameterPanelTime arg_basetime; - - /** - * コンストラクタ - * @param tabbe parent panel - * @param arg_basetime // 開始画像の基準時刻: - * @param owner - * @param text - * @param pre - * @param next - */ - public CardImageFile( - JTabbedPane tabbe, - ParameterPanelTime arg_basetime, - Window owner, - String text, - int pre, int next - ) { - super(tabbe, text, pre, next); - arg_basetime.setOwner(owner); - this.arg_baseTimeImg = arg_basetime.getImageFile(); - this.arg_basetime = arg_basetime; - - JPanel argsPanel = new JPanel(); - argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS)); - argsPanel.add(packLine(new JLabel(i18n.getString("label.200")), new JPanel())); - argsPanel.add(arg_baseTimeImg); - - JPanel separater = new JPanel(); - separater.setMinimumSize(new Dimension(40, 20)); - argsPanel.add(separater); - - 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)); - argsPanel.add(space); - - this.mainPanel.add(argsPanel, BorderLayout.CENTER); - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return (arg_baseTimeImg.isEnable() && arg_basetime.isEnable()); - } - - @Override - public void openAction() { - ; // 何もしない - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java deleted file mode 100644 index c323d7c..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardPerformFile.java +++ /dev/null @@ -1,102 +0,0 @@ -package osm.jp.gpx.matchtime.gui.restamp; - -import java.awt.BorderLayout; -import java.io.File; -import java.util.ArrayList; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import osm.jp.gpx.matchtime.gui.AdjustTerra; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; -import osm.jp.gpx.matchtime.gui.Card; -import osm.jp.gpx.matchtime.gui.PanelAction; -import osm.jp.gpx.matchtime.gui.ParameterPanelTime; - -/** - * [基準画像(開始/終了)]選択パネル - * @author yuu - */ -public class CardPerformFile extends Card implements PanelAction { - private static final long serialVersionUID = -4796133437768564759L; - ParameterPanelTime arg1_basetime; - ParameterPanelTime arg2_basetime; - JButton doButton; // [処理実行]ボタン - - /** - * コンストラクタ - * @param tabbe parent panel - * @param arg1_basetime // 開始画像の基準時刻: - * @param arg2_basetime // 開始画像の基準時刻: - */ - public CardPerformFile( - JTabbedPane tabbe, - ParameterPanelTime arg1_basetime, - ParameterPanelTime arg2_basetime - ) { - super(tabbe, AdjustTerra.i18n.getString("tab.restamp.400"), 2, 4); - this.arg1_basetime = arg1_basetime; - this.arg2_basetime = arg2_basetime; - - JPanel argsPanel = new JPanel(); - argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS)); - argsPanel.add(packLine(new JLabel(i18n.getString("label.200")), new JPanel())); - - // [処理実行]ボタン - doButton = new JButton( - i18n.getString("button.execute"), - AdjustTerra.createImageIcon("/images/media_playback_start.png") - ); - argsPanel.add(doButton); - - this.mainPanel.add(argsPanel, BorderLayout.CENTER); - - //{{REGISTER_LISTENERS - SymAction lSymAction = new SymAction(); - doButton.addActionListener(lSymAction); - //}} - } - - class SymAction implements java.awt.event.ActionListener { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == doButton) { - doButton_Action(event); - } - } - } - - /** - * [実行]ボタンをクリックしたときの動作 - * @param event - */ - void doButton_Action(java.awt.event.ActionEvent event) { - ArrayList arry = new ArrayList<>(); - File file = arg1_basetime.getImageFile().getImageFile(); - File dir = file.getParentFile(); - arry.add(dir.getAbsolutePath()); - arry.add(file.getName()); - arry.add(arg1_basetime.argField.getText()); - file = arg2_basetime.getImageFile().getImageFile(); - arry.add(file.getName()); - arry.add(arg2_basetime.argField.getText()); - String[] argv = arry.toArray(new String[arry.size()]); - (new DoRestamp(argv)).setVisible(true); - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return (arg1_basetime.isEnable() && arg2_basetime.isEnable()); - } - - @Override - public void openAction() { - ; // 何もしない - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java deleted file mode 100644 index bc967bd..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/CardSourceFolder.java +++ /dev/null @@ -1,51 +0,0 @@ -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.AdjustTerra; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.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 { - private static final long serialVersionUID = -5496892696559069841L; - ParameterPanelFolder arg_srcFolder; // 対象フォルダ - - /** - * コンストラクタ - * @param tabbe parent panel - * @param arg_srcFolder 対象フォルダ - */ - public CardSourceFolder(JTabbedPane tabbe, ParameterPanelFolder arg_srcFolder) { - super(tabbe, AdjustTerra.i18n.getString("tab.100"), -1, 1); - this.arg_srcFolder = arg_srcFolder; - 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(arg_srcFolder); - this.mainPanel.add(argsPanel, BorderLayout.CENTER); - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return this.arg_srcFolder.isEnable(); - } - - @Override - public void openAction() { - ; // 何もしない - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java deleted file mode 100644 index 89e81c3..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DialogCorectTime.java +++ /dev/null @@ -1,228 +0,0 @@ -package osm.jp.gpx.matchtime.gui.restamp; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.GridLayout; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.Window; -import javax.swing.BoxLayout; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import osm.jp.gpx.matchtime.gui.AdjustTerra; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.createImageIcon; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; -import osm.jp.gpx.matchtime.gui.PanelAction; -import osm.jp.gpx.matchtime.gui.ParameterPanelTime; - -/** - * [基準画像(開始)]選択パネル - * @author yuu - */ -public class DialogCorectTime extends JDialog implements PanelAction { - private static final long serialVersionUID = -3573167730473345932L; - public JPanel mainPanel; - ParameterPanelTime arg_basetime; // 開始画像の基準時刻(parent) - ParameterPanelTime basetime; // 開始画像の基準時刻(tempolarry) - java.awt.Button closeButton; - JButton expandButton; - JButton zoomInButton; - JButton zoomOutButton; - JLabel imageLabel; // 開始画像の基準時刻画像表示 - JScrollPane imageSPane; // スクロールパネル - - /** - * コンストラクタ - * @param arg3_basetime 開始画像の基準時刻: - * @param owner - */ - public DialogCorectTime(ParameterPanelTime arg3_basetime, Window owner) { - super(owner, AdjustTerra.i18n.getString("tab.restamp.300"), Dialog.ModalityType.DOCUMENT_MODAL); - this.arg_basetime = arg3_basetime; - - // INIT_CONTROLS - setLayout(new BorderLayout()); - setSize( - getInsets().left + getInsets().right + 720, - getInsets().top + getInsets().bottom + 480 - ); - - //---- CENTER ----- - JPanel centerPanel = new JPanel(); - centerPanel.setLayout(new BorderLayout()); - add(centerPanel, BorderLayout.CENTER); - - //---- CENTER.NORTH ----- - JPanel argsPanel; // パラメータ設定パネル (上部) - argsPanel = new JPanel(); - argsPanel.setLayout(new GridLayout(2, 1)); - - // 3. 正確な撮影時刻を入力してください。 - // カメラの時計が正確ならば、設定を変更する必要はありません。 - JLabel label3 = new JLabel(); - label3.setText(i18n.getString("label.300")); - argsPanel.add(label3); - - basetime = new ParameterPanelTime( - arg_basetime.argLabel.getText(), - "", - arg_basetime.getImageFile() - ); - basetime.updateButton.setVisible(false); - basetime.resetButton.setVisible(true); - argsPanel.add(basetime); - centerPanel.add(argsPanel, BorderLayout.NORTH); - - //---- CENTER.CENTER ----- - // 参考画像 - imageLabel = new JLabel(); - imageSPane = new JScrollPane(imageLabel); - centerPanel.add(imageSPane, BorderLayout.CENTER); - - //---- CENTER.SOUTH ----- - // 画像ファイル選択ダイアログを起動するボタン - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); - expandButton = new JButton(createImageIcon("/images/Fit16.gif")); - buttonPanel.add(expandButton); - zoomInButton = new JButton(createImageIcon("/images/ZoomIn16.gif")); - buttonPanel.add(zoomInButton); - zoomOutButton = new JButton(createImageIcon("/images/ZoomOut16.gif")); - buttonPanel.add(zoomOutButton); - centerPanel.add(buttonPanel, BorderLayout.SOUTH); - - //---- SOUTH ----- - closeButton = new java.awt.Button(); - closeButton.setLabel(i18n.getString("button.close") ); - closeButton.setBounds(145,65,66,27); - add(closeButton, BorderLayout.SOUTH); - - // 選択された画像ファイルを表示する - imageView_Action(); - - //{{REGISTER_LISTENERS - SymWindow aSymWindow = new SymWindow(); - this.addWindowListener(aSymWindow); - SymAction lSymAction = new SymAction(); - closeButton.addActionListener(lSymAction); - expandButton.addActionListener(lSymAction); - zoomInButton.addActionListener(lSymAction); - zoomOutButton.addActionListener(lSymAction); - //}} - } - - class SymWindow extends java.awt.event.WindowAdapter - { - @Override - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == DialogCorectTime.this) { - dialog_WindowClosing(); - } - } - } - - class SymAction implements java.awt.event.ActionListener - { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == closeButton) { - dialog_WindowClosing(); - } - else if (object == expandButton) { - imageView_Action(); - } - else if (object == zoomInButton) { - zoomin_Action(); - } - else if (object == zoomOutButton) { - zoomout_Action(); - } - } - } - - ImageIcon refImage; - - /** - * 選択された画像ファイルを表示する - * 基準画像ボタンがクリックされた時に、基準時刻フィールドに基準画像の作成日時を設定する。 - */ - public void imageView_Action() { - try { - String path = basetime.getImageFile().getImageFile().getAbsolutePath(); - - // View Image File - 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); - } - catch(NullPointerException e) { - // 何もしない - } - repaint(); - } - - public void zoomin_Action() { - if (refImage != null) { - int size_x = imageLabel.getWidth(); - 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); - repaint(); - } - } - - public void zoomout_Action() { - if (refImage != null) { - int size_x = imageLabel.getWidth(); - ImageIcon tmpIcon = refImage; - refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x / 2, -1, Image.SCALE_DEFAULT)); - imageLabel.setIcon(refImage); - repaint(); - } - } - - /** - * ダイアログが閉じられるときのアクション - */ - void dialog_WindowClosing() { - String workStr = basetime.getText(); - arg_basetime.setText(workStr); - dispose(); - } - - @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); - } - - @Override - public void openAction() { - ; // 何もしない - } - - /** - * 入力条件が満たされているかどうか - * @return - */ - @Override - public boolean isEnable() { - return this.basetime.isEnable(); - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java deleted file mode 100644 index e98f1ba..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/DoRestamp.java +++ /dev/null @@ -1,227 +0,0 @@ -package osm.jp.gpx.matchtime.gui.restamp; -import osm.jp.gpx.matchtime.gui.Command; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.io.*; -import javax.swing.*; - -/** - * 処理 - */ -@SuppressWarnings("serial") -public class DoRestamp extends JDialog { - public static final String TITLE = "Do Command"; - - // Used for addNotify check. - boolean fComponentsAdjusted = false; - String[] args; - - //{{DECLARE_CONTROLS - JPanel buttonPanel; // ボタン配置パネル (下部) - JButton closeButton; // [クローズ]ボタン - JButton doButton; // [実行]ボタン - JTextArea textArea; // 実行結果を表示するJTextArea (中央) - //}} - - public DoRestamp(String[] args) { - super(); // 親フォームなしのモーダルダイアログを基盤にする - this.args = args; - - // INIT_CONTROLS - Container container = getContentPane(); - container.setLayout(new BorderLayout()); - setSize(getInsets().left + getInsets().right + 980, getInsets().top + getInsets().bottom + 480); - setTitle(DoRestamp.TITLE); - - // コントロールパネル - buttonPanel = new JPanel(); - - doButton = new JButton("実行"); - doButton.setToolTipText("処理を実行します."); - doButton.setEnabled(true); - doButton.addActionListener((ActionEvent event) -> { - // 処理中であることを示すため - // ボタンの文字列を変更し,使用不可にする - doButton.setText("処理中..."); - doButton.setEnabled(false); - - // SwingWorker を生成し,実行する - LongTaskWorker worker = new LongTaskWorker(doButton); - worker.execute(); - }); - buttonPanel.add(doButton); - - closeButton = new JButton("閉じる"); - closeButton.setToolTipText("処理を終了します."); - closeButton.addActionListener((ActionEvent event) -> { - dispose(); - }); - buttonPanel.add(closeButton); - - this.getContentPane().add("South", buttonPanel); - - // 説明文 - textArea = new JTextArea(); - JScrollPane sc=new JScrollPane(textArea); - textArea.setFont(new Font(Font.MONOSPACED,Font.PLAIN,12)); - textArea.setTabSize(4); - this.getContentPane().add("Center", sc); - - try { - textArea.append("> java -jar AdjustTime.jar osm.jp.gpx.Restamp"); - for (String arg : args) { - textArea.append(" '" + arg + "'"); - } - textArea.append("\n\n"); - } - catch (Exception e) { - System.out.println(e.toString()); - } - - // JFrameの表示 - //parentFrame.setVisible(true); - } - - /** - * Shows or hides the component depending on the boolean flag b. - * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す. - * @see java.awt.Component#isVisible - */ - @Override - public void setVisible(boolean b) { - if(b) { - setLocation(80, 80); - } - super.setVisible(b); - } - - @Override - public void addNotify() { - // Record the size of the window prior to calling parents addNotify. - Dimension d = getSize(); - - super.addNotify(); - - if (fComponentsAdjusted) { - return; - } - - // Adjust components according to the insets - setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height); - Component components[] = getComponents(); - for (Component component : components) { - Point p = component.getLocation(); - p.translate(getInsets().left, getInsets().top); - component.setLocation(p); - } - fComponentsAdjusted = true; - } - - - /** - * JTextAreaに書き出すOutputStream - */ - public static class JTextAreaOutputStream extends OutputStream { - private final ByteArrayOutputStream os; - - /** 書き出し対象 */ - private final JTextArea textArea; - private final String encode; - - public JTextAreaOutputStream(JTextArea textArea, String encode) { - this.textArea = textArea; - this.encode = encode; - this.os = new ByteArrayOutputStream(); - } - - /** - * OutputStream#write(byte[])のオーバーライド - * @param arg - * @throws java.io.IOException - */ - @Override - public void write(int arg) throws IOException { - this.os.write(arg); - } - - /** - * flush()でJTextAreaに書き出す - * @throws java.io.IOException - */ - @Override - public void flush() throws IOException { - // 文字列のエンコード - final String str = new String(this.os.toByteArray(), this.encode); - // 実際の書き出し処理 - SwingUtilities.invokeLater( - new Runnable(){ - @Override - public void run() { - JTextAreaOutputStream.this.textArea.append(str); - } - } - ); - // 書き出した内容はクリアする - this.os.reset(); - } - } - - // 非同期に行う処理を記述するためのクラス - class LongTaskWorker extends SwingWorker { - private final JButton button; - - public LongTaskWorker(JButton button) { - this.button = button; - } - - // 非同期に行われる処理 - @Override - public Object doInBackground() { - // ながーい処理 - PrintStream defOut = System.out; - PrintStream defErr = System.err; - - OutputStream os = new JTextAreaOutputStream(textArea, "UTF-8"); - PrintStream stdout = new PrintStream(os, true); // 自動flushをtrueにしておく - - // System.out にJTextAreaOutputStreamに書き出すPrintStreamを設定 - System.setOut(stdout); - System.setErr(stdout); - - try { - Command command = new Command(osm.jp.gpx.Restamp.class); - command.setArgs(args); - command.start(); // コマンドを実行 - while (command.isAlive()) { - try { - Thread.sleep(10); - } catch (InterruptedException e) {} - } - } - catch(Exception e) { - e.printStackTrace(stdout); - } - finally { - System.setOut(defOut); - System.setErr(defErr); - done(); - } - - return null; - } - - // 非同期処理後に実行 - @Override - protected void done() { - // 処理が終了したので,文字列を元に戻し - // ボタンを使用可能にする - button.setText("実行"); - button.setEnabled(true); - } - } -} diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java b/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java deleted file mode 100644 index 110bfac..0000000 --- a/src/main/java/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java +++ /dev/null @@ -1,269 +0,0 @@ -package osm.jp.gpx.matchtime.gui.restamp; -import java.awt.*; -import java.io.IOException; -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import osm.jp.gpx.AppParameters; -import osm.jp.gpx.matchtime.gui.AdjustTerra; -import osm.jp.gpx.matchtime.gui.Card; -import osm.jp.gpx.matchtime.gui.ParameterPanelFolder; -import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; -import static osm.jp.gpx.matchtime.gui.AdjustTerra.i18n; -import osm.jp.gpx.matchtime.gui.ParameterPanelTime; -import osm.jp.gpx.matchtime.gui.SimpleDocumentListener; - -@SuppressWarnings("serial") -public class RestampDialog extends JDialog -{ - //{{DECLARE_CONTROLS - java.awt.Button closeButton; - JTabbedPane cardPanel; // ウィザード形式パネル(タブ型) - Card[] cards; - ParameterPanelFolder arg1_srcFolder; // 対象フォルダ - ParameterPanelImageFile arg2_baseTimeImg; // 開始画像ファイルパス - ParameterPanelTime arg2_basetime; // 開始画像の基準時刻: - ParameterPanelImageFile arg3_baseTimeImg; // 終了画像ファイルパス - ParameterPanelTime arg3_basetime; // 終了画像の基準時刻: - AppParameters params; - //}} - - class SymWindow extends java.awt.event.WindowAdapter - { - @Override - public void windowClosing(java.awt.event.WindowEvent event) { - Object object = event.getSource(); - if (object == RestampDialog.this) { - dispose(); - } - } - } - - class SymAction implements java.awt.event.ActionListener - { - @Override - public void actionPerformed(java.awt.event.ActionEvent event) { - Object object = event.getSource(); - if (object == closeButton) { - dispose(); - } - } - } - - 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 Card[4]; - 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) - ); - 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; - cardNo++; - } - - //--------------------------------------------------------------------- - // 2. [基準画像(開始)]選択パネル - { - // 基準時刻画像 - arg2_baseTimeImg = new ParameterPanelImageFile( - i18n.getString("label.210") +": ", - null, - arg1_srcFolder - ); - - // 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()); - } - } - ); - - CardImageFile card = new CardImageFile( - cardPanel, arg2_basetime, (Window)this, - AdjustTerra.i18n.getString("tab.restamp.200"), 0, 2); - cardPanel.addTab(card.getTitle(), card); - cardPanel.setEnabledAt(cardNo, false); - cards[cardNo] = card; - cardNo++; - } - - //--------------------------------------------------------------------- - // 3. 最終画像の本当の時刻を設定の入力画面 - { - // 基準時刻画像 - arg3_baseTimeImg = new ParameterPanelImageFile( - i18n.getString("label.210") +": ", - null, - arg1_srcFolder - ); - - // 3a. 基準時刻: - arg3_basetime = new ParameterPanelTime( - i18n.getString("label.310"), - null, - arg3_baseTimeImg - ); - arg3_basetime.argField.getDocument().addDocumentListener( - new SimpleDocumentListener() { - @Override - public void update(DocumentEvent e) { - toEnable(2, arg3_basetime.isEnable()); - } - } - ); - - CardImageFile card = new CardImageFile( - cardPanel, arg3_basetime, (Window)this, - AdjustTerra.i18n.getString("tab.restamp.250"), 1, 3 - ); - cardPanel.addTab(card.getTitle(), card); - cardPanel.setEnabledAt(cardNo, false); - cards[cardNo] = card; - cardNo++; - } - - //--------------------------------------------------------------------- - // 4. 実行画面 - { - CardPerformFile card = new CardPerformFile( - cardPanel, - arg2_basetime, - 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); - //}} - } - - - 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); - } - } - } - - public RestampDialog(Frame parent, String title, boolean modal) throws IOException { - this(parent, modal); - 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. - 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); - } -}