17 package com.generalrobotix.ui.view.tdview;
20 import java.awt.event.*;
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;
27 protected static final int ROTATION_MODE = 1;
28 protected static final int TRANSLATION_MODE = 2;
29 protected static final int ZOOM_MODE = 3;
31 protected int[] mode_;
32 protected Map<String, int[]> modeMap_;
35 modeMap_ =
new HashMap<String, int[]>();
39 new int[] { ROTATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
43 "button_mode_rotation",
44 new int[] { ROTATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
48 "button_mode_translation",
49 new int[] { TRANSLATION_MODE, ZOOM_MODE, TRANSLATION_MODE }
54 new int[] { ZOOM_MODE, ZOOM_MODE, TRANSLATION_MODE }
59 new int[] { ZOOM_MODE, ZOOM_MODE, ZOOM_MODE }
64 new int[] { TRANSLATION_MODE, TRANSLATION_MODE, TRANSLATION_MODE }
67 setMode(
"default_mode");
70 void setMode(String mode) {
71 mode_ = (
int[])modeMap_.get(mode);
74 protected int getMouseButtonMode(MouseEvent evt) {
90 if (evt.isMetaDown()) {
91 return MOUSE_BUTTON_RIGHT;
92 }
else if (evt.isAltDown()) {
93 return MOUSE_BUTTON_CENTER;
95 return MOUSE_BUTTON_LEFT;