ViewHandler.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.util.*;
20 import java.awt.event.*;
21 
22 abstract class ViewHandler implements BehaviorHandler {
23  protected static final int MOUSE_BUTTON_LEFT = 0;
24  protected static final int MOUSE_BUTTON_CENTER = 1;
25  protected static final int MOUSE_BUTTON_RIGHT = 2;
26 
27  protected static final int ROTATION_MODE = 1;
28  protected static final int TRANSLATION_MODE = 2;
29  protected static final int ZOOM_MODE = 3;
30 
31  protected int[] mode_;
32  protected Map<String, int[]> modeMap_;
33 
34  ViewHandler() {
35  modeMap_ = new HashMap<String, int[]>();
36 
37  modeMap_.put(
38  "default_mode",
39  new int[] { ROTATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
40  );
41 
42  modeMap_.put(
43  "button_mode_rotation",
44  new int[] { ROTATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
45  );
46 
47  modeMap_.put(
48  "button_mode_translation",
49  new int[] { TRANSLATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
50  );
51 
52  modeMap_.put(
53  "button_mode_zoom",
54  new int[] { ZOOM_MODE, ZOOM_MODE, TRANSLATION_MODE }
55  );
56 
57  modeMap_.put(
58  "ctrl_pressed",
59  new int[] { ZOOM_MODE, ZOOM_MODE, ZOOM_MODE }
60  );
61 
62  modeMap_.put(
63  "alt_pressed",
64  new int[] { TRANSLATION_MODE, TRANSLATION_MODE, TRANSLATION_MODE }
65  );
66 
67  setMode("default_mode");
68  }
69 
70  void setMode(String mode) {
71  mode_ = (int[])modeMap_.get(mode);
72  }
73 
74  protected int getMouseButtonMode(MouseEvent evt) {
75  // マウスイベントからマウスボタンの識別子に変換。
76 /*
77  switch (evt.getModifiers()) {
78  case MouseEvent.BUTTON1_MASK:
79  return MOUSE_BUTTON_LEFT;
80  case MouseEvent.BUTTON2_MASK:
81  return MOUSE_BUTTON_CENTER;
82  case MouseEvent.BUTTON3_MASK:
83  return MOUSE_BUTTON_RIGHT;
84  default:
85  return 3;
86  //return MOUSE_BUTTON_RIGHT;
87  }
88 */
89 
90  if (evt.isMetaDown()) {
91  return MOUSE_BUTTON_RIGHT;
92  } else if (evt.isAltDown()) {
93  return MOUSE_BUTTON_CENTER;
94  } else {
95  return MOUSE_BUTTON_LEFT;
96  }
97  }
98 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:41