~boginw/tapaal/multiplayer

« back to all changes in this revision

Viewing changes to src/pipe/gui/handler/TAPNTransitionHandler.java

  • Committer: Bogi Napoleon Wennerstrøm
  • Date: 2020-04-08 13:12:38 UTC
  • mfrom: (998.2.361 testbranch)
  • Revision ID: bogi.wennerstrom@gmail.com-20200408131238-6daa9ocph3zgx1ag
merged ~yrke changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package pipe.gui.handler;
2
 
 
3
 
import java.awt.Container;
4
 
import java.awt.event.MouseEvent;
5
 
import java.awt.event.MouseWheelEvent;
6
 
 
7
 
import javax.swing.JPopupMenu;
8
 
 
9
 
import pipe.dataLayer.DataLayer;
10
 
import pipe.gui.CreateGui;
11
 
import pipe.gui.DrawingSurfaceImpl;
12
 
import pipe.gui.graphicElements.Transition;
13
 
import dk.aau.cs.model.tapn.TimedArcPetriNet;
14
 
 
15
 
public class TAPNTransitionHandler extends TransitionHandler {
16
 
 
17
 
        public TAPNTransitionHandler(Transition obj) {
18
 
                super(obj);
19
 
        }
20
 
 
21
 
 
22
 
        // overwrite to remove shift behaviour
23
 
        @Override
24
 
        public void mouseWheelMoved(MouseWheelEvent e) {
25
 
 
26
 
                if (!(CreateGui.getApp().isEditionAllowed()) || e.isControlDown() || !(myObject.isSelected())) {
27
 
                        return;
28
 
                }
29
 
 
30
 
                int rotation = 0;
31
 
                if (e.getWheelRotation() < 0) {
32
 
                        rotation = -e.getWheelRotation() * 135;
33
 
                } else {
34
 
                        rotation = e.getWheelRotation() * 45;
35
 
                }
36
 
                CreateGui.getDrawingSurface().getUndoManager().addNewEdit(
37
 
                                ((Transition) myObject).rotate(rotation));
38
 
        }
39
 
 
40
 
        /**
41
 
         * Creates the popup menu that the user will see when they right click on a
42
 
         * component
43
 
         */
44
 
        @Override
45
 
        public JPopupMenu getPopup(MouseEvent e) {
46
 
                JPopupMenu popup = super.getPopup(e);
47
 
 
48
 
                return popup;
49
 
        }
50
 
 
51
 
}