01: package com.opensymphony.workflow.designer.views;
02:
03: import java.awt.*;
04: import java.awt.geom.Rectangle2D;
05:
06: import org.jgraph.graph.CellViewRenderer;
07: import org.jgraph.graph.VertexView;
08:
09: public class InitialActionView extends VertexView {
10: private Object cell;
11: private static final InitialActionRenderer renderer = new InitialActionRenderer();
12:
13: public InitialActionView(Object cell) {
14: super (cell);
15: this .cell = cell;
16: }
17:
18: public String toString() {
19: return cell.toString();
20: }
21:
22: /**
23: * Returns the intersection of the bounding rectangle and the
24: * straight line between the source and the specified point p.
25: * The specified point is expected not to intersect the bounds.
26: */
27: public Point getPerimeterPoint(Point source, Point p) {
28: // Compute relative bounds
29: Rectangle2D r = getBounds();
30: double a = (r.getWidth() + 1) / 2;
31: double b = (r.getHeight() + 1) / 2;
32:
33: // Get center
34: int xCenter = (int) r.getCenterX();
35: int yCenter = (int) r.getCenterY();
36:
37: // Compute angle
38: int dx = p.x - xCenter;
39: int dy = p.y - yCenter;
40: double t = Math.atan2(dy, dx);
41:
42: // Compute Perimeter Point
43: int xout = xCenter + (int) (a * Math.cos(t)) - 1;
44: int yout = yCenter + (int) (b * Math.sin(t)) - 1;
45:
46: // Return perimeter point
47: return new Point(xout, yout);
48: }
49:
50: public CellViewRenderer getRenderer() {
51: return renderer;
52: }
53:
54: }
|