package simple_uml.view.canvas; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; /** * Illustrations some kind of relationship (association, parentage, etc.) * between two shapes on the canvas. You can extend this class to display the * different kinds of arrows necessary for the UML relationship you need to * draw. * * @author Eric Liebowitz * @version 08jul11 */ public class Relationship extends SumlShape { /** * Point we'll hook the src to */ private Hook src; private Hook dst; public Relationship (SumlShape s1, SumlShape s2) { src = new Hook(s1); dst = new Hook(s2); } protected void draw (Graphics2D g2d) { AffineTransform at = g2d.getTransform(); at.setToIdentity(); g2d.setTransform(at); g2d.draw(new Line2D.Double(src.getPoint().getX(), src.getPoint().getY(), dst.getPoint().getX(), dst.getPoint().getY())); } }