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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
;
15 import java
.util
.Arrays
;
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
;
25 * ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
26 * which you can customize fill and/or.
28 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
33 public class ExecutionOccurrence
extends BasicExecutionOccurrence
implements ITimeRange
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
42 private int[] fFillRGB
;
44 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
46 private int[] fStrokeRGB
;
48 * The occurrence image.
50 private IImage fImage
;
52 * The top ellipses image.
54 private IImage fEllipsesImage
;
56 * The start time stamp.
58 private ITmfTimestamp fStartTime
;
62 private ITmfTimestamp fEndTime
;
64 * Flag to indicate whether time information is available or not.
66 private boolean fHasTimeInfo
;
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
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);
84 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
86 * @param red A value for red.
87 * @param green A green value for green.
88 * @param blue A value blue.
90 public void setFillColor(int red
, int green
, int blue
) {
91 fFillRGB
= new int[3];
98 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
100 * @param red A value for red.
101 * @param green A green value for green.
102 * @param blue A value blue.
104 public void setStrokeColor(int red
, int green
, int blue
) {
105 fStrokeRGB
= new int[3];
107 fStrokeRGB
[1] = green
;
108 fStrokeRGB
[2] = blue
;
112 * Set the corresponding image.
114 * @param image A image to set.
116 public void setImage(IImage image
) {
121 * Set the top ellipses image.
123 * @param image A image to set.
125 public void setTopEllipsesImage(IImage image
) {
126 fEllipsesImage
= image
;
130 * Set the time when the execution occurrence starts.
132 * @param time the time when the execution occurrence starts
135 public void setStartTime(ITmfTimestamp time
) {
138 if (getLifeline() != null) {
139 getLifeline().setTimeInfo(true);
144 * Set the time when the execution occurrence ends.
146 * @param time the time when the execution occurrence ends
149 public void setEndTime(ITmfTimestamp time
) {
152 if (getLifeline() != null) {
153 getLifeline().setTimeInfo(true);
161 public ITmfTimestamp
getStartTime() {
169 public ITmfTimestamp
getEndTime() {
174 public boolean hasTimeInfo() {
179 * @return the RGB of the occurrence filler.
182 public int[] getFillRGB() {
183 if (fFillRGB
== null) {
186 return Arrays
.copyOf(fFillRGB
, fFillRGB
.length
);
190 * @return the RGB of the occurrence filler.
193 public int[] getStrokeRGB() {
194 if (fStrokeRGB
== null) {
197 return Arrays
.copyOf(fStrokeRGB
, fStrokeRGB
.length
);
204 protected IImage
getImage() {
212 protected IImage
getEllipsesImage() {
213 return fEllipsesImage
;
217 public void draw(IGC context
) {
221 int width
= getWidth();
222 int height
= getHeight();
223 if (fImage
!= null) {
224 context
.drawImage(fImage
, x
+ width
- 4, y
+ height
- 11, 8, 11);
226 if (fEllipsesImage
!= null) {
227 context
.drawImage(fEllipsesImage
, x
+ width
, y
, 40, 10);
232 protected IColor
setUnselectedFillColor(IGC context
) {
233 ISDPreferences pref
= SDViewPref
.getInstance();
234 if (fFillRGB
!= null) {
235 IColor tempFillColor
= context
.createColor(fFillRGB
[0], fFillRGB
[1], fFillRGB
[2]);
236 if (pref
.useGradienColor()) {
237 context
.setGradientColor(tempFillColor
);
238 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
239 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_FRAME
));
241 context
.setBackground(tempFillColor
);
243 return tempFillColor
;
245 return super.setUnselectedFillColor(context
);
249 protected IColor
setUnselectedStrokeColor(IGC context
) {
250 if (fStrokeRGB
!= null) {
251 IColor tempStrokeColor
= context
.createColor(fStrokeRGB
[0], fStrokeRGB
[1], fStrokeRGB
[2]);
252 context
.setForeground(tempStrokeColor
);
253 return tempStrokeColor
;
255 return super.setUnselectedStrokeColor(context
);
259 * Sets the flag whether the frame has time info or not
262 * true if frame has time info else false
264 public void setHasTimeInfo(boolean hasTimeInfo
) {
265 fHasTimeInfo
= hasTimeInfo
;
This page took 0.042805 seconds and 6 git commands to generate.