~boginw/tapaal/multiplayer

« back to all changes in this revision

Viewing changes to src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.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
1
package pipe.gui.graphicElements.tapn;
2
2
 
3
 
import java.awt.BasicStroke;
4
3
import java.awt.Container;
5
 
import java.awt.Graphics;
6
 
import java.awt.Graphics2D;
7
 
import java.awt.Polygon;
8
 
import java.awt.RenderingHints;
9
 
import java.awt.geom.AffineTransform;
10
4
import java.util.Hashtable;
11
5
 
12
6
import javax.swing.BoxLayout;
13
7
 
14
 
import pipe.dataLayer.DataLayer;
15
8
import pipe.gui.CreateGui;
16
 
import pipe.gui.DrawingSurfaceImpl;
 
9
 
17
10
import pipe.gui.Grid;
18
 
import pipe.gui.Pipe;
19
11
import pipe.gui.Zoomer;
20
12
import pipe.gui.graphicElements.Arc;
21
13
import pipe.gui.graphicElements.ArcPath;
22
 
import pipe.gui.graphicElements.NameLabel;
23
14
import pipe.gui.graphicElements.PlaceTransitionObject;
24
15
import pipe.gui.handler.ArcHandler;
25
16
import pipe.gui.undo.ArcTimeIntervalEdit;
30
21
import dk.aau.cs.model.tapn.TimedArcPetriNet;
31
22
import dk.aau.cs.model.tapn.Weight;
32
23
 
33
 
/**
34
 
 * <b>Arc</b> - Petri-Net Normal Arc Class
35
 
 * 
36
 
 * @see <p>
37
 
 *      <a href="..\PNMLSchema\index.html">PNML - Petri-Net XMLSchema
38
 
 *      (stNet.xsd)</a>
39
 
 * @see </p>
40
 
 *      <p>
41
 
 *      <a href="..\..\..\UML\dataLayer.html">UML - PNML Package </a>
42
 
 *      </p>
43
 
 * @version 1.0
44
 
 */
45
24
public class TimedOutputArcComponent extends Arc {
46
25
        /**
47
26
         * 
50
29
 
51
30
        private dk.aau.cs.model.tapn.TimedOutputArc outputArc;
52
31
 
53
 
        /**
54
 
         * Create Petri-Net Arc object
55
 
         * 
56
 
         * @param startPositionXInput
57
 
         *            Start X-axis Position
58
 
         * @param startPositionYInput
59
 
         *            Start Y-axis Position
60
 
         * @param endPositionXInput
61
 
         *            End X-axis Position
62
 
         * @param endPositionYInput
63
 
         *            End Y-axis Position
64
 
         * @param sourceInput
65
 
         *            Arc source
66
 
         * @param targetInput
67
 
         *            Arc target
68
 
         * @param idInput
69
 
         *            Arc id
70
 
         */
 
32
        public TimedOutputArcComponent(PlaceTransitionObject sourceInput, PlaceTransitionObject targetInput, int weightInput, String idInput) {
 
33
                super(sourceInput, targetInput, weightInput, idInput);
 
34
        }
 
35
 
 
36
        /** @deprecated */
 
37
        @Deprecated
71
38
        public TimedOutputArcComponent(double startPositionXInput,
72
39
                        double startPositionYInput, double endPositionXInput,
73
40
                        double endPositionYInput, PlaceTransitionObject sourceInput,
74
41
                        PlaceTransitionObject targetInput, int weightInput, String idInput,
75
42
                        boolean taggedInput) {
76
 
                super(startPositionXInput, startPositionYInput, endPositionXInput,
77
 
                                endPositionYInput, sourceInput, targetInput, weightInput,
78
 
                                idInput);
79
 
 
80
 
                //XXX: se note in funcation
81
 
                addMouseHandler();
 
43
                this(sourceInput, targetInput, weightInput, idInput);
82
44
        }
83
45
 
84
46
        /**
86
48
         */
87
49
        public TimedOutputArcComponent(PlaceTransitionObject newSource) {
88
50
                super(newSource);
89
 
 
90
 
                //XXX: se note in funcation
91
 
                addMouseHandler();
92
51
        }
93
52
 
94
53
        public TimedOutputArcComponent(TimedOutputArcComponent arc) {
95
 
                zoom = arc.zoom;
96
 
 
97
 
                myPath = new ArcPath(this);
98
 
                for (int i = 0; i <= arc.myPath.getEndIndex(); i++) {
99
 
                        myPath.addPoint(arc.myPath.getPoint(i).getX(), arc.myPath.getPoint(i).getY(), arc.myPath.getPointType(i),zoom);
100
 
                }
101
 
                myPath.createPath();
 
54
 
 
55
                super(arc.getSource(), arc.getTarget(), 0, null);
 
56
 
 
57
                myPath = new ArcPath(this, arc.myPath);
 
58
 
102
59
                this.updateBounds();
103
60
                id = arc.id;
104
61
                this.setSource(arc.getSource());
105
62
                this.setTarget(arc.getTarget());
106
 
                this.updateNameOffsetX(arc.getNameOffsetXObject());
107
 
                this.updateNameOffsetY(arc.getNameOffsetYObject());
 
63
                this.setNameOffsetX(arc.getNameOffsetXObject());
 
64
                this.setNameOffsetY(arc.getNameOffsetYObject());
108
65
                this.getNameLabel().setPosition(
109
 
                                Grid.getModifiedX((int) (arc.getNameLabel().getXPosition() + Zoomer.getZoomedValue(this.nameOffsetX, zoom))), 
110
 
                                Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(this.nameOffsetY, zoom))));
 
