Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15042
Modified Files:
ToolFactory.java
Log Message:
added new way of choosing movement mode
Index: ToolFactory.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** ToolFactory.java 3 Feb 2006 14:53:19 -0000 1.29
--- ToolFactory.java 9 Feb 2006 15:02:22 -0000 1.30
***************
*** 16,21 ****
--- 16,27 ----
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
+ import java.awt.event.MouseAdapter;
+ import java.awt.event.MouseEvent;
+ import java.awt.event.ActionListener;
+ import javax.swing.JPopupMenu;
+ import javax.swing.JMenuItem;
import javax.swing.AbstractAction;
import javax.swing.Action;
+
import javax.swing.ImageIcon;
import javax.swing.JToggleButton;
***************
*** 148,151 ****
--- 154,158 ----
bg.add(moveBut);
moveBut.setToolTipText("Move");
+ moveBut.addMouseListener(new MoveButtonMouseListener(moveBut));
rotBut = tb.registerAction(new RotationAction(glv));
bg.add(rotBut);
***************
*** 586,588 ****
--- 593,654 ----
}
}
+
+ /**
+ * The listener for the move button
+ */
+ class MoveButtonMouseListener extends MouseAdapter {
+ /**
+ * The button
+ */
+ private JToggleButton button;
+
+ /**
+ * Constructs the listener.
+ * @param button the button to listen on
+ */
+ public MoveButtonMouseListener(JToggleButton button) {
+ super();
+ this.button = button;
+ }
+ /**
+ * Invoked when the mouse is pressed
+ * @param e the mouse event
+ */
+ public void mousePressed(MouseEvent e) {
+ if (e.getButton() == e.BUTTON3) {
+ JPopupMenu pm = new JPopupMenu();
+ MovePopupActionListener mpal = new MovePopupActionListener();
+ JMenuItem mi = new JMenuItem("Axis restricted");
+ mi.addActionListener(mpal);
+ pm.add(mi);
+ mi = new JMenuItem("Free plane");
+ mi.addActionListener(mpal);
+ pm.add(mi);
+ mi = new JMenuItem("Vector");
+ mi.addActionListener(mpal);
+ pm.add(mi);
+ pm.show(button, 0, button.getHeight());
+ }
+ }
+
+ /**
+ listener
+ */
+ class MovePopupActionListener implements ActionListener {
+ /**
+ * invoked when action performed
+ * @param actionEvent the event.
+ */
+ public void actionPerformed(ActionEvent actionEvent) {
+ if (actionEvent.getActionCommand().equals("Vector")) {
+ move.setMoveMode(move.THREE_CLICK);
+ } else if (actionEvent.getActionCommand().equals("Axis restricted")) {
+ move.setMoveMode(move.AXIS_RESTRICTED);
+ } else if (actionEvent.getActionCommand().equals("Free plane")) {
+ move.setMoveMode(move.FREE_SNAP);
+ }
+ }
+ }
+ }
}
+
|