1 package com.opensymphony.workflow.designer.views; 2 3 import java.awt.*; 4 import java.awt.geom.Rectangle2D ; 5 6 import org.jgraph.JGraph; 7 import org.jgraph.graph.CellMapper; 8 import org.jgraph.graph.CellViewRenderer; 9 import org.jgraph.graph.VertexView; 10 11 public class InitialActionView extends VertexView 12 { 13 private Object cell; 14 private static final InitialActionRenderer renderer = new InitialActionRenderer(); 15 16 public InitialActionView(Object cell, JGraph graph, CellMapper mapper) 17 { 18 super(cell, graph, mapper); 19 this.cell = cell; 20 } 21 22 public String toString() 23 { 24 return cell.toString(); 25 } 26 27 32 public Point getPerimeterPoint(Point source, Point p) 33 { 34 Rectangle2D r = getBounds(); 36 double a = (r.getWidth() + 1) / 2; 37 double b = (r.getHeight() + 1) / 2; 38 39 int xCenter = (int)r.getCenterX(); 41 int yCenter = (int)r.getCenterY(); 42 43 int dx = p.x - xCenter; 45 int dy = p.y - yCenter; 46 double t = Math.atan2(dy, dx); 47 48 int xout = xCenter + (int)(a * Math.cos(t)) - 1; 50 int yout = yCenter + (int)(b * Math.sin(t)) - 1; 51 52 return new Point(xout, yout); 54 } 55 56 public CellViewRenderer getRenderer() 57 { 58 return renderer; 59 } 60 61 } 62 | Popular Tags |