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

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/io/TapnXmlLoader.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:
29
29
import pipe.gui.Zoomer;
30
30
import pipe.gui.graphicElements.AnnotationNote;
31
31
import pipe.gui.graphicElements.Arc;
32
 
import pipe.gui.graphicElements.Note;
33
32
import pipe.gui.graphicElements.PetriNetObject;
34
33
import pipe.gui.graphicElements.Place;
35
34
import pipe.gui.graphicElements.PlaceTransitionObject;
36
 
import pipe.gui.graphicElements.Transition;
37
35
import pipe.gui.graphicElements.tapn.TimedInhibitorArcComponent;
38
36
import pipe.gui.graphicElements.tapn.TimedInputArcComponent;
39
37
import pipe.gui.graphicElements.tapn.TimedOutputArcComponent;
40
38
import pipe.gui.graphicElements.tapn.TimedPlaceComponent;
41
39
import pipe.gui.graphicElements.tapn.TimedTransitionComponent;
42
40
import pipe.gui.graphicElements.tapn.TimedTransportArcComponent;
43
 
import pipe.gui.handler.AnimationHandler;
44
 
import pipe.gui.handler.AnnotationNoteHandler;
45
 
import pipe.gui.handler.ArcHandler;
46
 
import pipe.gui.handler.LabelHandler;
47
 
import pipe.gui.handler.PlaceHandler;
48
 
import pipe.gui.handler.TAPNTransitionHandler;
49
 
import pipe.gui.handler.TimedArcHandler;
50
 
import pipe.gui.handler.TransitionHandler;
51
 
import pipe.gui.handler.TransportArcHandler;
52
41
import dk.aau.cs.gui.NameGenerator;
53
42
import dk.aau.cs.io.queries.TAPNQueryLoader;
54
43
import dk.aau.cs.model.tapn.Constant;
405
394
                }
406
395
                nameGenerator.updateIndicesForAllModels(nameInput);
407
396
                TimedTransitionComponent transitionComponent = new TimedTransitionComponent(
408
 
                                positionXInput, positionYInput, idInput, nameInput,
 
397
                                positionXInput, positionYInput, idInput,
409
398
                                nameOffsetXInput, nameOffsetYInput, true,
410
399
                                infiniteServer, angle, priority);
411
400
                transitionComponent.setUnderlyingTransition(t);
462
451
                        }
463
452
                }
464
453
                nameGenerator.updateIndicesForAllModels(nameInput);
465
 
                TimedPlaceComponent placeComponent = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameInput, nameOffsetXInput, nameOffsetYInput, initialMarkingInput, markingOffsetXInput, markingOffsetYInput, 0);
 
454
                TimedPlaceComponent placeComponent = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, markingOffsetXInput, markingOffsetYInput);
466
455
                placeComponent.setUnderlyingPlace(p);
467
456
                
468
457
                if (!displayName){
743
732
        }
744
733
 
