KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > diagrams > RelationLinkFigure


1 /*
2   Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA. */

18
19 package org.objectweb.jac.ide.diagrams;
20
21 import CH.ifa.draw.figures.ArrowTip;
22 import org.objectweb.jac.ide.RelationLink;
23 import java.awt.Color JavaDoc;
24 import org.objectweb.jac.aspects.gui.DisplayContext;
25 import org.objectweb.jac.core.rtti.CollectionItem;
26 import org.objectweb.jac.core.rtti.ClassRepository;
27 import org.objectweb.jac.aspects.gui.EventHandler;
28
29
30 public class RelationLinkFigure extends LinkFigure {
31
32    public RelationLinkFigure(org.objectweb.jac.ide.LinkFigure figure) {
33       super(figure);
34    }
35    public RelationLinkFigure() {
36    }
37
38    void setDecorations() {
39       if (linkFig==null) {
40          setStartDecoration(null);
41          setEndDecoration(null);
42          return;
43       }
44       RelationLink link = (RelationLink)linkFig.getLink();
45       switch (link.getOrientation()) {
46          case RelationLink.ORIENTATION_STRAIGHT:
47             setStartDecoration(null);
48             setEndDecoration(new ArrowTip());
49             break;
50          case RelationLink.ORIENTATION_REVERSE:
51             setStartDecoration(new ArrowTip());
52             setEndDecoration(null);
53             break;
54          default:
55             setStartDecoration(null);
56             setEndDecoration(null);
57       }
58       if (link.isAggregation()) {
59          ArrowTip arrow = new ArrowTip(0.50, 15, 28);
60          arrow.setFillColor(Color.white);
61          setStartDecoration(arrow);
62       }
63    }
64
65    // Selectable interface
66
public void onSelect(DisplayContext context) {
67       CollectionItem coll = ClassRepository.get().getClass(Class JavaDoc.class)
68          .getCollection("links");
69       EventHandler.get().onSelection(
70          context,coll,getSubstance(),null,null);
71    }
72 }
73
Popular Tags