Java Doc and API clean up of TMF UML Sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / ExecutionOccurrence.java
1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
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
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
15
16 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
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;
20 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
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 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
38 */
39 protected int[] fillRGB;
40 /**
41 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
42 */
43 protected int[] strokeRGB;
44 /**
45 * The occurrence image.
46 */
47 protected IImage image;
48 /**
49 * The top ellipses image.
50 */
51 protected IImage ellipsesImage;
52 /**
53 * The start time stamp.
54 */
55 protected ITmfTimestamp startTime;
56 /**
57 * The end time stamp;
58 */
59 protected ITmfTimestamp endTime;
60 /**
61 * Flag to indicate whether time information is available or not.
62 */
63 protected boolean hasTime;
64
65 // ------------------------------------------------------------------------
66 // Methods
67 // ------------------------------------------------------------------------
68 /*
69 * (non-Javadoc)
70 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
71 */
72 @Override
73 public void setLifeline(Lifeline theLifeline) {
74 super.setLifeline(theLifeline);
75 if (lifeline != null && hasTime) {
76 lifeline.hasTime = true;
77 if (lifeline.getFrame() != null) {
78 lifeline.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 _r A value for red.
87 * @param _g A green value for green.
88 * @param _b A value blue.
89 */
90 public void setFillColor(int _r, int _g, int _b) {
91 fillRGB = new int[3];
92 fillRGB[0] = _r;
93 fillRGB[1] = _g;
94 fillRGB[2] = _b;
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 _r A value for red.
101 * @param _g A green value for green.
102 * @param _b A value blue.
103 */
104 public void setStrokeColor(int _r, int _g, int _b) {
105 strokeRGB = new int[3];
106 strokeRGB[0] = _r;
107 strokeRGB[1] = _g;
108 strokeRGB[2] = _b;
109 }
110
111 /**
112 * Set the corresponding image.
113 *
114 * @param image_ A image to set.
115 */
116 public void setImage(IImage image_) {
117 image = 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 ellipsesImage = 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 startTime = time.clone();
136 hasTime = true;
137 if (lifeline != null) {
138 lifeline.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 endTime = time.clone();
149 hasTime = true;
150 if (lifeline != null) {
151 lifeline.setTimeInfo(true);
152 }
153 }
154
155 /*
156 * (non-Javadoc)
157 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
158 */
159 @Override
160 public ITmfTimestamp getStartTime() {
161 return startTime;
162 }
163
164 /*
165 * (non-Javadoc)
166 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime()
167 */
168 @Override
169 public ITmfTimestamp getEndTime() {
170 return endTime;
171 }
172
173 /*
174 * (non-Javadoc)
175 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
176 */
177 @Override
178 public boolean hasTimeInfo() {
179 return hasTime;
180 }
181
182 /*
183 * (non-Javadoc)
184 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
185 */
186 @Override
187 public void draw(IGC context) {
188 super.draw(context);
189 int x = getX();
190 int y = getY();
191 int width = getWidth();
192 int height = getHeight();
193 if (image != null) {
194 context.drawImage(image, x + width - 4, y + height - 11, 8, 11);
195 }
196 if (ellipsesImage != null) {
197 context.drawImage(ellipsesImage, x + width, y, 40, 10);
198 }
199 }
200
201 /*
202 * (non-Javadoc)
203 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedFillColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
204 */
205 @Override
206 protected IColor setUnselectedFillColor(IGC context) {
207 if (fillRGB != null) {
208 IColor tempFillColor = context.createColor(fillRGB[0], fillRGB[1], fillRGB[2]);
209 if (Frame.getUserPref().useGradienColor()) {
210 context.setGradientColor(tempFillColor);
211 context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_EXEC));
212 context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_FRAME));
213 } else {
214 context.setBackground(tempFillColor);
215 }
216 return tempFillColor;
217 } else {
218 return super.setUnselectedFillColor(context);
219 }
220 }
221
222 /*
223 * (non-Javadoc)
224 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedStrokeColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
225 */
226 @Override
227 protected IColor setUnselectedStrokeColor(IGC context) {
228 if (strokeRGB != null) {
229 IColor tempStrokeColor = context.createColor(strokeRGB[0], strokeRGB[1], strokeRGB[2]);
230 context.setForeground(tempStrokeColor);
231 return tempStrokeColor;
232 } else {
233 return super.setUnselectedStrokeColor(context);
234 }
235 }
236 }
This page took 0.038012 seconds and 6 git commands to generate.