KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > WorkflowPort


1 package com.opensymphony.workflow.designer;
2
3 import java.util.Iterator JavaDoc;
4
5 import org.jgraph.graph.DefaultPort;
6
7 /**
8  * User: Hani Suleiman
9  * Date: Oct 16, 2003
10  * Time: 3:12:13 PM
11  */

12 public class WorkflowPort extends DefaultPort
13 {
14   public WorkflowPort()
15   {
16   }
17
18   public int getEdgeCount()
19   {
20     return edges.size();
21   }
22
23   /**
24    * Check all existing edges for this port and assign the edge an index.
25    * If there are no edges that would overlap edge, then the index
26    * is 0. The index ensures that it is possible to uniquely
27    * identify any overlapping edges.
28    * @param edge
29    */

30   public void assignIndex(ResultEdge edge)
31   {
32     WorkflowPort source = (WorkflowPort)edge.getSource();
33     WorkflowPort target = (WorkflowPort)edge.getTarget();
34     int index = 0;
35     Iterator JavaDoc i = edges.iterator();
36     while(i.hasNext())
37     {
38       ResultEdge e = (ResultEdge)i.next();
39       if(e.getTarget().equals(source) && e.getSource().equals(target))
40       {
41         index++;
42       }
43     }
44     edge.setIndex(index);
45   }
46 }
47
Popular Tags