Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FigPool |
|
| 1.2307692307692308;1.231 |
1 | /* $Id: FigPool.java 18728 2010-09-10 09:29:47Z mvw $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009-2010 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * bobtarling | |
11 | * Michiel van der Wulp | |
12 | ***************************************************************************** | |
13 | * | |
14 | * Some portions of this file was previously release using the BSD License: | |
15 | */ | |
16 | ||
17 | // Copyright (c) 2003-2009 The Regents of the University of California. All | |
18 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
19 | // software and its documentation without fee, and without a written | |
20 | // agreement is hereby granted, provided that the above copyright notice | |
21 | // and this paragraph appear in all copies. This software program and | |
22 | // documentation are copyrighted by The Regents of the University of | |
23 | // California. The software program and documentation are supplied "AS | |
24 | // IS", without any accompanying services from The Regents. The Regents | |
25 | // does not warrant that the operation of the program will be | |
26 | // uninterrupted or error-free. The end-user understands that the program | |
27 | // was developed for research purposes and is advised not to rely | |
28 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
29 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
30 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
31 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
32 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
33 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
34 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
35 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
36 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
37 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
38 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
39 | ||
40 | package org.argouml.uml.diagram.activity.ui; | |
41 | ||
42 | import java.awt.Color; | |
43 | import java.awt.Dimension; | |
44 | import java.awt.Rectangle; | |
45 | import java.util.Iterator; | |
46 | ||
47 | import org.argouml.model.Model; | |
48 | import org.argouml.uml.diagram.DiagramSettings; | |
49 | import org.argouml.uml.diagram.ui.FigEmptyRect; | |
50 | import org.argouml.uml.diagram.ui.FigNodeModelElement; | |
51 | import org.argouml.uml.diagram.ui.FigStereotypesGroup; | |
52 | import org.tigris.gef.presentation.Fig; | |
53 | import org.tigris.gef.presentation.FigRect; | |
54 | ||
55 | /** | |
56 | * This class represents a Pool of Swimlanes for Activity diagrams. This is | |
57 | * exists only to act as the GEF style encloser. Other nodes in the same | |
58 | * must be placed entirely within or outside the boundaries of this Fig | |
59 | * but cannot intersect with the boundary. <p> | |
60 | * TODO: There is no actual model element being represented here so we are | |
61 | * inheriting a lot of behaviour from FigNodeModelElement that we don't want. | |
62 | * We require to split FigNodeModelElement to separate the code that requires | |
63 | * a model element owner. See issue ... <p> | |
64 | * Remark mvw: Why not give it an owner instead? The ActivityGraph | |
65 | * is the obvious candidate, or maybe the top state. | |
66 | * | |
67 | * @author mkl | |
68 | */ | |
69 | public class FigPool extends FigNodeModelElement { | |
70 | ||
71 | private void initialize(Rectangle r) { | |
72 | /* TODO: Replace the next deprecated call. This case is complicated | |
73 | * by the use of parameters. All other Figs work differently. */ | |
74 | 0 | setBigPort(new FigEmptyRect(r.x, r.y, r.width, r.height)); |
75 | 0 | getBigPort().setFilled(false); |
76 | 0 | getBigPort().setLineWidth(0); |
77 | ||
78 | 0 | addFig(getBigPort()); |
79 | ||
80 | 0 | setBounds(r); |
81 | 0 | } |
82 | ||
83 | /** | |
84 | * Constructor used by PGML parser when loading. | |
85 | * | |
86 | * @param bounds bounding box rectangle | |
87 | * @param settings (ignored since this is just an empty rectangle) | |
88 | */ | |
89 | public FigPool(Rectangle bounds, DiagramSettings settings) { | |
90 | 0 | super(null, bounds, settings); |
91 | 0 | initialize(bounds); |
92 | 0 | } |
93 | ||
94 | ||
95 | /** | |
96 | * Create the Fig containing the stereotype(s). As there is no stereotype | |
97 | * display for this Fig we return null | |
98 | * | |
99 | * @return the stereotype FigGroup | |
100 | */ | |
101 | protected FigStereotypesGroup createStereotypeFig() { | |
102 | 0 | return null; |
103 | } | |
104 | ||
105 | /* | |
106 | * @see org.argouml.uml.diagram.ui.FigNodeModelElement#clone() | |
107 | */ | |
108 | @Override | |
109 | public Object clone() { | |
110 | 0 | FigPool figClone = (FigPool) super.clone(); |
111 | 0 | Iterator it = figClone.getFigs().iterator(); |
112 | 0 | figClone.setBigPort((FigRect) it.next()); |
113 | 0 | return figClone; |
114 | } | |
115 | ||
116 | /* | |
117 | * @see org.argouml.uml.diagram.ui.FigNodeModelElement#addEnclosedFig(org.tigris.gef.presentation.Fig) | |
118 | */ | |
119 | @Override | |
120 | public void addEnclosedFig(Fig figState) { | |
121 | 0 | super.addEnclosedFig(figState); |
122 | 0 | Iterator it = getLayer().getContentsNoEdges().iterator(); |
123 | 0 | while (it.hasNext()) { |
124 | 0 | Fig f = (Fig) it.next(); |
125 | 0 | if (f instanceof FigPartition |
126 | && f.getBounds().intersects(figState.getBounds())) { | |
127 | 0 | Model.getCoreHelper().setModelElementContainer( |
128 | figState.getOwner(), f.getOwner()); | |
129 | } | |
130 | 0 | } |
131 | 0 | } |
132 | ||
133 | /* | |
134 | * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color) | |
135 | */ | |
136 | @Override | |
137 | public void setFillColor(Color col) { | |
138 | 0 | getBigPort().setFillColor(col); |
139 | 0 | getNameFig().setFillColor(col); |
140 | 0 | } |
141 | ||
142 | /* | |
143 | * @see org.tigris.gef.presentation.Fig#getFillColor() | |
144 | */ | |
145 | @Override | |
146 | public Color getFillColor() { | |
147 | 0 | return getBigPort().getFillColor(); |
148 | } | |
149 | ||
150 | /* | |
151 | * @see org.tigris.gef.presentation.Fig#setFilled(boolean) | |
152 | */ | |
153 | @Override | |
154 | public void setFilled(boolean f) { | |
155 | 0 | getBigPort().setFilled(f); |
156 | 0 | } |
157 | ||
158 | @Override | |
159 | public boolean isFilled() { | |
160 | 0 | return getBigPort().isFilled(); |
161 | } | |
162 | ||
163 | /* | |
164 | * @see org.tigris.gef.presentation.Fig#getMinimumSize() | |
165 | */ | |
166 | @Override | |
167 | public Dimension getMinimumSize() { | |
168 | 0 | Dimension nameDim = getNameFig().getMinimumSize(); |
169 | 0 | int w = nameDim.width; |
170 | 0 | int h = nameDim.height; |
171 | ||
172 | // we want to maintain a minimum size for the partition | |
173 | 0 | w = Math.max(64, w); |
174 | 0 | h = Math.max(256, h); |
175 | ||
176 | 0 | return new Dimension(w, h); |
177 | } | |
178 | ||
179 | /** | |
180 | * Using a traprect enables us to move containing figs easily. | |
181 | * | |
182 | * @return <code>true</code> | |
183 | * | |
184 | * @see org.tigris.gef.presentation.Fig#getUseTrapRect() | |
185 | */ | |
186 | @Override | |
187 | public boolean getUseTrapRect() { | |
188 | 0 | return true; |
189 | } | |
190 | ||
191 | /* | |
192 | * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int) | |
193 | */ | |
194 | @Override | |
195 | protected void setStandardBounds(int x, int y, int w, int h) { | |
196 | ||
197 | 0 | Rectangle oldBounds = getBounds(); |
198 | 0 | getBigPort().setBounds(x, y, w, h); |
199 | ||
200 | 0 | firePropChange("bounds", oldBounds, getBounds()); |
201 | 0 | calcBounds(); //_x = x; _y = y; _w = w; _h = h; |
202 | 0 | } |
203 | ||
204 | /** | |
205 | * A FigPool can't be selected. Instead it is dragged or resized whenever | |
206 | * one of its swimlanes is dragged or resized. | |
207 | * @return false at all times | |
208 | */ | |
209 | @Override | |
210 | public boolean isSelectable() { | |
211 | 0 | return false; |
212 | } | |
213 | ||
214 | } | |
215 |