Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FigInitialState |
|
| 1.2352941176470589;1.235 |
1 | /* $Id: FigInitialState.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 | * Michiel van der Wulp | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2009 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.uml.diagram.state.ui; | |
40 | ||
41 | import java.awt.Color; | |
42 | import java.awt.Rectangle; | |
43 | import java.awt.event.MouseEvent; | |
44 | import java.util.Collection; | |
45 | import java.util.Iterator; | |
46 | import java.util.List; | |
47 | ||
48 | import org.argouml.model.Model; | |
49 | import org.argouml.uml.diagram.DiagramSettings; | |
50 | import org.argouml.uml.diagram.activity.ui.SelectionActionState; | |
51 | import org.tigris.gef.base.Selection; | |
52 | import org.tigris.gef.presentation.Fig; | |
53 | import org.tigris.gef.presentation.FigCircle; | |
54 | ||
55 | /** | |
56 | * Class to display graphics for a UML Initial State in a diagram. | |
57 | * | |
58 | * @author abonner | |
59 | */ | |
60 | public class FigInitialState extends FigStateVertex { | |
61 | ||
62 | private static final int X = X0; | |
63 | private static final int Y = Y0; | |
64 | private static final int STATE_WIDTH = 16; | |
65 | private static final int HEIGHT = 16; | |
66 | ||
67 | private FigCircle head; | |
68 | ||
69 | ||
70 | /** | |
71 | * Construct a new FigSubactivityState. | |
72 | * | |
73 | * @param owner owning UML element | |
74 | * @param bounds position and size | |
75 | * @param settings rendering settings | |
76 | */ | |
77 | public FigInitialState(Object owner, Rectangle bounds, | |
78 | DiagramSettings settings) { | |
79 | 0 | super(owner, bounds, settings); |
80 | 0 | initFigs(); |
81 | 0 | } |
82 | ||
83 | @Override | |
84 | protected Fig createBigPortFig() { | |
85 | 0 | return |
86 | new FigCircle(X, Y, STATE_WIDTH, HEIGHT, DEBUG_COLOR, DEBUG_COLOR); | |
87 | } | |
88 | ||
89 | private void initFigs() { | |
90 | 0 | setEditable(false); |
91 | ||
92 | 0 | head = new FigCircle(X, Y, STATE_WIDTH, HEIGHT, LINE_COLOR, |
93 | SOLID_FILL_COLOR); | |
94 | ||
95 | // add Figs to the FigNode in back-to-front order | |
96 | 0 | addFig(getBigPort()); |
97 | 0 | addFig(head); |
98 | ||
99 | 0 | setBlinkPorts(false); //make port invisible unless mouse enters |
100 | 0 | } |
101 | ||
102 | @Override | |
103 | public Object clone() { | |
104 | 0 | FigInitialState figClone = (FigInitialState) super.clone(); |
105 | 0 | Iterator it = figClone.getFigs().iterator(); |
106 | 0 | setBigPort((FigCircle) it.next()); |
107 | 0 | figClone.head = (FigCircle) it.next(); |
108 | 0 | return figClone; |
109 | } | |
110 | ||
111 | /* | |
112 | * @see org.tigris.gef.presentation.Fig#makeSelection() | |
113 | */ | |
114 | @Override | |
115 | public Selection makeSelection() { | |
116 | 0 | Object pstate = getOwner(); |
117 | 0 | Selection sel = null; |
118 | 0 | if ( pstate != null) { |
119 | 0 | if (Model.getFacade().isAActivityGraph( |
120 | Model.getFacade().getStateMachine( | |
121 | Model.getFacade().getContainer(pstate)))) { | |
122 | 0 | sel = new SelectionActionState(this); |
123 | 0 | ((SelectionActionState) sel).setIncomingButtonEnabled(false); |
124 | 0 | Collection outs = Model.getFacade().getOutgoings(getOwner()); |
125 | 0 | ((SelectionActionState) sel) |
126 | .setOutgoingButtonEnabled(outs.isEmpty()); | |
127 | 0 | } else { |
128 | 0 | sel = new SelectionState(this); |
129 | 0 | ((SelectionState) sel).setIncomingButtonEnabled(false); |
130 | 0 | Collection outs = Model.getFacade().getOutgoings(getOwner()); |
131 | 0 | ((SelectionState) sel) |
132 | .setOutgoingButtonEnabled(outs.isEmpty()); | |
133 | } | |
134 | } | |
135 | 0 | return sel; |
136 | } | |
137 | ||
138 | /** | |
139 | * Initial states are fixed size. | |
140 | * | |
141 | * @return false | |
142 | */ | |
143 | @Override | |
144 | public boolean isResizable() { | |
145 | 0 | return false; |
146 | } | |
147 | ||
148 | /* | |
149 | * @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color) | |
150 | */ | |
151 | @Override | |
152 | public void setLineColor(Color col) { | |
153 | 0 | head.setLineColor(col); |
154 | 0 | } |
155 | ||
156 | /* | |
157 | * @see org.tigris.gef.presentation.Fig#getLineColor() | |
158 | */ | |
159 | @Override | |
160 | public Color getLineColor() { | |
161 | 0 | return head.getLineColor(); |
162 | } | |
163 | ||
164 | /* | |
165 | * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color) | |
166 | */ | |
167 | @Override | |
168 | public void setFillColor(Color col) { | |
169 | 0 | head.setFillColor(col); |
170 | 0 | } |
171 | ||
172 | /* | |
173 | * @see org.tigris.gef.presentation.Fig#getFillColor() | |
174 | */ | |
175 | @Override | |
176 | public Color getFillColor() { | |
177 | 0 | return head.getFillColor(); |
178 | } | |
179 | ||
180 | /** | |
181 | * Ignored - figure has fixed rendering | |
182 | * @param f ignored | |
183 | */ | |
184 | @Override | |
185 | public void setFilled(boolean f) { | |
186 | // ignored - rendering is fixed | |
187 | 0 | } |
188 | ||
189 | ||
190 | @Override | |
191 | public boolean isFilled() { | |
192 | 0 | return true; |
193 | } | |
194 | ||
195 | /* | |
196 | * @see org.tigris.gef.presentation.Fig#setLineWidth(int) | |
197 | */ | |
198 | @Override | |
199 | public void setLineWidth(int w) { | |
200 | 0 | head.setLineWidth(w); |
201 | 0 | } |
202 | ||
203 | /* | |
204 | * @see org.tigris.gef.presentation.Fig#getLineWidth() | |
205 | */ | |
206 | @Override | |
207 | public int getLineWidth() { | |
208 | 0 | return head.getLineWidth(); |
209 | } | |
210 | ||
211 | /* | |
212 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) | |
213 | */ | |
214 | @Override | |
215 | public void mouseClicked(MouseEvent me) { | |
216 | // ignore mouse clicks | |
217 | 0 | } |
218 | ||
219 | /** | |
220 | * The UID. | |
221 | */ | |
222 | static final long serialVersionUID = 6572261327347541373L; | |
223 | ||
224 | /** | |
225 | * Return a list of gravity points around the outer circle. Used in place of | |
226 | * the default bounding box. | |
227 | * | |
228 | * {@inheritDoc} | |
229 | */ | |
230 | @Override | |
231 | public List getGravityPoints() { | |
232 | 0 | return getCircleGravityPoints(); |
233 | } | |
234 | ||
235 | /** | |
236 | * Override setBounds to keep shapes looking right. | |
237 | * {@inheritDoc} | |
238 | */ | |
239 | @Override | |
240 | protected void setStandardBounds(int x, int y, int w, int h) { | |
241 | 0 | if (getNameFig() == null) { |
242 | 0 | return; |
243 | } | |
244 | 0 | Rectangle oldBounds = getBounds(); |
245 | ||
246 | ||
247 | 0 | getBigPort().setBounds(x, y, w, h); |
248 | 0 | head.setBounds(x, y, w, h); |
249 | 0 | calcBounds(); //_x = x; _y = y; _w = w; _h = h; |
250 | 0 | updateEdges(); |
251 | 0 | firePropChange("bounds", oldBounds, getBounds()); |
252 | 0 | } |
253 | } |