01: package org.enhydra.jawe.components.graph;
02:
03: import java.util.HashSet;
04: import java.util.Set;
05:
06: import org.jgraph.graph.DefaultGraphCell;
07:
08: /**
09: * Interface for creating JGraph's Participant object.
10: *
11: * @author Sasa Bojanic
12: */
13: public abstract class GraphParticipantInterface extends
14: DefaultGraphCell implements WorkflowElement {
15:
16: public boolean hasAnyParticipant() {
17: return false;
18: }
19:
20: /**
21: * Returns true if participant is a container for any activity.
22: * <BR>NOTE: subflow is a kind of activity.
23: */
24: public boolean hasAnyActivity() {
25: for (int i = 0; i < getChildCount(); i++) {
26: if (getChildAt(i) instanceof GraphActivityInterface) {
27: return true;
28: }
29: }
30: return false;
31: }
32:
33: /**
34: * Returns the number of participant's children activities (number of
35: * activities for which it is a container).
36: * <BR>NOTE: subflow is a kind of activity.
37: */
38: public int howManyChildActivities() {
39: int ca = 0;
40: for (int i = 0; i < getChildCount(); i++) {
41: if (getChildAt(i) instanceof GraphActivityInterface) {
42: ca++;
43: }
44: }
45: return ca;
46: }
47:
48: /**
49: * Returns participant's children activities (activities
50: * for which it is a container).
51: * <BR>NOTE: subflow is a kind of activity.
52: */
53: public Set getChildActivities() {
54: Set childActivities = new HashSet();
55: for (int i = 0; i < getChildCount(); i++) {
56: Object child = getChildAt(i);
57: if (child instanceof GraphActivityInterface) {
58: childActivities.add(child);
59: }
60: }
61: return childActivities;
62: }
63:
64: }
|