Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
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
00048
00049
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
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
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
00177 selectNone();
00178 }
00179
00185 public void setMode(int mode) {
00186 mode_ = mode;
00187 switch (mode_) {
00188 case DISABLE_MODE:
00189
00190
00191
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
00204
00205
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
00220
00221
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
00234
00235
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
00248
00249
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 }