tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / ExecutionOccurrence.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2013 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.linuxtools.tmf.ui.views.uml2sd.core;
14
15 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
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;
19 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
20 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
21
22 /**
23 * ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
24 * which you can customize fill and/or.
25 *
26 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
27 * @version 1.0
28 * @author sveyrier
29 *
30 */
31 public class ExecutionOccurrence extends BasicExecutionOccurrence implements ITimeRange {
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36
37 /**
38 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
39 */
40 protected int[] fFillRGB;
41 /**
42 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
43 */
44 protected int[] fStrokeRGB;
45 /**
46 * The occurrence image.
47 */
48 protected IImage fImage;
49 /**
50 * The top ellipses image.
51 */
52 protected IImage fEllipsesImage;
53 /**
54 * The start time stamp.
55 */
56 protected ITmfTimestamp fStartTime;
57 /**
58 * The end time stamp;
59 */
60 protected ITmfTimestamp fEndTime;
61 /**
62 * Flag to indicate whether time information is available or not.
63 */
64 protected boolean fHasTimeInfo;
65
66 // ------------------------------------------------------------------------
67 // Methods
68 // ------------------------------------------------------------------------
69
70 @Override
71 public void setLifeline(Lifeline theLifeline) {
72 super.setLifeline(theLifeline);
73 if (fLifeline != null && fHasTimeInfo) {
74 fLifeline.fHasTimeInfo = true;
75 if (fLifeline.getFrame() != null) {
76 fLifeline.getFrame().setHasTimeInfo(true);
77 }
78 }
79 }
80
81 /**
82 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
83 *
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;
93 }
94
95 /**
96 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
97 *
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;
107 }
108
109 /**
110 * Set the corresponding image.
111 *
112 * @param image A image to set.
113 */
114 public void setImage(IImage image) {
115 fImage = image;
116 }
117
118 /**
119 * Set the top ellipses image.
120 *
121 * @param image A image to set.
122 */
123 public void setTopEllipsesImage(IImage image) {
124 fEllipsesImage = image;
125 }
126
127 /**
128 * Set the time when the execution occurrence starts.
129 *
130 * @param time the time when the execution occurrence starts
131 * @since 2.0
132 */
133 public void setStartTime(ITmfTimestamp time) {
134 fStartTime = time;
135 fHasTimeInfo = true;
136 if (fLifeline != null) {
137 fLifeline.setTimeInfo(true);
138 }
139 }
140
141 /**
142 * Set the time when the execution occurrence ends.
143 *
144 * @param time the time when the execution occurrence ends
145 * @since 2.0
146 */
147 public void setEndTime(ITmfTimestamp time) {
148 fEndTime = time;
149 fHasTimeInfo = true;
150 if (fLifeline != null) {
151 fLifeline.setTimeInfo(true);
152 }
153 }
154
155 /**
156 * @since 2.0
157 */
158 @Override
159 public ITmfTimestamp getStartTime() {
160 return fStartTime;
161 }
162
163 /**
164 * @since 2.0
165 */
166 @Override
167 public ITmfTimestamp getEndTime() {
168 return fEndTime;
169 }
170
171 @Override
172 public boolean hasTimeInfo() {
173 return fHasTimeInfo;
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();
183 if (fImage != null) {
184 context.drawImage(fImage, x + width - 4, y + height - 11, 8, 11);
185 }
186 if (fEllipsesImage != null) {
187 context.drawImage(fEllipsesImage, x + width, y, 40, 10);
188 }
189 }
190
191 @Override
192 protected IColor setUnselectedFillColor(IGC context) {
193 ISDPreferences pref = SDViewPref.getInstance();
194 if (fFillRGB != null) {
195 IColor tempFillColor = context.createColor(fFillRGB[0], fFillRGB[1], fFillRGB[2]);
196 if (pref.useGradienColor()) {
197 context.setGradientColor(tempFillColor);
198 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_EXEC));
199 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
200 } else {
201 context.setBackground(tempFillColor);
202 }
203 return tempFillColor;
204 }
205 return super.setUnselectedFillColor(context);
206 }
207
208 @Override
209 protected IColor setUnselectedStrokeColor(IGC context) {
210 if (fStrokeRGB != null) {
211 IColor tempStrokeColor = context.createColor(fStrokeRGB[0], fStrokeRGB[1], fStrokeRGB[2]);
212 context.setForeground(tempStrokeColor);
213 return tempStrokeColor;
214 }
215 return super.setUnselectedStrokeColor(context);
216 }
217 }
This page took 0.036707 seconds and 6 git commands to generate.