1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
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
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
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 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
24 * ExecutionOccurrence is the UML2 execution occurrence graphical representation. It is a BasicExecutionOccurrence on
25 * which you can customize fill and/or.
27 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
32 public class ExecutionOccurrence
extends BasicExecutionOccurrence
implements ITimeRange
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
38 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
40 protected int[] fFillRGB
;
42 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
44 protected int[] fStrokeRGB
;
46 * The occurrence image.
48 protected IImage fImage
;
50 * The top ellipses image.
52 protected IImage fEllipsesImage
;
54 * The start time stamp.
56 protected ITmfTimestamp fStartTime
;
60 protected ITmfTimestamp fEndTime
;
62 * Flag to indicate whether time information is available or not.
64 protected boolean fHasTimeInfo
;
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline)
74 public void setLifeline(Lifeline theLifeline
) {
75 super.setLifeline(theLifeline
);
76 if (fLifeline
!= null && fHasTimeInfo
) {
77 fLifeline
.fHasTimeInfo
= true;
78 if (fLifeline
.getFrame() != null) {
79 fLifeline
.getFrame().setHasTimeInfo(true);
85 * Set the red, green and blue value of the optional color to be used for filling the execution occurrence.
87 * @param red A value for red.
88 * @param green A green value for green.
89 * @param blue A value blue.
91 public void setFillColor(int red
, int green
, int blue
) {
92 fFillRGB
= new int[3];
99 * Set the red, green and blue value of the optional color to be used for drawing the execution occurrence
101 * @param red A value for red.
102 * @param green A green value for green.
103 * @param blue A value blue.
105 public void setStrokeColor(int red
, int green
, int blue
) {
106 fStrokeRGB
= new int[3];
108 fStrokeRGB
[1] = green
;
109 fStrokeRGB
[2] = blue
;
113 * Set the corresponding image.
115 * @param image A image to set.
117 public void setImage(IImage image
) {
122 * Set the top ellipses image.
124 * @param image A image to set.
126 public void setTopEllipsesImage(IImage image
) {
127 fEllipsesImage
= image
;
131 * Set the time when the execution occurrence starts.
133 * @param time the time when the execution occurrence starts
135 public void setStartTime(ITmfTimestamp time
) {
138 if (fLifeline
!= null) {
139 fLifeline
.setTimeInfo(true);
144 * Set the time when the execution occurrence ends.
146 * @param time the time when the execution occurrence ends
148 public void setEndTime(ITmfTimestamp time
) {
151 if (fLifeline
!= null) {
152 fLifeline
.setTimeInfo(true);
158 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime()
161 public ITmfTimestamp
getStartTime() {
167 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime()
170 public ITmfTimestamp
getEndTime() {
176 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo()
179 public boolean hasTimeInfo() {
185 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
188 public void draw(IGC context
) {
192 int width
= getWidth();
193 int height
= getHeight();
194 if (fImage
!= null) {
195 context
.drawImage(fImage
, x
+ width
- 4, y
+ height
- 11, 8, 11);
197 if (fEllipsesImage
!= null) {
198 context
.drawImage(fEllipsesImage
, x
+ width
, y
, 40, 10);
204 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedFillColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
207 protected IColor
setUnselectedFillColor(IGC context
) {
208 ISDPreferences pref
= SDViewPref
.getInstance();
209 if (fFillRGB
!= null) {
210 IColor tempFillColor
= context
.createColor(fFillRGB
[0], fFillRGB
[1], fFillRGB
[2]);
211 if (pref
.useGradienColor()) {
212 context
.setGradientColor(tempFillColor
);
213 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
214 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_FRAME
));
216 context
.setBackground(tempFillColor
);
218 return tempFillColor
;
220 return super.setUnselectedFillColor(context
);
225 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BasicExecutionOccurrence#setUnselectedStrokeColor(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
228 protected IColor
setUnselectedStrokeColor(IGC context
) {
229 if (fStrokeRGB
!= null) {
230 IColor tempStrokeColor
= context
.createColor(fStrokeRGB
[0], fStrokeRGB
[1], fStrokeRGB
[2]);
231 context
.setForeground(tempStrokeColor
);
232 return tempStrokeColor
;
234 return super.setUnselectedStrokeColor(context
);
This page took 0.03642 seconds and 6 git commands to generate.