Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / core / ExecutionOccurrence.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
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
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
12
13 package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core;
14
15 import java.util.Arrays;
16
17 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
18 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IColor;
19 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IGC;
20 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IImage;
21 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.preferences.ISDPreferences;
22 import org.eclipse.tracecompass.tmf.ui.views.uml2sd.preferences.SDViewPref;
23
24 /**
25 * ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
26 * which you can customize fill and/or.
27 *
28 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
29 * @version 1.0
30 * @author sveyrier
31 *
32 */
33 public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange {
34
35 // ------------------------------------------------------------------------
36 // Attributes
37 // ------------------------------------------------------------------------
38
39 /**
40 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
41 */
42 private int[] fFillRGB;
43 /**
44 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
45 */
46 private int[] fStrokeRGB;
47 /**
48 * The occurrence image.
49 */
50 private IImage fImage;
51 /**
52 * The top ellipses image.
53 */
54 private IImage fEllipsesImage;
55 /**
56 * The start time stamp.
57 */
58 private ITmfTimestamp fStartTime;
59 /**
60 * The end time stamp;
61 */
62 private ITmfTimestamp fEndTime;
63 /**
64 * Flag to indicate whether time information is available or not.
65 */
66 private boolean fHasTimeInfo;
67
68 // ------------------------------------------------------------------------
69 // Methods
70 // ------------------------------------------------------------------------
71
72 @Override
73 public void setLifeline(Lifeline theLifeline) {
74 super.setLifeline(theLifeline);
75 if (getLifeline() != null && fHasTimeInfo) {
76 getLifeline().setTimeInfo(true);
77 if (getLifeline().getFrame() != null) {
78 getLifeline().getFrame().setHasTimeInfo(true);
79 }
80 }
81 }
82
83 /**
84 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
85 *
86 * @param red A value for red.
87 * @param green A green value for green.
88 * @param blue A value blue.
89 */
90 public void setFillColor(int red, int green, int blue) {
91 fFillRGB = new int[3];
92 fFillRGB[0] = red;
93 fFillRGB[1] = green;
94 fFillRGB[2] = blue;
95 }
96
97 /**
98 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
99 *
100 * @param red A value for red.
101 * @param green A green value for green.
102 * @param blue A value blue.
103 */
104 public void setStrokeColor(int red, int green, int blue) {
105 fStrokeRGB = new int[3];
106 fStrokeRGB[0] = red;
107 fStrokeRGB[1] = green;
108 fStrokeRGB[2] = blue;
109 }
110
111 /**
112 * Set the corresponding image.
113 *
114 * @param image A image to set.
115 */
116 public void setImage(IImage image) {
117 fImage = image;
118 }
119
120 /**
121 * Set the top ellipses image.
122 *
123 * @param image A image to set.
124 */
125 public void setTopEllipsesImage(IImage image) {
126 fEllipsesImage = image;
127 }
128
129 /**
130 * Set the time when the execution occurrence starts.
131 *
132 * @param time the time when the execution occurrence starts
133 */
134 public void setStartTime(ITmfTimestamp time) {
135 fStartTime = time;
136 fHasTimeInfo = true;
137 if (getLifeline() != null) {
138 getLifeline().setTimeInfo(true);
139 }
140 }
141
142 /**
143 * Set the time when the execution occurrence ends.
144 *
145 * @param time the time when the execution occurrence ends
146 */
147 public void setEndTime(ITmfTimestamp time) {
148 fEndTime = time;
149 fHasTimeInfo = true;
150 if (getLifeline() != null) {
151 getLifeline().setTimeInfo(true);
152 }
153 }
154
155 @Override
156 public ITmfTimestamp getStartTime() {
157 return fStartTime;
158 }
159
160 @Override
161 public ITmfTimestamp getEndTime() {
162 return fEndTime;
163 }
164
165 @Override
166 public boolean hasTimeInfo() {
167 return fHasTimeInfo;
168 }
169
170 /**
171 * @return the RGB of the occurrence filler.
172 */
173 public int[] getFillRGB() {
174 if (fFillRGB == null) {
175 return null;
176 }
177 return Arrays.copyOf(fFillRGB, fFillRGB.length);
178 }
179
180 /**
181 * @return the RGB of the occurrence filler.
182 */
183 public int[] getStrokeRGB() {
184 if (fStrokeRGB == null) {
185 return null;
186 }
187 return Arrays.copyOf(fStrokeRGB, fStrokeRGB.length);
188 }
189
190 /**
191 * @return the image.
192 */
193 protected IImage getImage() {
194 return fImage;
195 }
196
197 /**
198 * @return the image.
199 */
200 protected IImage getEllipsesImage() {
201 return fEllipsesImage;
202 }
203
204 @Override
205 public void draw(IGC context) {
206 super.draw(context);
207 int x = getX();
208 int y = getY();
209 int width = getWidth();
210 int height = getHeight();
211 if (fImage != null) {
212 context.drawImage(fImage, x + width - 4, y + height - 11, 8, 11);
213 }
214 if (fEllipsesImage != null) {
215 context.drawImage(fEllipsesImage, x + width, y, 40, 10);
216 }
217 }
218
219 @Override
220 protected IColor setUnselectedFillColor(IGC context) {
221 ISDPreferences pref = SDViewPref.getInstance();
222 if (fFillRGB != null) {
223 IColor tempFillColor = context.createColor(fFillRGB[0], fFillRGB[1], fFillRGB[2]);
224 if (pref.useGradienColor()) {
225 context.setGradientColor(tempFillColor);
226 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_EXEC));
227 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
228 } else {
229 context.setBackground(tempFillColor);
230 }
231 return tempFillColor;
232 }
233 return super.setUnselectedFillColor(context);
234 }
235
236 @Override
237 protected IColor setUnselectedStrokeColor(IGC context) {
238 if (fStrokeRGB != null) {
239 IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]);
240 context.setForeground(tempStrokeColor);
241 return tempStrokeColor;
242 }
243 return super.setUnselectedStrokeColor(context);
244 }
245
246 /**
247 * Sets the flag whether the frame has time info or not'
248 *
249 * @param hasTimeInfo
250 * true if frame has time info else false
251 */
252 public void setHasTimeInfo(boolean hasTimeInfo) {
253 fHasTimeInfo = hasTimeInfo;
254 }
255 }
This page took 0.038322 seconds and 6 git commands to generate.