OSDN Git Service

実行時のメッセージもGUIパネルに表示した。
authorYu Hayashi <Yu.Hayashi@tecan.com>
Mon, 30 Jun 2014 12:30:05 +0000 (21:30 +0900)
committerYu Hayashi <Yu.Hayashi@tecan.com>
Mon, 30 Jun 2014 12:30:05 +0000 (21:30 +0900)
importPicture/.classpath
importPicture/MatchTime.bat
importPicture/MatchTime.sh [new file with mode: 0644]
importPicture/build.xml
importPicture/importPictute.bat [deleted file]
importPicture/importPictute.sh [deleted file]
importPicture/list.csv [new file with mode: 0644]
importPicture/src/osm/jp/gpx/ImportPicture.java
importPicture/src/osm/jp/gpx/matchtime/gui/Command.java [new file with mode: 0644]
importPicture/src/osm/jp/gpx/matchtime/gui/DoDialog.java [new file with mode: 0644]
importPicture/src/osm/jp/gpx/matchtime/gui/MatchTime.java

index 1687303..2061450 100644 (file)
@@ -2,6 +2,5 @@
 <classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="lib" path="C:/workspace/hayashi_0225.jar"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
index 89dee31..b68b169 100644 (file)
@@ -1,2 +1 @@
-java -cp ./importPicture.jar osm.jp.gpx.matchtime.gui.MatchTime
-pause
+javaw -jar MatchTime.jar
\ No newline at end of file
diff --git a/importPicture/MatchTime.sh b/importPicture/MatchTime.sh
new file mode 100644 (file)
index 0000000..59e8a00
--- /dev/null
@@ -0,0 +1 @@
+java -jar MatchTime.jar
index 27b3f7e..9a58d4f 100644 (file)
@@ -14,7 +14,7 @@
     <property name="src" value="${basedir}/src" />\r
     <property name="classes" value="${basedir}/classes" />\r
        <property name="deploy" value="${basedir}/deploy" />\r
-       <property name="appname" value="importPicture"></property>\r
+       <property name="appname" value="MatchTime"></property>\r
        <property name="version" value="${verdate}"></property>\r
 \r
 \r
@@ -69,7 +69,7 @@
                </tstamp>\r
                <jar destfile="${appname}.jar" >\r
                        <manifest>\r
-                         <attribute name="Main-Class" value="osm.jp.gpx.ImportPicture" />\r
+                         <attribute name="Main-Class" value="osm.jp.gpx.matchtime.gui.MatchTime" />\r
                          <attribute name="Class-Path" value="${jar.runtime.classpath}" />\r
                          <attribute name="Implementation-Title"   value="${appname}" />\r
                          <attribute name="Implementation-Version" value="${ts}" />\r
