~tapaal-contributor/tapaal/display-shared-places-transitions-1879126

« back to all changes in this revision

Viewing changes to src/pipe/gui/graphicElements/Arc.java

merged in lp:~yrke/tapaal/testbranch-syntaxOnlyChanges only reformating, no semantic changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
import pipe.gui.Grid;
14
14
import pipe.gui.Pipe;
15
15
import pipe.gui.Zoomer;
16
 
import pipe.gui.handler.LabelHandler;
17
16
import dk.aau.cs.model.tapn.Weight;
18
17
import pipe.gui.handler.PlaceTransitionObjectHandler;
19
18
 
22
21
 */
23
22
public abstract class Arc extends PetriNetObjectWithLabel {
24
23
 
25
 
        private static final long serialVersionUID = 6527845538091358791L;
26
 
 
27
24
        private Shape head = null;
28
25
        private boolean fillHead = true; //If true, fill the shape when drawing, if false, fill with bg color.
29
26
 
50
47
        // Bounds of arc need to be grown in order to avoid clipping problems
51
48
        protected int zoomGrow = 10;
52
49
 
53
 
        private Arc(int nameOffsetX, int nameOffsetY) {
54
 
            super(nameOffsetX, nameOffsetY);
 
50
        private Arc() {
 
51
            super(0, 0);
55
52
 
56
53
        setHead();
57
54
    }
63
60
        public Arc(
64
61
                        PlaceTransitionObject sourceInput,
65
62
                        PlaceTransitionObject targetInput, int weightInput, String idInput) {
66
 
                this(0,0);
 
63
                this();
67
64
 
68
65
                id = idInput;
69
66
                setSource(sourceInput);
76
73
         * Create Petri-Net Arc object
77
74
         */
78
75
        public Arc(PlaceTransitionObject newSource) {
79
 
                this(0,0);
 
76
                this();
80
77
                isPrototype = true;
81
78
 
82
79
                setSource(newSource);
218
215
                super.paintComponent(g);
219
216
                Graphics2D g2 = (Graphics2D) g;
220
217
 
221
 
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
222
 
                                RenderingHints.VALUE_ANTIALIAS_ON);
 
218
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
223
219
 
224
220
                g2.translate(COMPONENT_DRAW_OFFSET + zoomGrow
225
221
                                - myPath.getBounds().getX(), COMPONENT_DRAW_OFFSET + zoomGrow
251
247
 
252
248
                //Draw Arrow-head
253
249
                //Jump to arc end
254
 
                g2.translate(myPath.getPoint(myPath.getEndIndex()).getX(), myPath
255
 
                                .getPoint(myPath.getEndIndex()).getY());
 
250
                g2.translate(myPath.getPoint(myPath.getEndIndex()).getX(), myPath.getPoint(myPath.getEndIndex()).getY());
256
251
 
257
252
                //Rotate to match arrowhead to arc angle
258
253
                g2.rotate(myPath.getEndAngle() + Math.PI);
297
292
 
298
293
        @Override
299
294
        public boolean contains(int x, int y) {
300
 
                Point2D.Double point = new Point2D.Double(x + myPath.getBounds().getX()
301
 
                                - COMPONENT_DRAW_OFFSET - zoomGrow, y
302
 
                                + myPath.getBounds().getY() - COMPONENT_DRAW_OFFSET - zoomGrow);
 
295
                Point2D.Double point = new Point2D.Double(
 
296
                    x + myPath.getBounds().getX() - COMPONENT_DRAW_OFFSET - zoomGrow,
 
297
            y
 
298
                                + myPath.getBounds().getY() - COMPONENT_DRAW_OFFSET - zoomGrow
 
299
        );
 
300
 
303
301
                if (!CreateGui.getCurrentTab().isInAnimationMode()) {
304
302
                        if (myPath.proximityContains(point) || selected) {
305
303
                                // show also if Arc itself selected
388
386
                this.getActionMap().clear();
389
387
        }
390
388
 
391
 
        private class DeleteAction extends AbstractAction {
 
389
        private static class DeleteAction extends AbstractAction {
392
390
                Arc arcBeingDraw;
393
391
 
394
392
                DeleteAction(Arc arc) {