01: package com.opensymphony.workflow.designer;
02:
03: import java.awt.*;
04: import java.awt.geom.Point2D;
05: import java.util.ArrayList;
06:
07: import com.opensymphony.workflow.designer.views.EdgeRouter;
08: import com.opensymphony.workflow.loader.*;
09: import org.jgraph.graph.GraphConstants;
10:
11: /**
12: * @author Hani Suleiman (hani@formicary.net)
13: * Date: May 20, 2003
14: * Time: 3:27:52 PM
15: */
16: public class ResultEdge extends WorkflowEdge {
17: private static final EdgeRouter EDGE_ROUTER = new EdgeRouter();
18:
19: private ResultDescriptor descriptor;
20:
21: public ResultEdge(ResultDescriptor descriptor, Point2D labelPos) {
22: super (descriptor);
23: setAttributes(new WorkflowAttributeMap(getAttributes()));
24: this .descriptor = descriptor;
25: int arrow = GraphConstants.ARROW_CLASSIC;
26: //GraphConstants.setLabelAlongEdge(attributes, true);
27: GraphConstants.setLineEnd(attributes, arrow);
28: GraphConstants.setEndFill(attributes, true);
29: GraphConstants.setDisconnectable(attributes, true);
30: GraphConstants.setBendable(attributes, true);
31: GraphConstants.setForeground(attributes, Color.BLACK);
32: //GraphConstants.setRouting(attributes, EDGE_ROUTER);
33: GraphConstants.setMoveable(attributes, true);
34: if (labelPos != null) {
35: GraphConstants.setLabelPosition(attributes, new Point(
36: (int) labelPos.getX(), (int) labelPos.getY()));
37: }
38: }
39:
40: public ResultEdge(ResultDescriptor descriptor, Point2D labelPos,
41: java.util.List routingPoints) {
42: this (descriptor, labelPos);
43: java.util.List newpoints = new ArrayList();
44: newpoints.add(new Point(0, 0));
45: for (int i = 0; i < routingPoints.size(); i++) {
46: newpoints.add(new Point(((Point) routingPoints.get(i)).x,
47: ((Point) routingPoints.get(i)).y));
48: }
49: newpoints.add(new Point(0, 0));
50: GraphConstants.setPoints(attributes, newpoints);
51: }
52:
53: public ResultEdge(ResultDescriptor descriptor, Point2D labelPos,
54: float lineWidth, Color color, java.util.List routingPoints) {
55: this (descriptor, labelPos, routingPoints);
56: GraphConstants.setLineWidth(attributes, lineWidth);
57: GraphConstants.setForeground(attributes, color);
58: }
59:
60: public ResultDescriptor getDescriptor() {
61: return descriptor;
62: }
63:
64: public void setAutoroute() {
65: GraphConstants.setRouting(attributes, EDGE_ROUTER);
66: }
67:
68: public String toString() {
69: if (descriptor == null)
70: return null;
71: if (descriptor.getDisplayName() != null) {
72: if (descriptor.getDisplayName().length() > 0) {
73: return descriptor.getDisplayName();
74: }
75: }
76: if (descriptor.getParent() instanceof ActionDescriptor) {
77: return ((ActionDescriptor) descriptor.getParent())
78: .getName();
79: } else if (descriptor.getParent() instanceof SplitDescriptor) {
80: return "Split #" + descriptor.getParent().getId();
81: } else if (descriptor.getParent() instanceof JoinDescriptor) {
82: return "Join #" + descriptor.getParent().getId();
83: }
84: return "<unknown>";
85: }
86: }
|