001 /* 002 Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public 015 License along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 USA */ 018 019 package org.objectweb.jac.ide; 020 021 import java.awt.Point; 022 import java.util.List; 023 import java.util.Vector; 024 025 /** 026 * A Link figure of a diagram. 027 * @see Diagram 028 * @see Link 029 */ 030 031 public class LinkFigure extends Figure { 032 033 public LinkFigure() { 034 } 035 036 public LinkFigure(Link link) { 037 super(link); 038 nameCorner = new Point(); 039 startRoleCorner = new Point(); 040 startCardinalityCorner = new Point(); 041 endRoleCorner = new Point(); 042 endCardinalityCorner = new Point(); 043 points.add(new Point(0,0)); 044 points.add(new Point(0,0)); 045 } 046 047 public LinkFigure(Link link, 048 Point nameCorner, 049 Point startRoleCorner, 050 Point startCardinalityCorner, 051 Point endRoleCorner, 052 Point endCardinalityCorner) { 053 super(link); 054 this.nameCorner = nameCorner; 055 this.startRoleCorner = startRoleCorner; 056 this.startCardinalityCorner = startCardinalityCorner; 057 this.endRoleCorner = endRoleCorner; 058 this.endCardinalityCorner = endCardinalityCorner; 059 points.add(new Point(0,0)); 060 points.add(new Point(0,0)); 061 } 062 063 public Link getLink() { 064 return (Link)element; 065 } 066 067 public void translateName(int dx,int dy) { 068 this.nameCorner.translate(dx,dy); 069 } 070 071 public void translateStartRole(int dx,int dy) { 072 this.startRoleCorner.translate(dx,dy); 073 } 074 075 public void translateEndRole(int dx,int dy) { 076 this.endRoleCorner.translate(dx,dy); 077 } 078 079 public void translateStartCardinality(int dx,int dy) { 080 this.startCardinalityCorner.translate(dx,dy); 081 } 082 083 public void translateEndCardinality(int dx,int dy) { 084 this.endCardinalityCorner.translate(dx,dy); 085 } 086 087 Point nameCorner = new Point(); 088 089 /** 090 * Get the value of nameCorner. 091 * @return value of nameCorner. 092 */ 093 public Point getNameCorner() { 094 return nameCorner; 095 } 096 097 /** 098 * Set the value of nameCorner. 099 * @param v Value to assign to nameCorner. 100 */ 101 public void setNameCorner(Point v) { 102 this.nameCorner = v; 103 } 104 105 Point startRoleCorner; 106 107 /** 108 * Get the value of startRoleCorner. 109 * @return value of startRoleCorner. 110 */ 111 public Point 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 v) { 120 this.startRoleCorner = v; 121 } 122 123 Point endRoleCorner; 124 125 /** 126 * Get the value of endRoleCorner. 127 * @return value of endRoleCorner. 128 */ 129 public Point 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 v) { 138 this.endRoleCorner = v; 139 } 140 141 Point startCardinalityCorner; 142 143 /** 144 * Get the value of startCardinalityCorner. 145 * @return value of startCardinalityCorner. 146 */ 147 public Point 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 v) { 156 this.startCardinalityCorner = v; 157 } 158 159 Point endCardinalityCorner; 160 161 /** 162 * Get the value of endCardinalityCorner. 163 * @return value of endCardinalityCorner. 164 */ 165 public Point 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 v) { 174 this.endCardinalityCorner = v; 175 } 176 177 List points = new Vector(); 178 179 /** 180 * Get the value of points. 181 * @return value of points. 182 */ 183 public List 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 v) { 192 this.points = v; 193 } 194 195 public int getPointCount() { 196 return points.size(); 197 } 198 199 public void addPoint(int index,Point 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 p) { 208 points.set(index,p); 209 } 210 211 public void translatePoint(int index, int dx, int dy) { 212 Point p = (Point)points.get(index); 213 p.x += dx; 214 p.y += dy; 215 } 216 217 }