1 /**********************************************************************
2 * Copyright (c) 2005, 2012 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
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
;
15 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
16 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IImage
;
17 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
21 * Class to add a hot spot marker.
26 public class HotSpot
extends GraphNode
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 * The grahNode ID constant
33 public static final String GLYPH
= "Glyph"; //$NON-NLS-1$
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 * The execution occurrence the hot spot marker is for.
41 protected BasicExecutionOccurrence fExecOcc
= null;
43 * The occurrence number.
45 protected int fOccurrence
= 0;
47 * The marker image to display.
49 protected IImage fImage
= null;
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
59 fPrefId
= ISDPreferences
.PREF_EXEC
;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * Set the marker image.
69 * @param img A image to set
71 public void setImage(IImage img
) {
77 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
81 if (fExecOcc
!= null) {
82 return fExecOcc
.getX() - 3;
89 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
93 if (fExecOcc
!= null){
94 return fExecOcc
.getY();
101 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
104 public int getWidth() {
105 if (fExecOcc
!= null) {
106 return fExecOcc
.getWidth() + 7;
113 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
116 public int getHeight() {
117 if (fExecOcc
!= null) {
118 return fExecOcc
.getWidth() + 10;
124 * Set the lifeline on which the execution occurrence appears.
126 * @param occ the parent lifeline
128 public void setExecution(BasicExecutionOccurrence occ
) {
130 fExecOcc
.addNode(this);
134 * Get the lifeline on which the execution occurrence appears.
136 * @return - the parent lifeline
138 public BasicExecutionOccurrence
getExecOcc() {
143 * Returns the occurrence number.
145 * @return the occurrence number.
147 public int getOccurrence() {
152 * Set the occurrence number.
154 * @param occ A number to set.
156 public void setOccurrence(int occ
) {
162 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
165 public void draw(IGC context
) {
167 ISDPreferences pref
= SDViewPref
.getInstance();
169 // The execution occurrence is selected
170 // if the owning lifeline is selected
171 if (isSelected() || (fExecOcc
!= null && fExecOcc
.isSelected()) || (fExecOcc
!= null && fExecOcc
.getLifeline() != null && fExecOcc
.getLifeline().isSelected())) {
172 context
.setBackground(pref
.getBackGroundColorSelection());
173 context
.setForeground(pref
.getForeGroundColorSelection());
175 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_EXEC
));
176 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
178 context
.drawImage(fImage
, getX(), getY(), getWidth(), getHeight());
183 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
186 public String
getArrayId() {
192 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#isVisible(int, int, int, int)
195 public boolean isVisible(int x
, int y
, int width
, int height
) {
201 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
204 public boolean contains(int xValue
, int yValue
) {
207 int width
= getWidth();
208 int height
= getHeight();
210 if (GraphNode
.contains(x
, y
, width
, height
, xValue
, yValue
)) {