1 package com.opensymphony.workflow.designer; 2 3 import java.io.PrintWriter ; 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 ; 10 11 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 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 e) 37 { 38 System.out.println("Error parsing result position:" + e); 39 } 40 } 41 42 public void writeXML(PrintWriter writer, int indent) 43 { 44 XMLUtil.printIndent(writer, indent++); 45 StringBuffer buf = new StringBuffer (); 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 |