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 org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
16 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.drawings
.IImage
;
17 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
18 import org
.eclipse
.tracecompass
.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 private BasicExecutionOccurrence fExecOcc
= null;
43 * The occurrence number.
45 private int fOccurrence
= 0;
47 * The marker image to display.
49 private IImage fImage
= null;
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
59 setColorPrefId(ISDPreferences
.PREF_EXEC
);
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * Set the marker image.
69 * @param img A image to set
71 public void setImage(IImage img
) {
76 * Returns the marker image.
80 protected IImage
getImage() {
86 if (fExecOcc
!= null) {
87 return fExecOcc
.getX() - 3;
94 if (fExecOcc
!= null){
95 return fExecOcc
.getY();
101 public int getWidth() {
102 if (fExecOcc
!= null) {
103 return fExecOcc
.getWidth() + 7;
109 public int getHeight() {
110 if (fExecOcc
!= null) {
111 return fExecOcc
.getWidth() + 10;
117 * Set the lifeline on which the execution occurrence appears.
119 * @param occ the parent lifeline
121 public void setExecution(BasicExecutionOccurrence occ
) {
123 fExecOcc
.addNode(this);
127 * Get the lifeline on which the execution occurrence appears.
129 * @return - the parent lifeline
131 public BasicExecutionOccurrence
getExecOcc() {
136 * Returns the occurrence number.
138 * @return the occurrence number.
140 public int getOccurrence() {
145 * Set the occurrence number.
147 * @param occ A number to set.
149 public void setOccurrence(int occ
) {
154 public void draw(IGC context
) {
156 ISDPreferences pref
= SDViewPref
.getInstance();
158 // The execution occurrence is selected
159 // if the owning lifeline is selected
160 if (isSelected() || (fExecOcc
!= null && fExecOcc
.isSelected()) || (fExecOcc
!= null && fExecOcc
.getLifeline() != null && fExecOcc
.getLifeline().isSelected())) {
161 context
.setBackground(pref
.getBackGroundColorSelection());
162 context
.setForeground(pref
.getForeGroundColorSelection());
164 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_EXEC
));
165 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
167 context
.drawImage(fImage
, getX(), getY(), getWidth(), getHeight());
171 public String
getArrayId() {
176 public boolean isVisible(int x
, int y
, int width
, int height
) {
181 public boolean contains(int xValue
, int yValue
) {
184 int width
= getWidth();
185 int height
= getHeight();
187 if (GraphNode
.contains(x
, y
, width
, height
, xValue
, yValue
)) {