diff --git a/importPicture/importPictute.bat b/importPicture/importPictute.bat
deleted file mode 100644 (file)
index 4087038..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/2014-01-01 09.14.01 自動.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/2014-01-01 09.59.09 自動.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/2014-01-01 10.44.19 自動.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/2014-01-01 11.29.22 自動.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/2014-01-01 12.14.49 自動.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/20140101.gpx"
-java -jar importPicture.jar list.csv /home/hayashi/osm/20140101/10040101 DSC01396.JPG 2014-01-01T15:46:56  "/home/hayashi/osm/20140101/Current.gpx"
diff --git a/importPicture/importPictute.sh b/importPicture/importPictute.sh
deleted file mode 100755 (executable)
index 7306a8e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-java -jar importPicture.jar list.csv 10040101 DSC01396.JPG 2014-01-01T15:46:56
diff --git a/importPicture/list.csv b/importPicture/list.csv
new file mode 100644 (file)
index 0000000..230c703
--- /dev/null
@@ -0,0 +1,64 @@
+           \8e\9e\8d·\81F -324(sec)
+    Target GPX\81F [4-02-22 145413.gpx]
+GPX start time\81F 2014-02-22T13:16:11
+  GPX end time\81F 2014-02-22T14:54:21
+"name","orignal","gpstime"
+"IMG_0150.JPG","2014-02-22T13:30:20","2014-02-22T13:24:56"
+"IMG_0151.JPG","2014-02-22T13:38:04","2014-02-22T13:32:40"
+"IMG_0152.JPG","2014-02-22T13:39:06","2014-02-22T13:33:42"
+"IMG_0153.JPG","2014-02-22T13:39:12","2014-02-22T13:33:48"
+"IMG_0154.JPG","2014-02-22T13:39:16","2014-02-22T13:33:52"
+"IMG_0155.JPG","2014-02-22T13:40:16","2014-02-22T13:34:52"
+"IMG_0156.JPG","2014-02-22T13:40:44","2014-02-22T13:35:20"
+"IMG_0157.JPG","2014-02-22T13:41:46","2014-02-22T13:36:22"
+"IMG_0158.JPG","2014-02-22T13:42:32","2014-02-22T13:37:08"
+"IMG_0159.JPG","2014-02-22T13:46:20","2014-02-22T13:40:56"
+"IMG_0160.JPG","2014-02-22T13:47:06","2014-02-22T13:41:42"
+"IMG_0161.JPG","2014-02-22T13:47:12","2014-02-22T13:41:48"
+"IMG_0162.JPG","2014-02-22T13:47:40","2014-02-22T13:42:16"
+"IMG_0163.JPG","2014-02-22T13:48:56","2014-02-22T13:43:32"
+"IMG_0164.JPG","2014-02-22T13:49:24","2014-02-22T13:44:00"
+"IMG_0165.JPG","2014-02-22T13:49:34","2014-02-22T13:44:10"
+"IMG_0166.JPG","2014-02-22T13:51:02","2014-02-22T13:45:38"
+"IMG_0167.JPG","2014-02-22T13:51:44","2014-02-22T13:46:20"
+"IMG_0168.JPG","2014-02-22T13:53:56","2014-02-22T13:48:32"
+"IMG_0169.JPG","2014-02-22T13:54:06","2014-02-22T13:48:42"
+"IMG_0170.JPG","2014-02-22T13:54:40","2014-02-22T13:49:16"
+"IMG_0171.JPG","2014-02-22T14:03:34","2014-02-22T13:58:10"
+"IMG_0172.JPG","2014-02-22T14:03:38","2014-02-22T13:58:14"
+"IMG_0173.JPG","2014-02-22T14:04:24","2014-02-22T13:59:00"
+"IMG_0174.JPG","2014-02-22T14:04:44","2014-02-22T13:59:20"
+"IMG_0175.JPG","2014-02-22T14:04:58","2014-02-22T13:59:34"
+"IMG_0176.JPG","2014-02-22T14:05:10","2014-02-22T13:59:46"
+"IMG_0177.JPG","2014-02-22T14:06:04","2014-02-22T14:00:40"
+"IMG_0178.JPG","2014-02-22T14:08:12","2014-02-22T14:02:48"
+"IMG_0179.JPG","2014-02-22T14:08:24","2014-02-22T14:03:00"
+"IMG_0180.JPG","2014-02-22T14:08:30","2014-02-22T14:03:06"
+"IMG_0181.JPG","2014-02-22T14:08:46","2014-02-22T14:03:22"
+"IMG_0182.JPG","2014-02-22T14:09:02","2014-02-22T14:03:38"
+"IMG_0183.JPG","2014-02-22T14:09:10","2014-02-22T14:03:46"
+"IMG_0184.JPG","2014-02-22T14:10:14","2014-02-22T14:04:50"
+"IMG_0185.JPG","2014-02-22T14:11:34","2014-02-22T14:06:10"
+"IMG_0186.JPG","2014-02-22T14:11:54","2014-02-22T14:06:30"
+"IMG_0187.JPG","2014-02-22T14:14:24","2014-02-22T14:09:00"
+"IMG_0188.JPG","2014-02-22T14:15:02","2014-02-22T14:09:38"
+"IMG_0189.JPG","2014-02-22T14:15:12","2014-02-22T14:09:48"
+"IMG_0190.JPG","2014-02-22T14:15:16","2014-02-22T14:09:52"
+"IMG_0191.JPG","2014-02-22T14:16:02","2014-02-22T14:10:38"
+"IMG_0192.JPG","2014-02-22T14:18:46","2014-02-22T14:13:22"
+"IMG_0193.JPG","2014-02-22T14:28:04","2014-02-22T14:22:40"
+"IMG_0194.JPG","2014-02-22T14:28:30","2014-02-22T14:23:06"
+"IMG_0195.JPG","2014-02-22T14:30:56","2014-02-22T14:25:32"
+"IMG_0196.JPG","2014-02-22T14:31:00","2014-02-22T14:25:36"
+"IMG_0197.JPG","2014-02-22T14:31:44","2014-02-22T14:26:20"
+"IMG_0198.JPG","2014-02-22T14:32:12","2014-02-22T14:26:48"
+"IMG_0199.JPG","2014-02-22T14:32:20","2014-02-22T14:26:56"
+"IMG_0200.JPG","2014-02-22T14:32:32","2014-02-22T14:27:08"
+"IMG_0201.JPG","2014-02-22T14:34:54","2014-02-22T14:29:30"
+"IMG_0202.JPG","2014-02-22T14:35:12","2014-02-22T14:29:48"
+"IMG_0203.JPG","2014-02-22T14:35:28","2014-02-22T14:30:04"
+"IMG_0204.JPG","2014-02-22T14:35:44","2014-02-22T14:30:20"
+"IMG_0205.JPG","2014-02-22T14:37:18","2014-02-22T14:31:54"
+"IMG_0206.JPG","2014-02-22T14:37:32","2014-02-22T14:32:08"
+"IMG_0207.JPG","2014-02-22T14:41:18","2014-02-22T14:35:54"
+"IMG_0208.JPG","2014-02-22T14:42:42","2014-02-22T14:37:18"
index de2dbd2..64774b8 100644 (file)
@@ -86,6 +86,9 @@ public class ImportPicture {
         */\r
        public static void main(String[] argv) throws IOException\r
        {\r
+               Date jptime;\r
+               \r
+               \r
                File csvfile = new File("ImportPicture.csv");\r
                if (argv.length > 0) {\r
                        csvfile = new File(argv[0]);\r
@@ -99,6 +102,10 @@ public class ImportPicture {
                        System.out.println("> java -jar importPicture.jar <outputfile> <targetDir> <time base image> <time> (gpx)");\r
                        System.out.println("> java -jar importPicture.jar list.csv . IMG_01234.JPG 2012-06-15T12:52:22");\r
                }\r
+\r
+               // 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。\r
+               File baseFile = new File(gpxDir, argv[2]);\r
+               jptime = new Date(baseFile.lastModified());\r
                \r
                // 第5引数が指定されなければ、指定されたディレクトリ内のGPXファイルすべてを対象とする\r
                ArrayList<File> gpxFiles = new ArrayList<File>();\r
@@ -119,6 +126,7 @@ public class ImportPicture {
                        }\r
                }\r
 \r
+               \r
                /**\r
                 *\r
                        <wpt lat="35.25714922" lon="139.15490497">\r
@@ -185,8 +193,6 @@ public class ImportPicture {
 \r
                                if (trk != null) {\r
                                        HashMap<Long,Element> map = trkptMap(trk);\r
-                                       File baseFile = new File(gpxDir, argv[2]);\r
-                                       Date jptime = new Date(baseFile.lastModified());\r
 \r
                                        PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(csvfile)));\r
                                        String timeStr = argv[3];\r
diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java b/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java
new file mode 100644 (file)
index 0000000..04d67b1
--- /dev/null
@@ -0,0 +1,63 @@
+package osm.jp.gpx.matchtime.gui;
+import java.text.SimpleDateFormat;
+
+class Command extends Thread {
+       String[] args;          // コマンドパラメータ
+       private String commandName = "";        // コマンド名
+       @SuppressWarnings({ "rawtypes" })
+       private Class cmd;              // 実行対象インスタンス
+
+       /**
+        * コンストラクタ:実行対象のインスタンスを得る
+        * @param cmd
+        */
+       public Command(Class<?> cmd) {
+               super();
+               this.cmd = cmd;
+               this.commandName = cmd.getName();
+               this.args = new String[0];
+       }
+
+       /**
+        * コマンドパラメータの設定
+        * @param folder
+        */
+       public void setArgs(String[] args) {
+               this.args = args;
+       }
+
+       public void setCommandName(String name) {
+               this.commandName = name;
+       }
+       public String getCommandName() {
+               return this.commandName;
+       }
+
+       @SuppressWarnings("unchecked")
+       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 (Exception e) {
+                       System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName);
+                       throw e;
+               }
+        }
+        catch(Exception e) {
+            e.printStackTrace();
+        }
+               System.out.println();
+    }
+}
diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/DoDialog.java b/importPicture/src/osm/jp/gpx/matchtime/gui/DoDialog.java
new file mode 100644 (file)
index 0000000..5345249
--- /dev/null
@@ -0,0 +1,161 @@
+package osm.jp.gpx.matchtime.gui;
+import java.awt.*;
+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
+    JFrame parentFrame;        // MatchTime.class
+    JPanel buttonPanel;     // ボタン配置パネル        (下部)
+    JButton closeButton;      // [クローズ]ボタン
+    JButton doButton;      // [実行]ボタン
+    TextArea textArea;      // 実行結果を表示するJTextArea    (中央)
+    //}}
+
+    class SymAction implements java.awt.event.ActionListener {
+        public void actionPerformed(java.awt.event.ActionEvent event) {
+            Object object = event.getSource();
+            if (object == closeButton) {
+                closeButton_Action(event);
+            }
+            else if (object == doButton) {
+                doButton_Action(event);
+            }
+        }
+    }
+
+    public DoDialog(JFrame parentFrame, String[] args) {
+        super(parentFrame, true);   // モーダルダイアログを基盤にする
+        this.parentFrame = parentFrame;
+        this.args = args;
+                
+        // INIT_CONTROLS
+        Container container = getContentPane();
+        container.setLayout(new BorderLayout());
+        setVisible(false);
+        setSize(getInsets().left + getInsets().right + 500,getInsets().top + getInsets().bottom + 480);
+        setTitle(DoDialog.TITLE);
+        setSize(500,480);
+        
+        // コントロールパネル
+        buttonPanel = new JPanel();
+
+        doButton = new JButton("実行");
+        doButton.setToolTipText("処理を実行します.");
+        doButton.setEnabled(true);
+        buttonPanel.add(doButton);
+
+        closeButton = new JButton("閉じる");
+        closeButton.setToolTipText("処理を終了します.");
+        buttonPanel.add(closeButton);
+        
+        this.getContentPane().add("South", buttonPanel);
+        
+               // 説明文
+        textArea = new TextArea();
+        try {
+            textArea.append("> java -cp importPicture.jar osm.jp.gpx.ImportPicture");
+            for (int i = 0; i < args.length; i++) {
+               textArea.append(" '"+ args[i] +"'");
+            }
+            textArea.append("\n\n");
+        }
+        catch (Exception e) {
+            System.out.println(e.toString());
+        }
+        this.getContentPane().add("Center", textArea);
+
+        //{{REGISTER_LISTENERS
+        SymAction lSymAction = new SymAction();
+        closeButton.addActionListener(lSymAction);
+        doButton.addActionListener(lSymAction);
+        //}}
+    }
+
+    /**
+    * Shows or hides the component depending on the boolean flag b.
+    * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す.
+    * @see java.awt.Component#isVisible
+    */
+    public void setVisible(boolean b) {
+        if(b) {
+            setLocation(80, 80);
+        }
+        super.setVisible(b);
+    }
+
+    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 (int i = 0; i < components.length; i++)    {
+            Point p = components[i].getLocation();
+            p.translate(getInsets().left, getInsets().top);
+            components[i].setLocation(p);
+        }
+        fComponentsAdjusted = true;
+    }
+
+    /**
+     * [実行]ボタンをクリックしたときの動作
+     * @param event
+     */
+    void doButton_Action(java.awt.event.ActionEvent event) {
+        doButton.setEnabled(false);
+        
+        PrintStream defOut = System.out;
+        PrintStream defErr = System.err;
+
+       ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        try {
+               System.setOut(new PrintStream(stdout));
+               System.setErr(new PrintStream(stdout));
+
+               Command command = new Command(osm.jp.gpx.ImportPicture.class);
+               command.setArgs(args);
+               command.start();                // コマンドを実行
+               while (command.isAlive()) {
+                       Thread.sleep(1000);
+                textArea.append(stdout.toString());
+                stdout.reset();
+               }
+               textArea.append(stdout.toString());
+               JOptionPane.showMessageDialog(this, "'"+ TITLE +"'処理を完了しました。", "処理完了", JOptionPane.INFORMATION_MESSAGE);
+        }
+        catch(Exception e) {
+            e.printStackTrace();
+            JOptionPane.showMessageDialog(this, e.toString(), "Exception", JOptionPane.ERROR_MESSAGE);
+        }
+        finally {
+               System.setOut(defOut);
+               System.setErr(defErr);
+            doButton.setEnabled(true);
+        }
+    }
+
+    void closeButton_Action(java.awt.event.ActionEvent event) {
+        dispose();
+    }
+    
+    void changeSQL_Action(java.awt.event.ActionEvent event) {
+        textArea.setText("");
+    }
+}
index 4a94e05..30054f6 100644 (file)
@@ -2,12 +2,8 @@ package osm.jp.gpx.matchtime.gui;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.io.File;
-import java.io.IOException;
-
 import javax.swing.*;
 
