KickJava   Java API By Example, From Geeks To Geeks.

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


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;
20
21 import java.awt.Point JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Vector JavaDoc;
24
25 /**
26  * A Link figure of a diagram.
27  * @see Diagram
28  * @see Link
29  */

30
31 public class LinkFigure extends Figure {
32
33     public LinkFigure() {
34     }
35
36     public LinkFigure(Link link) {
37         super(link);
38         nameCorner = new Point JavaDoc();
39         startRoleCorner = new Point JavaDoc();
40         startCardinalityCorner = new Point JavaDoc();
41         endRoleCorner = new Point JavaDoc();
42         endCardinalityCorner = new Point JavaDoc();
43         points.add(new Point JavaDoc(0,0));
44         points.add(new Point JavaDoc(0,0));
45     }
46
47     public LinkFigure(Link link,
48                       Point JavaDoc nameCorner,
49                       Point JavaDoc startRoleCorner,
50                       Point JavaDoc startCardinalityCorner,
51                       Point JavaDoc endRoleCorner,
52                       Point JavaDoc endCardinalityCorner) {
53         super(link);
54         this.nameCorner = nameCorner;
55         this.startRoleCorner = startRoleCorner;
56         this.startCardinalityCorner = startCardinalityCorner;
57         this.endRoleCorner = endRoleCorner;
58         this.endCardinalityCorner = endCardinalityCorner;
59         points.add(new Point JavaDoc(0,0));
60         points.add(new Point JavaDoc(0,0));
61     }
62
63     public Link getLink() {
64         return (Link)element;
65     }
66
67     public void translateName(int dx,int dy) {
68         this.nameCorner.translate(dx,dy);
69     }
70
71     public void translateStartRole(int dx,int dy) {
72         this.startRoleCorner.translate(dx,dy);
73     }
74
75     public void translateEndRole(int dx,int dy) {
76         this.endRoleCorner.translate(dx,dy);
77     }
78
79     public void translateStartCardinality(int dx,int dy) {
80         this.startCardinalityCorner.translate(dx,dy);
81     }
82
83     public void translateEndCardinality(int dx,int dy) {
84         this.endCardinalityCorner.translate(dx,dy);
85     }
86
87     Point JavaDoc nameCorner = new Point JavaDoc();
88    
89     /**
90      * Get the value of nameCorner.
91      * @return value of nameCorner.
92      */

93     public Point JavaDoc getNameCorner() {
94         return nameCorner;
95     }
96    
97     /**
98      * Set the value of nameCorner.
99      * @param v Value to assign to nameCorner.
100      */

101     public void setNameCorner(Point JavaDoc v) {
102         this.nameCorner = v;
103     }
104    
105     Point JavaDoc startRoleCorner;
106    
107     /**
108      * Get the value of startRoleCorner.
109      * @return value of startRoleCorner.
110      */

111     public Point JavaDoc getStartRoleCorner() {
112         return startRoleCorner;
113     }
114    
115     /**
116      * Set the value of startRoleCorner.
117      * @param v Value to assign to startRoleCorner.
118      */

119     public void setStartRoleCorner(Point JavaDoc v) {
120         this.startRoleCorner = v;
121     }
122    
123     Point JavaDoc endRoleCorner;
124    
125     /**
126      * Get the value of endRoleCorner.
127      * @return value of endRoleCorner.
128      */

129     public Point JavaDoc getEndRoleCorner() {
130         return endRoleCorner;
131     }
132    
133     /**
134      * Set the value of endRoleCorner.
135      * @param v Value to assign to endRoleCorner.
136      */

137     public void setEndRoleCorner(Point JavaDoc v) {
138         this.endRoleCorner = v;
139     }
140    
141     Point JavaDoc startCardinalityCorner;
142    
143     /**
144      * Get the value of startCardinalityCorner.
145      * @return value of startCardinalityCorner.
146      */

147     public Point JavaDoc getStartCardinalityCorner() {
148         return startCardinalityCorner;
149     }
150    
151     /**
152      * Set the value of startCardinalityCorner.
153      * @param v Value to assign to startCardinalityCorner.
154      */

155     public void setStartCardinalityCorner(Point JavaDoc v) {
156         this.startCardinalityCorner = v;
157     }
158    
159     Point JavaDoc endCardinalityCorner;
160    
161     /**
162      * Get the value of endCardinalityCorner.
163      * @return value of endCardinalityCorner.
164      */

165     public Point JavaDoc getEndCardinalityCorner() {
166         return endCardinalityCorner;
167     }
168    
169     /**
170      * Set the value of endCardinalityCorner.
171      * @param v Value to assign to endCardinalityCorner.
172      */

173     public void setEndCardinalityCorner(Point JavaDoc v) {
174         this.endCardinalityCorner = v;
175     }
176
177     List JavaDoc points = new Vector JavaDoc();
178    
179     /**
180      * Get the value of points.
181      * @return value of points.
182      */

183     public List JavaDoc getPoints() {
184         return points;
185     }
186    
187     /**
188      * Set the value of points.
189      * @param v Value to assign to points.
190      */

191     public void setPoints(List JavaDoc v) {
192         this.points = v;
193     }
194
195     public int getPointCount() {
196         return points.size();
197     }
198    
199     public void addPoint(int index,Point JavaDoc p) {
200         points.add(index,p);
201     }
202
203     public void removePoint(int index) {
204         points.remove(index);
205     }
206
207     public void setPoint(int index,Point JavaDoc p) {
208         points.set(index,p);
209     }
210
211     public void translatePoint(int index, int dx, int dy) {
212         Point JavaDoc p = (Point JavaDoc)points.get(index);
213         p.x += dx;
214         p.y += dy;
215     }
216
217 }
218
Popular Tags