ObjectToolBar.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.view.tdview;
18 
19 import java.awt.*;
20 import java.awt.event.*;
21 
22 import javax.swing.*;
23 
26 
27 
28 
33 @SuppressWarnings("serial")
34 public class ObjectToolBar extends JToolBar {
35  // 画面モード
36  public static final int DISABLE_MODE = 0;
37  public static final int OBJECT_MODE = 1;
38  public static final int FITTING_MODE = 2;
39  public static final int FROM_JOINT_MODE = 3;
40  public static final int INV_KINEMA_MODE = 4;
41  public static final int FITTING_START_MODE = 5;
42 
43  public int mode_;
44 
45  ActionListener listener_;
46 
47  //JButton addRobot_;
48  //JButton addEnv_;
49  //JButton remove_;
50  JToggleButton objTrans_;
51  JToggleButton objRot_;
52  JToggleButton joint_;
53  JToggleButton fitSrc_;
54  JToggleButton fitDist_;
55  JButton fit_;
56  JToggleButton fromJoint_;
57  JToggleButton invKinTrans_;
58  JToggleButton invKinRot_;
59 
60  PopButtonGroup group_;
61 
69  public ObjectToolBar() {
70  super(MessageBundle.get("tool.object.title"));
71  Dimension size =
72  new Dimension(IconProperties.WIDTH, IconProperties.HEIGHT);
73 
74  group_ = new PopButtonGroup();
75  group_.addActionListener(GUIAction.OPERATION_DISABLE = new GUIAction("operationDisable"));
76 
77  // ロボット追加
78  //addRobot_ = new JButton(GUIAction.ADD_ROBOT);
79  //addRobot_.setPreferredSize(size);
80  //addRobot_.setMaximumSize(size);
81  //addRobot_.setMinimumSize(size);
82 // add(addRobot_);
83 
84  // 環境追加
85  //addEnv_ = new JButton(GUIAction.ADD_ENV);
86  //addEnv_.setPreferredSize(size);
87  //addEnv_.setMaximumSize(size);
88  //addEnv_.setMinimumSize(size);
89 // add(addEnv_);
90 
91  // オブジェクト削除
92  //remove_ = new JButton(GUIAction.REMOVE_OBJECT);
93  //remove_.setPreferredSize(size);
94  //remove_.setMaximumSize(size);
95  //remove_.setMinimumSize(size);
96 // add(remove_);
97 
98  //addSeparator();
99 
100  // オブジェクト並進移動
101  objTrans_ = new JToggleButton(GUIAction.OBJECT_TRANSLATION = new GUIAction("objectTranslation"));
102  objTrans_.setActionCommand(GUIAction.OBJECT_TRANSLATION.getActionCommand());
103  objTrans_.setPreferredSize(size);
104  objTrans_.setMaximumSize(size);
105  objTrans_.setMinimumSize(size);
106  add(objTrans_);
107  group_.add(objTrans_);
108 
109  // オブジェクト回転移動
110  objRot_ = new JToggleButton(GUIAction.OBJECT_ROTATION = new GUIAction("objectRotation"));
111  objRot_.setPreferredSize(size);
112  objRot_.setMaximumSize(size);
113  objRot_.setMinimumSize(size);
114  add(objRot_);
115  group_.add(objRot_);
116 
117  // 関節角設定
118  joint_ = new JToggleButton(GUIAction.JOINT_ROTATION = new GUIAction("jointRotation"));
119  joint_.setPreferredSize(size);
120  joint_.setMaximumSize(size);
121  joint_.setMinimumSize(size);
122  add(joint_);
123  group_.add(joint_);
124 
125  addSeparator();
126 
127  // フィット元設定
128  fitSrc_ = new JToggleButton(GUIAction.FITTING_SRC = new GUIAction("fittingSrc"));
129  fitSrc_.setPreferredSize(size);
130  fitSrc_.setMaximumSize(size);
131  fitSrc_.setMinimumSize(size);
132  add(fitSrc_);
133  group_.add(fitSrc_);
134 
135  // フィット先設定
136  fitDist_ = new JToggleButton(GUIAction.FITTING_DEST = new GUIAction("fittingDest"));
137  fitDist_.setPreferredSize(size);
138  fitDist_.setMaximumSize(size);
139  fitDist_.setMinimumSize(size);
140  add(fitDist_);
141  group_.add(fitDist_);
142 
143  // フィット
144  fit_ = new JButton(GUIAction.DO_FIT = new GUIAction("doFit"));
145  fit_.setPreferredSize(size);
146  fit_.setMaximumSize(size);
147  fit_.setMinimumSize(size);
148  add(fit_);
149 
150  addSeparator();
151 
152  // 根元ジョイント設定
153  fromJoint_ = new JToggleButton(GUIAction.INV_KINEMA_FROM = new GUIAction("invKinemaFrom"));
154  fromJoint_.setPreferredSize(size);
155  fromJoint_.setMaximumSize(size);
156  fromJoint_.setMinimumSize(size);
157  add(fromJoint_);
158  group_.add(fromJoint_);
159 
160  // リンク回転移動
161  invKinRot_ = new JToggleButton(GUIAction.INV_KINEMA_ROT = new GUIAction("invKinemaRot"));
162  invKinRot_.setPreferredSize(size);
163  invKinRot_.setMaximumSize(size);
164  invKinRot_.setMinimumSize(size);
165  add(invKinRot_);
166  group_.add(invKinRot_);
167 
168  // リンク並進移動
169  invKinTrans_ = new JToggleButton(GUIAction.INV_KINEMA_TRANS = new GUIAction("invKinemaTrans"));
170  invKinTrans_.setPreferredSize(size);
171  invKinTrans_.setMaximumSize(size);
172  invKinTrans_.setMinimumSize(size);
173  add(invKinTrans_);
174  group_.add(invKinTrans_);
175 
176  //setMode(DISABLE_MODE);
177  selectNone();
178  }
179 
185  public void setMode(int mode) {
186  mode_ = mode;
187  switch (mode_) {
188  case DISABLE_MODE:
189  //addRobot_.setEnabled(false);
190  //addEnv_.setEnabled(false);
191  //remove_.setEnabled(false);
192  objTrans_.setEnabled(false);
193  objRot_.setEnabled(false);
194  joint_.setEnabled(false);
195  fitSrc_.setEnabled(false);
196  fitDist_.setEnabled(false);
197  fit_.setEnabled(false);
198  fromJoint_.setEnabled(false);
199  invKinTrans_.setEnabled(false);
200  invKinRot_.setEnabled(false);
201  break;
202  case OBJECT_MODE:
203  //addRobot_.setEnabled(true);
204  //addEnv_.setEnabled(true);
205  //remove_.setEnabled(true);
206  objTrans_.setEnabled(true);
207  objRot_.setEnabled(true);
208  joint_.setEnabled(true);
209  fitSrc_.setEnabled(true);
210  fitDist_.setEnabled(true);
211  fit_.setEnabled(false);
212  fromJoint_.setEnabled(true);
213  invKinTrans_.setEnabled(false);
214  invKinRot_.setEnabled(false);
215  break;
216  case FITTING_START_MODE:
217  fitSrc_.doClick();
218  case FITTING_MODE:
219  //addRobot_.setEnabled(false);
220  //addEnv_.setEnabled(false);
221  //remove_.setEnabled(false);
222  objTrans_.setEnabled(false);
223  objRot_.setEnabled(false);
224  joint_.setEnabled(false);
225  fitSrc_.setEnabled(true);
226  fitDist_.setEnabled(true);
227  fit_.setEnabled(true);
228  fromJoint_.setEnabled(false);
229  invKinTrans_.setEnabled(false);
230  invKinRot_.setEnabled(false);
231  break;
232  case FROM_JOINT_MODE:
233  //addRobot_.setEnabled(false);
234  //addEnv_.setEnabled(false);
235  //remove_.setEnabled(false);
236  objTrans_.setEnabled(false);
237  objRot_.setEnabled(false);
238  joint_.setEnabled(false);
239  fitSrc_.setEnabled(false);
240  fitDist_.setEnabled(false);
241  fit_.setEnabled(false);
242  fromJoint_.setEnabled(true);
243  invKinTrans_.setEnabled(false);
244  invKinRot_.setEnabled(false);
245  break;
246  case INV_KINEMA_MODE:
247  //addRobot_.setEnabled(false);
248  //addEnv_.setEnabled(false);
249  //remove_.setEnabled(false);
250  objTrans_.setEnabled(false);
251  objRot_.setEnabled(false);
252  joint_.setEnabled(false);
253  fitSrc_.setEnabled(false);
254  fitDist_.setEnabled(false);
255  fit_.setEnabled(false);
256  fromJoint_.setEnabled(true);
257  invKinTrans_.setEnabled(true);
258  invKinRot_.setEnabled(true);
259  break;
260  }
261  }
262 
263  public String getSelectedButton() {
264  ButtonModel model = group_.getSelection();
265  System.out.println("selectedButton=" + model.getActionCommand());
266  return model.getActionCommand();
267  }
268 
269  public void selectNone() {
270  group_.selectNone();
271  }
272 }
static final String get(String key)
png_uint_32 size
Definition: png.h:1521
void addActionListener(ActionListener listener)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:04