KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.opensymphony.workflow.designer;
2
3 import java.io.PrintWriter JavaDoc;
4 import java.awt.*;
5
6 import com.opensymphony.workflow.util.XMLizable;
7 import com.opensymphony.workflow.loader.XMLUtil;
8 import org.jgraph.graph.GraphConstants;
9 import org.w3c.dom.Element JavaDoc;
10
11 /**
12  * @author Hani Suleiman (hani@formicary.net)
13  * Date: Dec 1 2003
14  * Time: 10:09:13 PM
15  */

16 public class ResultPosition implements XMLizable
17 {
18   private Point labelPos;
19   private int id;
20
21   public ResultPosition(ResultEdge edge)
22   {
23     id = edge.getDescriptor().getId();
24     labelPos = GraphConstants.getLabelPosition(edge.getAttributes());
25   }
26
27   public ResultPosition(Element JavaDoc edge)
28   {
29     try
30     {
31       id = Integer.parseInt(edge.getAttribute("id"));
32       labelPos = new Point();
33       labelPos.x = Integer.parseInt(edge.getAttribute("labelx"));
34       labelPos.y = Integer.parseInt(edge.getAttribute("labely"));
35     }
36     catch(Exception JavaDoc e)
37     {
38       System.out.println("Error parsing result position:" + e);
39     }
40   }
41
42   public void writeXML(PrintWriter JavaDoc writer, int indent)
43   {
44     XMLUtil.printIndent(writer, indent++);
45     StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
46     buf.append("<connector ");
47     buf.append("id=\"").append(id).append("\"");
48     buf.append(" labelx=\"").append(labelPos.x).append("\"");
49     buf.append(" labely=\"").append(labelPos.y).append("\"");
50     buf.append("/>");
51     writer.println(buf.toString());
52   }
53
54   public Point getLabelPosition()
55   {
56     return labelPos;
57   }
58
59   public int getId()
60   {
61     return id;
62   }
63 }
64
Popular Tags