001package horstmann.ch08_umleditor;
002import java.awt.geom.Point2D;
003
004/**
005   A UML class diagram.
006 */
007@SuppressWarnings("serial")
008public class ClassDiagramGraph extends Graph
009{
010
011        public boolean connect(Edge e, Point2D p1, Point2D p2)
012        {
013                Node n1 = findNode(p1);
014                Node n2 = findNode(p2);
015                if (n1 == n2) return false;
016                return super.connect(e, p1, p2);
017        }
018
019        public Node[] getNodePrototypes()
020        {
021                return new Node[] { new ClassNode() };
022        }
023
024        public Edge[] getEdgePrototypes()
025        {
026                ClassRelationshipEdge[] e = new ClassRelationshipEdge[6];
027
028                e[0] = new ClassRelationshipEdge();
029                e[0].setLineStyle(LineStyle.DOTTED);
030                e[0].setEndArrowHead(ArrowHead.V);
031
032                e[1] = new ClassRelationshipEdge();
033                e[1].setBentStyle(BentStyle.VHV);
034                e[1].setEndArrowHead(ArrowHead.TRIANGLE);
035
036                e[2] = new ClassRelationshipEdge();
037                e[2].setBentStyle(BentStyle.VHV);
038                e[2].setLineStyle(LineStyle.DOTTED);
039                e[2].setEndArrowHead(ArrowHead.TRIANGLE);
040
041                e[3] = new ClassRelationshipEdge();
042                e[3].setBentStyle(BentStyle.HVH);
043                e[3].setEndArrowHead(ArrowHead.V);
044
045                e[4] = new ClassRelationshipEdge();
046                e[4].setBentStyle(BentStyle.HVH);
047                e[4].setStartArrowHead(ArrowHead.DIAMOND);
048
049                e[5] = new ClassRelationshipEdge();
050                e[5].setBentStyle(BentStyle.HVH);
051                e[5].setStartArrowHead(ArrowHead.BLACK_DIAMOND);
052
053                return e;
054        }
055}
056
057
058
059
060