66
                                Grid.getModifiedX((int) (arc.getNameLabel().getXPosition() + Zoomer.getZoomedValue(getNameOffsetX(), getZoom()))),
 
67
                                Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(getNameOffsetY(), getZoom()))));
111
68
 
112
 
                //XXX: se note in funcation
113
 
                addMouseHandler();
114
69
        }
115
70
 
116
 
        private void addMouseHandler() {
 
71
        @Override
 
72
        protected void addMouseHandler() {
117
73
                //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when
118
74
                //XXX: handler is called. Make static constructor and add handler from there, to make it safe.
119
75
                mouseHandler = new ArcHandler(this);
133
89
        }
134
90
 
135
91
        public void updateLabel(boolean displayConstantNames) {
136
 
                pnName.setText("");
137
 
                pnName.setText(getWeight().toString(displayConstantNames)+" " + pnName.getText());
 
92
                getNameLabel().setText("");
 
93
                getNameLabel().setText(getWeight().toString(displayConstantNames)+" " + getNameLabel().getText());
138
94
                setLabelPosition();
139
95
        }
140
96
 
141
 
        @Override
142
 
        public void delete() {
143
 
                if (outputArc != null)
144
 
                        outputArc.delete();
145
 
                super.delete();
146
 
        }
147
 
        
148
97
        public void showTimeIntervalEditor() {
149
98
                EscapableDialog guiDialog = new EscapableDialog(CreateGui.getApp(), "Edit Arc", true);
150
99
 
181
130
                newCopyArc.setTarget(oldToNewMapping.get(this.getTarget()));
182
131
                newCopyArc.setUnderlyingArc(tapn.getOutputArcFromTransitionAndPlace(tapn.getTransitionByName(outputArc.source().name()), tapn.getPlaceByName(outputArc.destination().name())));
183
132
                
184
 
                newCopyArc.getSource().addConnectFrom(newCopyArc);
185
 
                newCopyArc.getTarget().addConnectTo(newCopyArc);
186
 
                
187
133
                return newCopyArc;
188
134
        }
189
135
 
197
143
                return outputArc.getWeight();
198
144
        }
199
145
 
200
 
        public TimeInterval getGuard() {
201
 
                // TODO Auto-generated method stub
202
 
                return null;
203
 
        }
204
 
 
205
146
}