Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
df0b8ff4 BH |
2 | * Copyright (c) 2005, 2006 IBM Corporation and others. |
3 | * Copyright (c) 2011, 2012 Ericsson. | |
abbdd66a | 4 | * |
73005152 BH |
5 | * All rights reserved. This program and the accompanying materials |
6 | * are made available under the terms of the Eclipse Public License v1.0 | |
7 | * which accompanies this distribution, and is available at | |
8 | * http://www.eclipse.org/legal/epl-v10.html | |
abbdd66a AM |
9 | * |
10 | * Contributors: | |
73005152 BH |
11 | * IBM - Initial API and implementation |
12 | * Bernd Hufmann - Updated for TMF | |
13 | **********************************************************************/ | |
14 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; | |
15 | ||
3bd46eef | 16 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
73005152 BH |
17 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor; |
18 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC; | |
19 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage; | |
df0b8ff4 | 20 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences; |
3145ec83 | 21 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; |
73005152 BH |
22 | |
23 | /** | |
24 | * ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on | |
df0b8ff4 | 25 | * which you can customize fill and/or. |
abbdd66a | 26 | * |
73005152 | 27 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details |
abbdd66a | 28 | * @version 1.0 |
73005152 | 29 | * @author sveyrier |
abbdd66a | 30 | * |
73005152 BH |
31 | */ |
32 | public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange { | |
33 | ||
df0b8ff4 BH |
34 | // ------------------------------------------------------------------------ |
35 | // Attributes | |
36 | // ------------------------------------------------------------------------ | |
37 | /** | |
abbdd66a | 38 | * Set the red, green and blue value of the optional color to be used for filling the execution occurrence. |
df0b8ff4 | 39 | */ |
eb63f5ff | 40 | protected int[] fFillRGB; |
df0b8ff4 BH |
41 | /** |
42 | * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence | |
43 | */ | |
eb63f5ff | 44 | protected int[] fStrokeRGB; |
df0b8ff4 BH |
45 | /** |
46 | * The occurrence image. | |
47 | */ | |
eb63f5ff | 48 | protected IImage fImage; |
df0b8ff4 BH |
49 | /** |
50 | * The top ellipses image. | |
51 | */ | |
eb63f5ff | 52 | protected IImage fEllipsesImage; |
df0b8ff4 | 53 | /** |
abbdd66a | 54 | * The start time stamp. |
df0b8ff4 | 55 | */ |
eb63f5ff | 56 | protected ITmfTimestamp fStartTime; |
df0b8ff4 BH |
57 | /** |
58 | * The end time stamp; | |
59 | */ | |
eb63f5ff | 60 | protected ITmfTimestamp fEndTime; |
df0b8ff4 | 61 | /** |
abbdd66a | 62 | * Flag to indicate whether time information is available or not. |
df0b8ff4 | 63 | */ |
eb63f5ff | 64 | protected boolean fHasTimeInfo; |
73005152 | 65 | |
df0b8ff4 BH |
66 | // ------------------------------------------------------------------------ |
67 | // Methods | |
68 | // ------------------------------------------------------------------------ | |
69 | /* | |
70 | * (non-Javadoc) | |
71 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline) | |
73005152 BH |
72 | */ |
73 | @Override | |
74 | public void setLifeline(Lifeline theLifeline) { | |
75 | super.setLifeline(theLifeline); | |
eb63f5ff BH |
76 | if (fLifeline != null && fHasTimeInfo) { |
77 | fLifeline.fHasTimeInfo = true; | |
78 | if (fLifeline.getFrame() != null) { | |
79 | fLifeline.getFrame().setHasTimeInfo(true); | |
73005152 BH |
80 | } |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
df0b8ff4 | 85 | * Set the red, green and blue value of the optional color to be used for filling the execution occurrence. |
abbdd66a | 86 | * |
eb63f5ff BH |
87 | * @param red A value for red. |
88 | * @param green A green value for green. | |
89 | * @param blue A value blue. | |
90 | */ | |
91 | public void setFillColor(int red, int green, int blue) { | |
92 | fFillRGB = new int[3]; | |
93 | fFillRGB[0] = red; | |
94 | fFillRGB[1] = green; | |
95 | fFillRGB[2] = blue; | |
73005152 BH |
96 | } |
97 | ||
98 | /** | |
99 | * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence | |
abbdd66a | 100 | * |
eb63f5ff BH |
101 | * @param red A value for red. |
102 | * @param green A green value for green. | |
103 | * @param blue A value blue. | |
104 | */ | |
105 | public void setStrokeColor(int red, int green, int blue) { | |
106 | fStrokeRGB = new int[3]; | |
107 | fStrokeRGB[0] = red; | |
108 | fStrokeRGB[1] = green; | |
109 | fStrokeRGB[2] = blue; | |
73005152 BH |
110 | } |
111 | ||
df0b8ff4 BH |
112 | /** |
113 | * Set the corresponding image. | |
abbdd66a | 114 | * |
eb63f5ff | 115 | * @param image A image to set. |
df0b8ff4 | 116 | */ |
eb63f5ff BH |
117 | public void setImage(IImage image) { |
118 | fImage = image; | |
73005152 BH |
119 | } |
120 | ||
df0b8ff4 BH |
121 | /** |
122 | * Set the top ellipses image. | |
abbdd66a | 123 | * |
eb63f5ff | 124 | * @param image A image to set. |
df0b8ff4 | 125 | */ |
eb63f5ff BH |
126 | public void setTopEllipsesImage(IImage image) { |
127 | fEllipsesImage = image; | |
73005152 BH |
128 | } |
129 | ||
130 | /** | |
df0b8ff4 | 131 | * Set the time when the execution occurrence starts. |
abbdd66a | 132 | * |
73005152 | 133 | * @param time the time when the execution occurrence starts |
3bd46eef | 134 | * @since 2.0 |
73005152 | 135 | */ |
d7dbf09a | 136 | public void setStartTime(ITmfTimestamp time) { |
4593bd5b | 137 | fStartTime = time; |
eb63f5ff BH |
138 | fHasTimeInfo = true; |
139 | if (fLifeline != null) { | |
140 | fLifeline.setTimeInfo(true); | |
73005152 BH |
141 | } |
142 | } | |
143 | ||
144 | /** | |
df0b8ff4 | 145 | * Set the time when the execution occurrence ends. |
abbdd66a | 146 | * |
73005152 | 147 | * @param time the time when the execution occurrence ends |
3bd46eef | 148 | * @since 2.0 |
73005152 | 149 | */ |
d7dbf09a | 150 | public void setEndTime(ITmfTimestamp time) { |
4593bd5b | 151 | fEndTime = time; |
eb63f5ff BH |
152 | fHasTimeInfo = true; |
153 | if (fLifeline != null) { | |
154 | fLifeline.setTimeInfo(true); | |
73005152 BH |
155 | } |
156 | } | |
157 | ||
3bd46eef AM |
158 | /** |
159 | * @since 2.0 | |
73005152 BH |
160 | */ |
161 | @Override | |
4df4581d | 162 | public ITmfTimestamp getStartTime() { |
eb63f5ff | 163 | return fStartTime; |
73005152 BH |
164 | } |
165 | ||
3bd46eef AM |
166 | /** |
167 | * @since 2.0 | |
73005152 BH |
168 | */ |
169 | @Override | |
4df4581d | 170 | public ITmfTimestamp getEndTime() { |
eb63f5ff | 171 | return fEndTime; |
73005152 BH |
172 | } |
173 | ||
df0b8ff4 BH |
174 | /* |
175 | * (non-Javadoc) | |
176 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo() | |
177 | */ | |
73005152 BH |
178 | @Override |
179 | public boolean hasTimeInfo() { | |
eb63f5ff | 180 | return fHasTimeInfo; |
73005152 BH |
181 | } |
182 | ||
df0b8ff4 BH |
183 | /* |
184 | * (non-Javadoc) | |
185 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
186 | */ | |
73005152 BH |
187 | @Override |
188 | public void draw(IGC context) { | |
189 | super.draw(context); | |
190 | int x = getX(); | |
191 | int y = getY(); | |
192 | int width = getWidth(); | |
193 | int height = getHeight(); | |
eb63f5ff BH |
194 | if (fImage != null) { |
195 | context.drawImage(fImage, x + width - 4, y + height - 11, 8, 11); | |
73005152 | 196 | } |
eb63f5ff BH |
197 | if (fEllipsesImage != null) { |
198 | context.drawImage(fEllipsesImage, x + width, y, 40, 10); | |
73005152 BH |
199 | } |
200 | } | |
201 | ||
df0b8ff4 BH |
202 | /* |
203 | * (non-Javadoc) | |
204 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedFillColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
73005152 BH |
205 | */ |
206 | @Override | |
207 | protected IColor setUnselectedFillColor(IGC context) { | |
3145ec83 | 208 | ISDPreferences pref = SDViewPref.getInstance(); |
eb63f5ff BH |
209 | if (fFillRGB != null) { |
210 | IColor tempFillColor = context.createColor(fFillRGB[0], fFillRGB[1], fFillRGB[2]); | |
3145ec83 | 211 | if (pref.useGradienColor()) { |
73005152 | 212 | context.setGradientColor(tempFillColor); |
3145ec83 BH |
213 | context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_EXEC)); |
214 | context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME)); | |
df0b8ff4 | 215 | } else { |
73005152 | 216 | context.setBackground(tempFillColor); |
df0b8ff4 | 217 | } |
73005152 | 218 | return tempFillColor; |
73005152 | 219 | } |
abbdd66a | 220 | return super.setUnselectedFillColor(context); |
73005152 BH |
221 | } |
222 | ||
df0b8ff4 BH |
223 | /* |
224 | * (non-Javadoc) | |
225 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedStrokeColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
73005152 BH |
226 | */ |
227 | @Override | |
228 | protected IColor setUnselectedStrokeColor(IGC context) { | |
eb63f5ff BH |
229 | if (fStrokeRGB != null) { |
230 | IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]); | |
73005152 BH |
231 | context.setForeground(tempStrokeColor); |
232 | return tempStrokeColor; | |
73005152 | 233 | } |
abbdd66a | 234 | return super.setUnselectedStrokeColor(context); |
73005152 BH |
235 | } |
236 | } |