Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FigHistoryState |
|
| 1.1176470588235294;1.118 |
1 | /* $Id: FigHistoryState.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.Iterator; | |
45 | ||
46 | import org.argouml.uml.diagram.DiagramSettings; | |
47 | import org.tigris.gef.presentation.Fig; | |
48 | import org.tigris.gef.presentation.FigCircle; | |
49 | import org.tigris.gef.presentation.FigText; | |
50 | ||
51 | /** | |
52 | * Class to display graphics for a UML HistoryState in a diagram. | |
53 | * | |
54 | * This abstract class is used for both a DeepHistory and a ShallowHistory. | |
55 | * | |
56 | * @author jrobbins | |
57 | */ | |
58 | public abstract class FigHistoryState extends FigStateVertex { | |
59 | ||
60 | private static final int X = X0; | |
61 | private static final int Y = Y0; | |
62 | private static final int WIDTH = 24; | |
63 | private static final int HEIGHT = 24; | |
64 | ||
65 | /** | |
66 | * The main label on this icon. | |
67 | */ | |
68 | private FigText h; | |
69 | private FigCircle head; | |
70 | ||
71 | ||
72 | /** | |
73 | * Construct a new FigSubactivityState. | |
74 | * | |
75 | * @param owner owning UML element | |
76 | * @param bounds position and size | |
77 | * @param settings rendering settings | |
78 | */ | |
79 | public FigHistoryState(Object owner, Rectangle bounds, | |
80 | DiagramSettings settings) { | |
81 | 0 | super(owner, bounds, settings); |
82 | 0 | initFigs(); |
83 | 0 | } |
84 | ||
85 | @Override | |
86 | protected Fig createBigPortFig() { | |
87 | 0 | return new FigCircle(X, Y, WIDTH, HEIGHT, DEBUG_COLOR, |
88 | DEBUG_COLOR); | |
89 | } | |
90 | ||
91 | private void initFigs() { | |
92 | 0 | setEditable(false); |
93 | 0 | head = new FigCircle(X, Y, WIDTH, HEIGHT, LINE_COLOR, FILL_COLOR); |
94 | 0 | h = new FigText(X, Y, WIDTH - 10, HEIGHT - 10); |
95 | 0 | h.setFont(getSettings().getFontPlain()); |
96 | 0 | h.setText(getH()); |
97 | 0 | h.setTextColor(TEXT_COLOR); |
98 | 0 | h.setFilled(false); |
99 | 0 | h.setLineWidth(0); |
100 | ||
101 | // add Figs to the FigNode in back-to-front order | |
102 | 0 | addFig(getBigPort()); |
103 | 0 | addFig(head); |
104 | 0 | addFig(h); |
105 | ||
106 | 0 | setBlinkPorts(false); //make port invisible unless mouse enters |
107 | 0 | } |
108 | ||
109 | /** | |
110 | * Override setBounds to keep shapes looking right. | |
111 | * {@inheritDoc} | |
112 | */ | |
113 | @Override | |
114 | protected void setStandardBounds(int x, int y, | |
115 | int width, int height) { | |
116 | 0 | if (getNameFig() == null) { |
117 | 0 | return; |
118 | } | |
119 | 0 | Rectangle oldBounds = getBounds(); |
120 | ||
121 | 0 | getBigPort().setBounds(x, y, WIDTH, HEIGHT); |
122 | 0 | head.setBounds(x, y, WIDTH, HEIGHT); |
123 | 0 | this.h.setBounds(x, y, WIDTH - 10, HEIGHT - 10); |
124 | 0 | this.h.calcBounds(); |
125 | ||
126 | 0 | calcBounds(); //_x = x; _y = y; _w = w; _h = h; |
127 | 0 | updateEdges(); |
128 | 0 | firePropChange("bounds", oldBounds, getBounds()); |
129 | 0 | } |
130 | ||
131 | /** | |
132 | * This should return the text shown at the center of the history state. | |
133 | * | |
134 | * @return the text at the center (H or H*) | |
135 | */ | |
136 | protected abstract String getH(); | |
137 | ||
138 | /* | |
139 | * @see org.argouml.uml.diagram.ui.FigNodeModelElement#placeString() | |
140 | */ | |
141 | @Override | |
142 | public String placeString() { | |
143 | 0 | return "H"; |
144 | } | |
145 | ||
146 | ||
147 | /* | |
148 | * @see java.lang.Object#clone() | |
149 | */ | |
150 | @Override | |
151 | public Object clone() { | |
152 | 0 | FigHistoryState figClone = (FigHistoryState) super.clone(); |
153 | 0 | Iterator it = figClone.getFigs().iterator(); |
154 | 0 | figClone.setBigPort((FigCircle) it.next()); |
155 | 0 | figClone.head = (FigCircle) it.next(); |
156 | 0 | figClone.h = (FigText) it.next(); |
157 | 0 | return figClone; |
158 | } | |
159 | ||
160 | ||
161 | /** | |
162 | * History states are fixed size. | |
163 | * @return false | |
164 | */ | |
165 | @Override | |
166 | public boolean isResizable() { | |
167 | 0 | return false; |
168 | } | |
169 | ||
170 | /* | |
171 | * @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color) | |
172 | */ | |
173 | @Override | |
174 | public void setLineColor(Color col) { | |
175 | 0 | head.setLineColor(col); |
176 | 0 | } |
177 | ||
178 | /* | |
179 | * @see org.tigris.gef.presentation.Fig#getLineColor() | |
180 | */ | |
181 | @Override | |
182 | public Color getLineColor() { | |
183 | 0 | return head.getLineColor(); |
184 | } | |
185 | ||
186 | /* | |
187 | * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color) | |
188 | */ | |
189 | @Override | |
190 | public void setFillColor(Color col) { | |
191 | 0 | head.setFillColor(col); |
192 | 0 | } |
193 | ||
194 | /* | |
195 | * @see org.tigris.gef.presentation.Fig#getFillColor() | |
196 | */ | |
197 | @Override | |
198 | public Color getFillColor() { | |
199 | 0 | return head.getFillColor(); |
200 | } | |
201 | ||
202 | /** | |
203 | * Ignored - figure has fixed rendering | |
204 | * @param f ignored | |
205 | */ | |
206 | @Override | |
207 | public void setFilled(boolean f) { | |
208 | // ignored | |
209 | 0 | } |
210 | ||
211 | @Override | |
212 | public boolean isFilled() { | |
213 | 0 | return true; |
214 | } | |
215 | ||
216 | /* | |
217 | * @see org.tigris.gef.presentation.Fig#setLineWidth(int) | |
218 | */ | |
219 | @Override | |
220 | public void setLineWidth(int w) { | |
221 | 0 | head.setLineWidth(w); |
222 | 0 | } |
223 | ||
224 | /* | |
225 | * @see org.tigris.gef.presentation.Fig#getLineWidth() | |
226 | */ | |
227 | @Override | |
228 | public int getLineWidth() { | |
229 | 0 | return head.getLineWidth(); |
230 | } | |
231 | ||
232 | ||
233 | /* | |
234 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) | |
235 | */ | |
236 | @Override | |
237 | public void mouseClicked(MouseEvent me) { | |
238 | // ignored | |
239 | 0 | } |
240 | ||
241 | /** | |
242 | * The UID. | |
243 | */ | |
244 | static final long serialVersionUID = 6572261327347541373L; | |
245 | ||
246 | } |