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.
81 protected IImage
getImage() {
87 if (fExecOcc
!= null) {
88 return fExecOcc
.getX() - 3;
95 if (fExecOcc
!= null){
96 return fExecOcc
.getY();
102 public int getWidth() {
103 if (fExecOcc
!= null) {
104 return fExecOcc
.getWidth() + 7;
110 public int getHeight() {
111 if (fExecOcc
!= null) {
112 return fExecOcc
.getWidth() + 10;
118 * Set the lifeline on which the execution occurrence appears.
120 * @param occ the parent lifeline
122 public void setExecution(BasicExecutionOccurrence occ
) {
124 fExecOcc
.addNode(this);
128 * Get the lifeline on which the execution occurrence appears.
130 * @return - the parent lifeline
132 public BasicExecutionOccurrence
getExecOcc() {
137 * Returns the occurrence number.
139 * @return the occurrence number.
141 public int getOccurrence() {
146 * Set the occurrence number.
148 * @param occ A number to set.
150 public void setOccurrence(int occ
) {
155 public void draw(IGC context
) {
157 ISDPreferences pref
= SDViewPref
.getInstance();
159 // The execution occurrence is selected
160 // if the owning lifeline is selected
161 if (isSelected() || (fExecOcc
!= null && fExecOcc
.isSelected()) || (fExecOcc
!= null && fExecOcc
.getLifeline() != null && fExecOcc
.getLifeline().isSelected())) {
162 context
.setBackground(pref
.getBackGroundColorSelection());
163 context
.setForeground(pref
.getForeGroundColorSelection());
165 context
.setBackground(pref
.getBackGroundColor(ISDPreferences
.PREF_EXEC
));
166 context
.setForeground(pref
.getForeGroundColor(ISDPreferences
.PREF_EXEC
));
168 context
.drawImage(fImage
, getX(), getY(), getWidth(), getHeight());
172 public String
getArrayId() {
177 public boolean isVisible(int x
, int y
, int width
, int height
) {
182 public boolean contains(int xValue
, int yValue
) {
185 int width
= getWidth();
186 int height
= getHeight();
188 if (GraphNode
.contains(x
, y
, width
, height
, xValue
, yValue
)) {