~tapaal-contributor/tapaal/update-zoom-percentage-on-ctrl+scroll-1785023

« back to all changes in this revision

Viewing changes to src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java

Merged bzr merge lp:~yrke/tapaal/placetransitionobjecthandler-refactor with cleanup 
and refactorings of elements and handlers

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                listener = timedTransitionListener();
52
52
                transition.addTimedTransitionListener(listener);
53
53
                attributesVisible = true;
 
54
 
 
55
                //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when
 
56
                //XXX: handler is called. Make static constructor and add handler from there, to make it safe.
 
57
                addMouseHandler();
54
58
        }
55
59
 
56
60
        public TimedTransitionComponent(double positionXInput,
57
 
                        double positionYInput, String idInput, String nameInput,
 
61
                        double positionYInput, String idInput,
58
62
                        double nameOffsetXInput, double nameOffsetYInput,
59
63
                        boolean timedTransition, boolean infServer, int angleInput,
60
64
                        int priority) {
61
 
                super(positionXInput, positionYInput, idInput, nameInput,
 
65
                super(positionXInput, positionYInput, idInput,
62
66
                                nameOffsetXInput, nameOffsetYInput, infServer,
63
67
                                angleInput, priority);
64
68
                listener = timedTransitionListener();
65
69
                attributesVisible = true;
 
70
 
 
71
                //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when
 
72
                //XXX: handler is called. Make static constructor and add handler from there, to make it safe.
 
73
                addMouseHandler();
 
74
        }
 
75
 
 
76
 
 
77
        private void addMouseHandler() {
 
78
                //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when
 
79
                //XXX: handler is called. Make static constructor and add handler from there, to make it safe.
 
80
                mouseHandler = new TAPNTransitionHandler(this);
 
81
                addMouseListener(new AnimationHandler());
66
82
        }
67
83
 
68
84
        private TimedTransitionListener timedTransitionListener(){
210
226
        }
211
227
 
212
228
        public TimedTransitionComponent copy(TimedArcPetriNet tapn, DataLayer guiModel) {
213
 
                TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getPositionXObject(), getPositionYObject(), id, transition.name(), nameOffsetX, nameOffsetY, true, false, getAngle(), 0);
 
229
                TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getPositionXObject(), getPositionYObject(), id, nameOffsetX, nameOffsetY, true, false, getAngle(), 0);
214
230
                transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name()));
215
 
 
216
 
                LabelHandler labelHandler = new LabelHandler(transitionComponent.getNameLabel(), transitionComponent);
217
 
                transitionComponent.getNameLabel().addMouseListener(labelHandler);
218
 
                transitionComponent.getNameLabel().addMouseMotionListener(labelHandler);
219
 
                transitionComponent.getNameLabel().addMouseWheelListener(labelHandler);
220
 
 
221
 
                TransitionHandler transitionHandler = new TAPNTransitionHandler((DrawingSurfaceImpl)getParent(), transitionComponent, guiModel, tapn);
222
 
                transitionComponent.addMouseListener(transitionHandler);
223
 
                transitionComponent.addMouseMotionListener(transitionHandler);
224
 
                transitionComponent.addMouseWheelListener(transitionHandler);
225
 
 
226
 
                transitionComponent.addMouseListener(new AnimationHandler());
227
 
 
 
231
                
228
232
                transitionComponent.setGuiModel(guiModel);
229
233
 
230
234
                return transitionComponent;