745
734
        private void addListeners(PetriNetObject newObject, Template template) {
746
 
                if (newObject != null) {
747
 
                        if (newObject.getMouseListeners().length == 0) {
748
 
                                if (newObject instanceof Place) {
749
 
                                        // XXX - kyrke
750
 
                                        if (newObject instanceof TimedPlaceComponent) {
751
 
 
752
 
                                                LabelHandler labelHandler = new LabelHandler(((Place) newObject).getNameLabel(), (Place) newObject);
753
 
                                                ((Place) newObject).getNameLabel().addMouseListener(labelHandler);
754
 
                                                ((Place) newObject).getNameLabel().addMouseMotionListener(labelHandler);
755
 
                                                ((Place) newObject).getNameLabel().addMouseWheelListener(labelHandler);
756
 
 
757
 
                                                PlaceHandler placeHandler = new PlaceHandler(drawingSurface, (Place) newObject, template.guiModel(), template.model());
758
 
                                                newObject.addMouseListener(placeHandler);
759
 
                                                newObject.addMouseWheelListener(placeHandler);
760
 
                                                newObject.addMouseMotionListener(placeHandler);
761
 
                                        } else {
762
 
 
763
 
                                                LabelHandler labelHandler = new LabelHandler(((Place) newObject).getNameLabel(), (Place) newObject);
764
 
                                                ((Place) newObject).getNameLabel().addMouseListener(labelHandler);
765
 
                                                ((Place) newObject).getNameLabel().addMouseMotionListener(labelHandler);
766
 
                                                //((Place) newObject).getNameLabel().addMouseWheelListener(labelHandler);
767
 
 
768
 
                                                PlaceHandler placeHandler = new PlaceHandler(drawingSurface, (Place) newObject);
769
 
                                                newObject.addMouseListener(placeHandler);
770
 
                                                //newObject.addMouseWheelListener(placeHandler);
771
 
                                                newObject.addMouseMotionListener(placeHandler);
772
 
 
773
 
                                        }
774
 
                                } else if (newObject instanceof Transition) {
775
 
                                        TransitionHandler transitionHandler;
776
 
                                        if (newObject instanceof TimedTransitionComponent) {
777
 
                                                transitionHandler = new TAPNTransitionHandler(drawingSurface, (Transition) newObject, template.guiModel(), template.model());
778
 
                                        } else {
779
 
                                                transitionHandler = new TransitionHandler(drawingSurface, (Transition) newObject);
780
 
                                        }
781
 
 
782
 
                                        LabelHandler labelHandler = new LabelHandler(((Transition) newObject).getNameLabel(), (Transition) newObject);
783
 
                                        ((Transition) newObject).getNameLabel().addMouseListener(labelHandler);
784
 
                                        ((Transition) newObject).getNameLabel().addMouseMotionListener(labelHandler);
785
 
                                        ((Transition) newObject).getNameLabel().addMouseWheelListener(labelHandler);
786
 
 
787
 
                                        newObject.addMouseListener(transitionHandler);
788
 
                                        newObject.addMouseMotionListener(transitionHandler);
789
 
                                        newObject.addMouseWheelListener(transitionHandler);
790
 
 
791
 
                                        newObject.addMouseListener(new AnimationHandler());
792
 
 
793
 
                                } else if (newObject instanceof Arc) {
794
 
                                        LabelHandler labelHandler = new LabelHandler(((Arc) newObject).getNameLabel(), (Arc) newObject);
795
 
                                        ((Arc) newObject).getNameLabel().addMouseListener(labelHandler);
796
 
                                        ((Arc) newObject).getNameLabel().addMouseMotionListener(labelHandler);
797
 
                                        ((Arc) newObject).getNameLabel().addMouseWheelListener(labelHandler);
798
 
                                        /* CB - Joakim Byg add timed arcs */
799
 
                                        if (newObject instanceof TimedInputArcComponent) {
800
 
                                                if (newObject instanceof TimedTransportArcComponent) {
801
 
                                                        TransportArcHandler transportArcHandler = new TransportArcHandler(drawingSurface, (Arc) newObject);
802
 
                                                        newObject.addMouseListener(transportArcHandler);
803
 
                                                        //newObject.addMouseWheelListener(transportArcHandler);
804
 
                                                        newObject.addMouseMotionListener(transportArcHandler);
805
 
                                                } else {
806
 
                                                        TimedArcHandler timedArcHandler = new TimedArcHandler(drawingSurface, (Arc) newObject);
807
 
                                                        newObject.addMouseListener(timedArcHandler);
808
 
                                                        //newObject.addMouseWheelListener(timedArcHandler);
809
 
                                                        newObject.addMouseMotionListener(timedArcHandler);
810
 
                                                }
811
 
                                        } else {
812
 
                                                /* EOC */
813
 
                                                ArcHandler arcHandler = new ArcHandler(drawingSurface,(Arc) newObject);
814
 
                                                newObject.addMouseListener(arcHandler);
815
 
                                                //newObject.addMouseWheelListener(arcHandler);
816
 
                                                newObject.addMouseMotionListener(arcHandler);
817
 
                                        }
818
 
                                } else if (newObject instanceof AnnotationNote) {
819
 
                                        AnnotationNoteHandler noteHandler = new AnnotationNoteHandler(drawingSurface, (AnnotationNote) newObject);
820
 
                                        newObject.addMouseListener(noteHandler);
821
 
                                        newObject.addMouseMotionListener(noteHandler);
822
 
                                        ((Note) newObject).getNote().addMouseListener(noteHandler);
823
 
                                        ((Note) newObject).getNote().addMouseMotionListener(noteHandler);
824
 
                                }
825
 
                                
826
 
                                newObject.zoomUpdate(drawingSurface.getZoom());
827
 
                                
828
 
                        }
829
 
                        newObject.setGuiModel(template.guiModel());
830
 
                }
 
735
                drawingSurface.addPNListeners(newObject, drawingSurface, template.guiModel());
831
736
        }
832
737
}