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