16 package com.generalrobotix.ui.view.tdview;
21 import org.eclipse.swt.widgets.Display;
28 import java.awt.event.*;
36 @SuppressWarnings(
"serial")
40 public static final int DISABLE_MODE = 0;
41 public static final int ROOM_MODE = 1;
42 public static final int WALK_MODE = 2;
43 public static final int PARALLEL_MODE = 3;
45 public static final String COMBO_SELECT_ROOM =
"Room";
46 public static final String COMBO_SELECT_WALK =
"Walk";
47 public static final String COMBO_SELECT_FRONT =
"Front";
48 public static final String COMBO_SELECT_BACK =
"Back";
49 public static final String COMBO_SELECT_LEFT =
"Left";
50 public static final String COMBO_SELECT_RIGHT =
"Right";
51 public static final String COMBO_SELECT_TOP =
"Top";
52 public static final String COMBO_SELECT_BOTTOM =
"Bottom";
53 public static final String[] VIEW_MODE = {COMBO_SELECT_ROOM, COMBO_SELECT_WALK, COMBO_SELECT_FRONT, COMBO_SELECT_BACK, COMBO_SELECT_LEFT,
54 COMBO_SELECT_RIGHT, COMBO_SELECT_TOP, COMBO_SELECT_BOTTOM};
56 public static final int PAN = 1;
57 public static final int ZOOM = 2;
58 public static final int ROTATE = 3;
66 protected JToggleButton
pan_;
85 group_ =
new ButtonGroup();
87 cmb_ =
new JComboBox();
89 cmb_.setLightWeightPopupEnabled(
false);
99 cmb_.setMinimumSize(cmb_.getPreferredSize());
100 cmb_.setMaximumSize(cmb_.getPreferredSize());
102 cmb_.addItemListener(
this);
108 rotate_.setPreferredSize(size);
109 rotate_.setMaximumSize(size);
110 rotate_.setMinimumSize(size);
117 zoom_.setPreferredSize(size);
118 zoom_.setMaximumSize(size);
119 zoom_.setMinimumSize(size);
125 pan_.setPreferredSize(size);
126 pan_.setMaximumSize(size);
127 pan_.setMinimumSize(size);
135 wireFrame_.setPreferredSize(size);
136 wireFrame_.setMaximumSize(size);
137 wireFrame_.setMinimumSize(size);
148 bgColor_.setPreferredSize(size);
149 bgColor_.setMaximumSize(size);
150 bgColor_.setMinimumSize(size);
156 capture_.setPreferredSize(size);
157 capture_.setMaximumSize(size);
158 capture_.setMinimumSize(size);
163 setOperation(ROTATE);
170 mode_ = DISABLE_MODE;
174 pan_.setEnabled(enabled);
175 zoom_.setEnabled(enabled);
176 rotate_.setEnabled(enabled);
177 wireFrame_.setEnabled(enabled);
184 cmb_.setEnabled(
false);
185 pan_.setEnabled(
false);
186 zoom_.setEnabled(
false);
187 rotate_.setEnabled(
false);
188 wireFrame_.setEnabled(
false);
192 cmb_.setEnabled(
true);
193 pan_.setEnabled(
true);
194 zoom_.setEnabled(
true);
195 rotate_.setEnabled(
true);
196 if (pan_.isSelected()){
199 wireFrame_.setEnabled(
true);
203 cmb_.setEnabled(
true);
204 pan_.setEnabled(
true);
205 zoom_.setEnabled(
true);
206 rotate_.setEnabled(
true);
207 wireFrame_.setEnabled(
true);
211 if (rotate_.isSelected()) {
214 cmb_.setEnabled(
true);
215 pan_.setEnabled(
true);
216 zoom_.setEnabled(
true);
217 rotate_.setEnabled(
false);
218 wireFrame_.setEnabled(
true);
232 pan_.setSelected(
true);
235 zoom_.setSelected(
true);
238 rotate_.setSelected(
true);
243 operation_ = operation;
249 cmb_.setSelectedIndex(index);
253 if (evt.getStateChange() == ItemEvent.SELECTED) {
254 Display display = Display.getDefault();
255 if (display !=
null && !display.isDisposed())
256 display.syncExec(
new Runnable(){
258 view_.
setProperty(
"view.mode", VIEW_MODE[cmb_.getSelectedIndex()]);
267 return wireFrame_.isSelected();
281 if (zoom_.isSelected()) {
282 selectedButton_ = zoom_;
283 }
else if (pan_.isSelected()) {
284 selectedButton_ = pan_;
285 }
else if (rotate_.isSelected()) {
286 selectedButton_ = rotate_;
289 if (evt.isMetaDown()) {
290 pan_.setSelected(
true);
291 }
else if (evt.isAltDown()) {
292 zoom_.setSelected(
true);
301 selectedButton_.setSelected(
true);
308 for(
int i=0;
i<VIEW_MODE.length;
i++)
309 if(VIEW_MODE[
i].equals(mode)){
310 cmb_.setSelectedIndex(
i);
315 int i = Integer.valueOf(mode.trim());
316 cmb_.setSelectedIndex(i);
318 }
catch(NumberFormatException e){
static final String get(String key)
static GUIAction BACK_VIEW
static GUIAction VIEW_PAN_MODE
#define null
our own NULL pointer
static GUIAction VIEW_ZOOM_MODE
static GUIAction WALK_VIEW
static GUIAction RIGHT_VIEW
static GUIAction TOP_VIEW
static GUIAction ROOM_VIEW
static GUIAction BOTTOM_VIEW
Object setProperty(String key, String value)
set property value associated with a keyword
static GUIAction VIEW_ROTATION_MODE
static GUIAction FRONT_VIEW
static GUIAction WIRE_FRAME
static GUIAction BG_COLOR
static ImageIcon get(String key)
static GUIAction LEFT_VIEW