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/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); - } - } -}