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
.ui
.views
.uml2sd
.drawings
.IGC
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IImage
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
22 * Class to add a hot spot marker.
27 public class HotSpot
extends GraphNode
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 * The grahNode ID constant
34 public static final String GLYPH
= "Glyph"; //$NON-NLS-1$
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 * The execution occurrence the hot spot marker is for.
42 protected BasicExecutionOccurrence fExecOcc
= null;
44 * The occurrence number.
46 protected int fOccurrence
= 0;
48 * The marker image to display.
50 protected IImage fImage
= null;
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
60 fPrefId
= ISDPreferences
.PREF_EXEC
;
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
68 * Set the marker image.
70 * @param img A image to set
72 public void setImage(IImage img
) {
78 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
82 if (fExecOcc
!= null) {
83 return fExecOcc
.getX() - 3;
90 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
94 if (fExecOcc
!= null){
95 return fExecOcc
.getY();
102 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
105 public int getWidth() {
106 if (fExecOcc
!= null) {
107 return fExecOcc
.getWidth() + 7;
114 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
117 public int getHeight() {
118 if (fExecOcc
!= null) {
119 return fExecOcc
.getWidth() + 10;
125 * Set the lifeline on which the execution occurrence appears.
127 * @param occ the parent lifeline
129 public void setExecution(BasicExecutionOccurrence occ
) {
131 fExecOcc
.addNode(this);
135 * Get the lifeline on which the execution occurrence appears.
137 * @return - the parent lifeline
139 public BasicExecutionOccurrence
getExecOcc() {
144 * Returns the occurrence number.
146 * @return the occurrence number.
148 public int getOccurrence() {
153 * Set the occurrence number.
155 * @param occ A number to set.
157 public void setOccurrence(int occ
) {
163 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
166 public void draw(IGC context
) {
168 ISDPreferences pref
= SDViewPref
.getInstance();
170 // The execution occurrence is selected
171 // if the owning lifeline is selected
172 if (isSelected() || (fExecOcc
!= null && fExecOcc
.isSelected()) || (fExecOcc
!= null && fExecOcc
.getLifeline() != null && fExecOcc
.getLifeline().isSelected())) {
173 context
.setBackground(pref
.getBackGroundColorSelection());
174 context
.setForeground(pref
.getForeGroundColorSelection());
176 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_EXEC
));
177 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
179 context
.drawImage(fImage
, getX(), getY(), getWidth(), getHeight());
184 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
187 public String
getArrayId() {
193 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
196 public boolean isVisible(int x
, int y
, int width
, int height
) {
202 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
205 public boolean contains(int xValue
, int yValue
) {
208 int width
= getWidth();
209 int height
= getHeight();
211 if (GraphNode
.contains(x
, y
, width
, height
, xValue
, yValue
)) {