OSDN Git Service

ウィザード風のUIに改造
authorhayashi yuu <hayashi.yuu@gmail.com>
Mon, 10 Aug 2015 05:04:45 +0000 (14:04 +0900)
committerhayashi yuu <hayashi.yuu@gmail.com>
Mon, 10 Aug 2015 05:04:45 +0000 (14:04 +0900)
importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java

index 8ca1df5..afc5257 100644 (file)
@@ -20,6 +20,9 @@ public class AdjustTime extends JFrame
     boolean fComponentsAdjusted = false;
     
     //{{DECLARE_CONTROLS
+    JPanel cardPanel;       // ウィザード形式パネル(カード型)
+    JPanel[] cards;
+    int cardPanelNo = 0;
     JPanel argsPanel;          // パラメータ設定パネル       (上部)
     JScrollPane imageSPane;    // スクロールパネル
     JLabel imageLabel;         // 基準時刻画像表示
@@ -29,11 +32,14 @@ public class AdjustTime extends JFrame
     ParameterPanelImageFile arg1Panel_2;
     ParameterPanelTime arg1Panel_3;
     ParameterPanelSelecter arg1Panel_4;                // EXIF 書き出しモード
+    ParameterPanelFolder arg1Panel_5;       // GPXファイル・フォルダ
     
     JPanel buttonPanel;                // ボタンパネル   (下部)
     JButton openButton;                // [Fit]ボタン
     JButton zoomInButton;      // [Zoom in]ボタン
     JButton zoomOutButton;     // [Zoom out]ボタン
+    JButton nextButton;     // [次へ]ボタン
+    JButton backButton;     // [戻る]ボタン
     //}}
 
     //{{DECLARE_MENUS
@@ -50,7 +56,7 @@ public class AdjustTime extends JFrame
     class SymWindow extends java.awt.event.WindowAdapter {
         /**
          * このFrameが閉じられるときの動作。
-         * 終了確認のパネルを表示して、[OK]が押されたら終了する
+         * このパネルが閉じられたら、このアプリケーションも終了させる。
          */
         @Override
         public void windowClosing(java.awt.event.WindowEvent event) {
@@ -93,6 +99,12 @@ public class AdjustTime extends JFrame
             else if (object == arg1Panel_4.field) {
                doButton_Action(event);
             }
+            else if (object == nextButton) {
+               nextButton_Action(event);
+            }
+            else if (object == backButton) {
+               backButton_Action(event);
+            }
         }
     }
 
