~workcraft/workcraft/2.0

« back to all changes in this revision

Viewing changes to XmasPlugin/src/org/workcraft/plugins/xmas/components/VisualForkComponent.java

  • Committer: Danil Sokolov
  • Date: 2014-01-29 19:00:22 UTC
  • mfrom: (470.1.134 src-danilovesky)
  • Revision ID: danilovesky@gmail.com-20140129190022-hvjinnjj60wou9s0
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*
 
3
* Copyright 2008,2009 Newcastle University
 
4
*
 
5
* This file is part of Workcraft.
 
6
 
7
* Workcraft is free software: you can redistribute it and/or modify
 
8
* it under the terms of the GNU General Public License as published by
 
9
* the Free Software Foundation, either version 3 of the License, or
 
10
* (at your option) any later version.
 
11
 
12
* Workcraft is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
 
17
* You should have received a copy of the GNU General Public License
 
18
* along with Workcraft.  If not, see <http://www.gnu.org/licenses/>.
 
19
*
 
20
*/
 
21
 
 
22
package org.workcraft.plugins.xmas.components;
 
23
 
 
24
import java.awt.Shape;
 
25
import java.awt.event.KeyEvent;
 
26
import java.awt.geom.Path2D;
 
27
 
 
28
import org.workcraft.annotations.DisplayName;
 
29
import org.workcraft.annotations.Hotkey;
 
30
import org.workcraft.annotations.SVGIcon;
 
31
import org.workcraft.dom.visual.Positioning;
 
32
 
 
33
@DisplayName("Fork")
 
34
@Hotkey(KeyEvent.VK_K)
 
35
@SVGIcon("images/icons/svg/xmas-fork.svg")
 
36
public class VisualForkComponent extends VisualXmasComponent {
 
37
        
 
38
        public VisualForkComponent(ForkComponent component) {
 
39
                super(component);
 
40
                if (component.getChildren().isEmpty()) { 
 
41
                        this.addInput("", Positioning.TOP);
 
42
                        this.addOutput("", Positioning.BOTTOM_RIGHT);
 
43
                        this.addOutput("", Positioning.BOTTOM_LEFT);
 
44
                }
 
45
        }
 
46
 
 
47
        @Override
 
48
        public Shape getShape() {
 
49
                Path2D shape = new Path2D.Double();
 
50
                
 
51
                shape.moveTo(0, -0.5 * size);
 
52
                shape.lineTo(0, -0.1 * size);
 
53
 
 
54
                shape.moveTo(-0.5 * size, -0.1 * size);
 
55
                shape.lineTo(+0.5 * size, -0.1 * size);
 
56
 
 
57
                shape.moveTo(-0.5 * size, +0.1 * size);
 
58
                shape.lineTo(+0.5 * size, +0.1 * size);
 
59
 
 
60
                shape.moveTo(-0.5 * size, +0.1 * size);
 
61
                shape.lineTo(-0.5 * size, +0.5 * size);
 
62
 
 
63
                shape.moveTo(+0.5 * size, +0.1 * size);
 
64
                shape.lineTo(+0.5 * size, +0.5 * size);
 
65
 
 
66
                return shape;
 
67
        }
 
68
 
 
69
}