ObjectToolBar.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00017 package com.generalrobotix.ui.view.tdview;
00018 
00019 import java.awt.*;
00020 import java.awt.event.*;
00021 
00022 import javax.swing.*;
00023 
00024 import com.generalrobotix.ui.util.IconProperties;
00025 import com.generalrobotix.ui.util.MessageBundle;
00026 
00027 
00028 
00033 @SuppressWarnings("serial")
00034 public class ObjectToolBar extends JToolBar {
00035     // 画面モード
00036     public static final int DISABLE_MODE    = 0;
00037     public static final int OBJECT_MODE     = 1;
00038     public static final int FITTING_MODE    = 2;
00039     public static final int FROM_JOINT_MODE = 3;
00040     public static final int INV_KINEMA_MODE = 4;
00041     public static final int FITTING_START_MODE    = 5;
00042 
00043     public int mode_;
00044 
00045     ActionListener listener_;
00046 
00047     //JButton addRobot_;
00048     //JButton addEnv_;
00049     //JButton remove_;
00050     JToggleButton objTrans_;
00051     JToggleButton objRot_;
00052     JToggleButton joint_;
00053     JToggleButton fitSrc_;
00054     JToggleButton fitDist_;
00055     JButton fit_;
00056     JToggleButton fromJoint_;
00057     JToggleButton invKinTrans_;
00058     JToggleButton invKinRot_;
00059 
00060     PopButtonGroup group_;
00061 
00069     public ObjectToolBar() {
00070         super(MessageBundle.get("tool.object.title"));
00071         Dimension size =
00072             new Dimension(IconProperties.WIDTH, IconProperties.HEIGHT);
00073 
00074         group_ = new PopButtonGroup();
00075         group_.addActionListener(GUIAction.OPERATION_DISABLE = new GUIAction("operationDisable"));
00076 
00077         // ロボット追加
00078         //addRobot_ = new JButton(GUIAction.ADD_ROBOT);
00079         //addRobot_.setPreferredSize(size);
00080         //addRobot_.setMaximumSize(size);
00081         //addRobot_.setMinimumSize(size);
00082 //        add(addRobot_);
00083 
00084         // 環境追加
00085         //addEnv_ = new JButton(GUIAction.ADD_ENV);
00086         //addEnv_.setPreferredSize(size);
00087         //addEnv_.setMaximumSize(size);
00088         //addEnv_.setMinimumSize(size);
00089 //        add(addEnv_);
00090 
00091         // オブジェクト削除
00092         //remove_ = new JButton(GUIAction.REMOVE_OBJECT);
00093         //remove_.setPreferredSize(size);
00094         //remove_.setMaximumSize(size);
00095         //remove_.setMinimumSize(size);
00096 //        add(remove_);
00097 
00098         //addSeparator();
00099 
00100         // オブジェクト並進移動
00101         objTrans_ = new JToggleButton(GUIAction.OBJECT_TRANSLATION = new GUIAction("objectTranslation"));
00102         objTrans_.setActionCommand(GUIAction.OBJECT_TRANSLATION.getActionCommand());
00103         objTrans_.setPreferredSize(size);
00104         objTrans_.setMaximumSize(size);
00105         objTrans_.setMinimumSize(size);
00106         add(objTrans_);
00107         group_.add(objTrans_);
00108 
00109         // オブジェクト回転移動
00110         objRot_ = new JToggleButton(GUIAction.OBJECT_ROTATION = new GUIAction("objectRotation"));
00111         objRot_.setPreferredSize(size);
00112         objRot_.setMaximumSize(size);
00113         objRot_.setMinimumSize(size);
00114         add(objRot_);
00115         group_.add(objRot_);
00116 
00117         // 関節角設定
00118         joint_ = new JToggleButton(GUIAction.JOINT_ROTATION = new GUIAction("jointRotation"));
00119         joint_.setPreferredSize(size);
00120         joint_.setMaximumSize(size);
00121         joint_.setMinimumSize(size);
00122         add(joint_);
00123         group_.add(joint_);
00124 
00125         addSeparator();
00126 
00127         // フィット元設定
00128         fitSrc_ = new JToggleButton(GUIAction.FITTING_SRC = new GUIAction("fittingSrc"));
00129         fitSrc_.setPreferredSize(size);
00130         fitSrc_.setMaximumSize(size);
00131         fitSrc_.setMinimumSize(size);
00132         add(fitSrc_);
00133         group_.add(fitSrc_);
00134 
00135         // フィット先設定
00136         fitDist_ = new JToggleButton(GUIAction.FITTING_DEST = new GUIAction("fittingDest"));
00137         fitDist_.setPreferredSize(size);
00138         fitDist_.setMaximumSize(size);
00139         fitDist_.setMinimumSize(size);
00140         add(fitDist_);
00141         group_.add(fitDist_);
00142 
00143         // フィット
00144         fit_ = new JButton(GUIAction.DO_FIT = new GUIAction("doFit"));
00145         fit_.setPreferredSize(size);
00146         fit_.setMaximumSize(size);
00147         fit_.setMinimumSize(size);
00148         add(fit_);
00149 
00150         addSeparator();
00151 
00152         // 根元ジョイント設定
00153         fromJoint_ = new JToggleButton(GUIAction.INV_KINEMA_FROM = new GUIAction("invKinemaFrom"));
00154         fromJoint_.setPreferredSize(size);
00155         fromJoint_.setMaximumSize(size);
00156         fromJoint_.setMinimumSize(size);
00157         add(fromJoint_);
00158         group_.add(fromJoint_);
00159 
00160         // リンク回転移動
00161         invKinRot_ = new JToggleButton(GUIAction.INV_KINEMA_ROT = new GUIAction("invKinemaRot"));
00162         invKinRot_.setPreferredSize(size);
00163         invKinRot_.setMaximumSize(size);
00164         invKinRot_.setMinimumSize(size);
00165         add(invKinRot_);
00166         group_.add(invKinRot_);
00167 
00168         // リンク並進移動
00169         invKinTrans_ = new JToggleButton(GUIAction.INV_KINEMA_TRANS = new GUIAction("invKinemaTrans"));
00170         invKinTrans_.setPreferredSize(size);
00171         invKinTrans_.setMaximumSize(size);
00172         invKinTrans_.setMinimumSize(size);
00173         add(invKinTrans_);
00174         group_.add(invKinTrans_);
00175 
00176         //setMode(DISABLE_MODE);
00177         selectNone();
00178     }
00179 
00185     public void setMode(int mode) {
00186         mode_ = mode;
00187         switch (mode_) {
00188         case DISABLE_MODE:
00189             //addRobot_.setEnabled(false);
00190             //addEnv_.setEnabled(false);
00191             //remove_.setEnabled(false);
00192             objTrans_.setEnabled(false);
00193             objRot_.setEnabled(false);
00194             joint_.setEnabled(false);
00195             fitSrc_.setEnabled(false);
00196             fitDist_.setEnabled(false);
00197             fit_.setEnabled(false);
00198             fromJoint_.setEnabled(false);
00199             invKinTrans_.setEnabled(false);
00200             invKinRot_.setEnabled(false);
00201             break;
00202         case OBJECT_MODE:
00203             //addRobot_.setEnabled(true);
00204             //addEnv_.setEnabled(true);
00205             //remove_.setEnabled(true);
00206             objTrans_.setEnabled(true);
00207             objRot_.setEnabled(true);
00208             joint_.setEnabled(true);
00209             fitSrc_.setEnabled(true);
00210             fitDist_.setEnabled(true);
00211             fit_.setEnabled(false);
00212             fromJoint_.setEnabled(true);
00213             invKinTrans_.setEnabled(false);
00214             invKinRot_.setEnabled(false);
00215             break;
00216         case FITTING_START_MODE:
00217                 fitSrc_.doClick();
00218         case FITTING_MODE:
00219             //addRobot_.setEnabled(false);
00220             //addEnv_.setEnabled(false);
00221             //remove_.setEnabled(false);
00222             objTrans_.setEnabled(false);
00223             objRot_.setEnabled(false);
00224             joint_.setEnabled(false);
00225             fitSrc_.setEnabled(true);
00226             fitDist_.setEnabled(true);
00227             fit_.setEnabled(true);
00228             fromJoint_.setEnabled(false);
00229             invKinTrans_.setEnabled(false);
00230             invKinRot_.setEnabled(false);
00231             break;
00232         case FROM_JOINT_MODE:
00233             //addRobot_.setEnabled(false);
00234             //addEnv_.setEnabled(false);
00235             //remove_.setEnabled(false);
00236             objTrans_.setEnabled(false);
00237             objRot_.setEnabled(false);
00238             joint_.setEnabled(false);
00239             fitSrc_.setEnabled(false);
00240             fitDist_.setEnabled(false);
00241             fit_.setEnabled(false);
00242             fromJoint_.setEnabled(true);
00243             invKinTrans_.setEnabled(false);
00244             invKinRot_.setEnabled(false);
00245             break;
00246         case INV_KINEMA_MODE:
00247             //addRobot_.setEnabled(false);
00248             //addEnv_.setEnabled(false);
00249             //remove_.setEnabled(false);
00250             objTrans_.setEnabled(false);
00251             objRot_.setEnabled(false);
00252             joint_.setEnabled(false);
00253             fitSrc_.setEnabled(false);
00254             fitDist_.setEnabled(false);
00255             fit_.setEnabled(false);
00256             fromJoint_.setEnabled(true);
00257             invKinTrans_.setEnabled(true);
00258             invKinRot_.setEnabled(true);
00259             break;
00260         }
00261     }
00262 
00263     public String getSelectedButton() {
00264          ButtonModel model = group_.getSelection();
00265          System.out.println("selectedButton=" + model.getActionCommand());
00266          return model.getActionCommand();
00267     }
00268 
00269     public void selectNone() {
00270         group_.selectNone();
00271     }
00272 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55