KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > RelationLink


1 /*
2   Copyright (C) 2002-2003 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;
20
21 import org.objectweb.jac.core.ObjectRepository;
22 import org.objectweb.jac.core.rtti.ClassRepository;
23 import java.util.Collection JavaDoc;
24
25 public class RelationLink extends Link {
26
27     public RelationLink() {
28     }
29
30     public RelationLink(Class JavaDoc start, Class JavaDoc end) {
31         initRoles();
32         setStart(start);
33         setEnd(end);
34     }
35
36     /**
37      * Instantiates a start role and an end role.
38      */

39     public void initRoles() {
40         startRole = new RelationRole(this);
41         endRole = new RelationRole(this);
42     }
43
44     public RelationRole startRole() {
45         return (RelationRole)startRole;
46     }
47
48     public RelationRole endRole() {
49         return (RelationRole)endRole;
50     }
51
52     public static final int ORIENTATION_BOTH = 0;
53     public static final int ORIENTATION_STRAIGHT = 1;
54     public static final int ORIENTATION_REVERSE = -1;
55
56     int orientation = ORIENTATION_BOTH;
57
58     /**
59      * Get the value of orientation.
60      * @return value of orientation.
61      */

62     public int getOrientation() {
63         return orientation;
64     }
65     /**
66      * Set the value of orientation.
67      * @param v Value to assign to orientation.
68      */

69     public void setOrientation(int v) {
70         this.orientation = v;
71     }
72
73     boolean aggregation;
74     /**
75      * Get the value of aggregation.
76      * @return value of aggregation.
77      */

78     public boolean isAggregation() {
79         return aggregation;
80     }
81     /**
82      * Set the value of aggregation.
83      * @param v Value to assign to aggregation.
84      */

85     public void setAggregation(boolean v) {
86         this.aggregation = v;
87     }
88
89     boolean calculated;
90     /**
91      * Get the value of aggregation.
92      * @return value of aggregation.
93      */

94     public boolean isCalculated() {
95         return calculated;
96     }
97     /**
98      * Set the value of aggregation.
99      * @param v Value to assign to aggregation.
100      */

101     public void setCalculated(boolean v) {
102         this.calculated = v;
103     }
104
105     public static Collection JavaDoc endChoices(Object JavaDoc substance) {
106         return ObjectRepository.getObjects(ClassRepository.get().getClass(Class JavaDoc.class));
107     }
108
109     /**
110      * Swaps start and end classes. (Does not work well with diagrams)
111      */

112     public void reverse() {
113         RelationRole start = (RelationRole)startRole;
114         RelationRole end = (RelationRole)endRole;
115         startRole = end;
116         endRole = start;
117     }
118 }
119
Popular Tags