1
14 package demo.view.flowchart.layout;
15
16 import y.base.DataProvider;
17 import y.base.Edge;
18 import y.base.Graph;
19 import y.base.GraphInterface;
20 import y.base.Node;
21
22
29 public class FlowchartElements {
30
33 public static final byte TYPE_INVALID = 0;
34
37 public static final byte NODE_TYPE_EVENT = 1;
38
41 public static final byte NODE_TYPE_START_EVENT = 7;
42
45 public static final byte NODE_TYPE_END_EVENT = 9;
46
49 public static final byte NODE_TYPE_DECISION = 2;
50
53 public static final byte NODE_TYPE_PROCESS = 3;
54
57 public static final byte NODE_TYPE_GROUP = 8;
58
61 public static final byte NODE_TYPE_ANNOTATION = 10;
62
65 public static final byte NODE_TYPE_POOL = 12;
66
69 public static final byte NODE_TYPE_DATA = 11;
70
71
74 public static final byte EDGE_TYPE_SEQUENCE_FLOW = 4;
75
76
79 public static final byte EDGE_TYPE_MESSAGE_FLOW = 5;
80
81
84 public static final byte EDGE_TYPE_ASSOCIATION = 6;
85
86
90 static boolean isActivity(final Graph graph, final Node node) {
91 final byte type = getType(graph, node);
92 return (type == NODE_TYPE_PROCESS) || (type == NODE_TYPE_DATA) || (type == NODE_TYPE_GROUP);
93 }
94
95
98 static boolean isGroup(final Graph graph, final Node node) {
99 return getType(graph, node) == NODE_TYPE_GROUP;
100 }
101
102
105 static boolean isAnnotation(final Graph graph, final Node node) {
106 return getType(graph, node) == NODE_TYPE_ANNOTATION;
107 }
108
109
113 static boolean isEvent(final Graph graph, final Node node) {
114 final byte type = getType(graph, node);
115 return (type == NODE_TYPE_START_EVENT) || (type == NODE_TYPE_EVENT) || (type == NODE_TYPE_END_EVENT);
116 }
117
118
121 static boolean isStartEvent(final Graph graph, final Node node) {
122 return getType(graph, node) == NODE_TYPE_START_EVENT;
123 }
124
125
128 static boolean isEndEvent(final Graph graph, final Node node) {
129 return getType(graph, node) == NODE_TYPE_END_EVENT;
130 }
131
132
135 static boolean isDecision(final Graph graph, final Node node) {
136 return getType(graph, node) == NODE_TYPE_DECISION;
137 }
138
139 static boolean isUndefined(final Graph graph, final Edge edge) {
140 return getType(graph, edge) == TYPE_INVALID;
141 }
142
143 static boolean isRegularEdge(final Graph graph, final Edge edge) {
144 return getType(graph, edge) == EDGE_TYPE_SEQUENCE_FLOW;
145 }
146
147 static boolean isMessageFlow(final Graph graph, final Edge edge) {
148 return getType(graph, edge) == EDGE_TYPE_MESSAGE_FLOW;
149 }
150
151 static byte getType(final GraphInterface graph, final Edge dataHolder) {
152 final DataProvider dataProvider = graph.getDataProvider(FlowchartLayouter.EDGE_TYPE_DPKEY);
153 return dataProvider == null ? TYPE_INVALID : (byte) dataProvider.getInt(dataHolder);
154 }
155
156 static byte getType(final GraphInterface graph, final Node dataHolder) {
157 final DataProvider dataProvider = graph.getDataProvider(FlowchartLayouter.NODE_TYPE_DPKEY);
158 return dataProvider == null ? TYPE_INVALID : (byte) dataProvider.getInt(dataHolder);
159 }
160
161 private FlowchartElements() {
162 }
163 }
164