-import osm.jp.gpx.ImportPicture;
-
 /**
  * 本プログラムのメインクラス
  */
@@ -25,6 +21,7 @@ public class MatchTime extends JFrame
     JPanel argsPanel;          // パラメータ設定パネル       (上部)
     JScrollPane imageSPane;    // スクロールパネル
     JLabel imageLabel;         // 基準時刻画像表示
+    JTextArea textArea;                // 実行結果表示領域
     //ImagePreview imagePane;  // 基準時刻画像表示
     ParameterPanelFolder arg1Panel_1;
     ParameterPanelImageFile arg1Panel_2;
@@ -85,17 +82,7 @@ public class MatchTime extends JFrame
                imageView_Action(event);
             }
             else if (object == arg1Panel_3.doButton) {
-                       String[] argv = new String[4];
-                       argv[0] = "list.csv";
-                       argv[1] = arg1Panel_1.getText();
-                       argv[2] = arg1Panel_2.getText();
-                       argv[3] = arg1Panel_3.getText();
-                       try {
-                                       ImportPicture.main(argv);
-                               }
-                       catch (IOException e) {
-                                       e.printStackTrace();
-                               }
+               doButton_Action(event);
             }
         }
     }
@@ -287,7 +274,7 @@ public class MatchTime extends JFrame
 
         //Set up the file chooser.
                File sdir = new File(arg1Panel_1.getText());
-               System.out.println(sdir.toPath());
+               System.out.println(sdir.getPath());
                if (sdir.isDirectory()) {
                fc = new JFileChooser(sdir);
                }
@@ -329,4 +316,22 @@ public class MatchTime extends JFrame
             return null;
         }
     }
+    
+    /**
+     * [実行]ボタンをクリックしたときの動作
+     * @param event
+     */
+    void doButton_Action(java.awt.event.ActionEvent event) {
+       arg1Panel_3.doButton.setEnabled(false);
+
+       String[] argv = new String[4];
+               argv[0] = "list.csv";
+               argv[1] = arg1Panel_1.getText();
+               argv[2] = arg1Panel_2.getText();
+               argv[3] = arg1Panel_3.getText();
+               (new DoDialog(this, argv)).setVisible(true);
+               
+       arg1Panel_3.doButton.setEnabled(true);
+    }
+
 }