@@ -102,34 +114,52 @@ public class AdjustTime extends JFrame
     public AdjustTime()
     {
         // INIT_CONTROLS
-        //setLayout(new BorderLayout());
         Container container = getContentPane();
         container.setLayout(new BorderLayout());
-        setVisible(false);
-        setSize(getInsets().left + getInsets().right + 500,getInsets().top + getInsets().bottom + 480);
+        setSize(getInsets().left + getInsets().right + 960,getInsets().top + getInsets().bottom + 480);
         setTitle(AdjustTime.PROGRAM_NAME +" v"+ AdjustTime.PROGRAM_VARSION);
         
+        //---------------------------------------------------------------------
+        cardPanel = new JPanel();
+        cardPanel.setLayout(new CardLayout());
+        container.add(cardPanel, BorderLayout.CENTER);
+        
+        nextButton = new JButton("次へ");
+        container.add(nextButton, BorderLayout.EAST);
+
+        backButton = new JButton("戻る");
+        container.add(backButton, BorderLayout.WEST);
+
+        cards = new JPanel[4];
+        for (int i=0; i < 4; i++) {
+            cards[i] = new JPanel();
+            cardPanel.add(cards[i], String.valueOf(i));
+        }
+        cardPanelNo = 0;
+
+        //---------------------------------------------------------------------
         // パラメータ設定パネル
+        int cardNo = 0;
+        cards[cardNo].setLayout(new BorderLayout());
         argsPanel = new JPanel();
         argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
         arg1Panel_1 = new ParameterPanelFolder("対象フォルダ: ", ".");
         argsPanel.add(arg1Panel_1);
         arg1Panel_2 = new ParameterPanelImageFile("基準時刻画像: ", "", arg1Panel_1);
         argsPanel.add(arg1Panel_2);
-        arg1Panel_3 = new ParameterPanelTime("  基準時刻: ", ImportPicture.TIME_FORMAT_STRING);
-        argsPanel.add(arg1Panel_3);
-        
-        String[] combodata = {"更新しない", "更新する"};
-        arg1Panel_4 = new ParameterPanelSelecter("EXIF変更: ", combodata);
-        argsPanel.add(arg1Panel_4);
-        
-        this.getContentPane().add(argsPanel, BorderLayout.NORTH);
+        cards[cardNo].add(argsPanel, BorderLayout.NORTH);
         
+        //---------------------------------------------------------------------
         // 基準時刻画像表示
+        cardNo++;
+        cards[cardNo].setLayout(new BorderLayout());
+        arg1Panel_3 = new ParameterPanelTime("  基準時刻: ", ImportPicture.TIME_FORMAT_STRING);
+        cards[cardNo].add(arg1Panel_3, BorderLayout.NORTH);
+
         imageLabel = new JLabel();
         imageSPane = new JScrollPane(imageLabel);
-        this.getContentPane().add(imageSPane, BorderLayout.CENTER);
-        
+        cards[cardNo].add(imageSPane, BorderLayout.CENTER);
+              
         // 画像ファイル選択ダイアログを起動するボタン
         buttonPanel = new JPanel();
         buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
@@ -139,8 +169,29 @@ public class AdjustTime extends JFrame
         buttonPanel.add(zoomInButton);
         zoomOutButton = new JButton(createImageIcon("images/ZoomOut16.gif"));
         buttonPanel.add(zoomOutButton);
-        this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
+        cards[cardNo].add(buttonPanel, BorderLayout.SOUTH);
         
+        //---------------------------------------------------------------------
+        // GPXファイル設定画面
+        cardNo++;
+        cards[cardNo].setLayout(new BorderLayout());
+        //JPanel tmpPanel = new JPanel();
+        //tmpPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
+        File gpxDir = new File(".");
+        arg1Panel_5 = new ParameterPanelFolder("GPXフォルダ: ", gpxDir.getAbsolutePath());
+        cards[cardNo].add(arg1Panel_5, BorderLayout.NORTH);
+        
+        //---------------------------------------------------------------------
+        // EXIF更新設定画面
+        cardNo++;
+        cards[cardNo].setLayout(new BorderLayout());
+        //JPanel tmpPanel = new JPanel();
+        //tmpPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
+        String[] combodata = {"更新しない", "更新する"};
+        arg1Panel_4 = new ParameterPanelSelecter("EXIF変更: ", combodata);
+        cards[cardNo].add(arg1Panel_4, BorderLayout.CENTER);
+
+        //---------------------------------------------------------------------
         // INIT_MENUS
         menu1 = new java.awt.Menu("File");
         miExit = new java.awt.MenuItem(QuitDialog.TITLE);
@@ -174,6 +225,8 @@ public class AdjustTime extends JFrame
         arg1Panel_2.openButton.addActionListener(lSymAction);
         arg1Panel_3.doButton.addActionListener(lSymAction);
         arg1Panel_4.field.addActionListener(lSymAction);
+        nextButton.addActionListener(lSymAction);
+        backButton.addActionListener(lSymAction);
         //}}
     }
     
@@ -186,7 +239,6 @@ public class AdjustTime extends JFrame
     public void setVisible(boolean b) {
         if(b) {
             setLocation(50, 50);
-            
         }
         super.setVisible(b);
     }
@@ -260,10 +312,8 @@ public class AdjustTime extends JFrame
        int size_x = imageSPane.getWidth() - 8;
        ImageIcon tmpIcon = new ImageIcon(path);
        refImage = tmpIcon;
-        if (tmpIcon != null) {
-            if (tmpIcon.getIconWidth() > size_x) {
-               refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x, -1, Image.SCALE_DEFAULT));
-            }
+        if (tmpIcon.getIconWidth() > size_x) {
+            refImage = new ImageIcon(tmpIcon.getImage().getScaledInstance(size_x, -1, Image.SCALE_DEFAULT));
         }
        imageLabel.setIcon(refImage);
         repaint();
@@ -358,5 +408,28 @@ public class AdjustTime extends JFrame
                
        arg1Panel_3.doButton.setEnabled(true);
     }
+    
+    /**
+     * [次へ]ボタンをクリックした時の動作
+     * @param event 
+     */
+    void nextButton_Action(ActionEvent event) {
+        if ((cardPanelNo + 1) < cards.length) {
+            cardPanelNo++;
+            CardLayout cl = (CardLayout)(cardPanel.getLayout());
+            cl.show(cardPanel, String.valueOf(cardPanelNo));
+        }
+    }
 
+    /**
+     * [戻る]ボタンをクリックした時の動作
+     * @param event
+     */
+    void backButton_Action(ActionEvent event) {
+        if ((cardPanelNo - 1) >= 0) {
+            cardPanelNo--;
+            CardLayout cl = (CardLayout)(cardPanel.getLayout());
+            cl.show(cardPanel, String.valueOf(cardPanelNo));
+        }
+    }
 }