Fix for Bug375082
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / HotSpot.java
CommitLineData
73005152
BH
1/**********************************************************************
2 * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
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
7 * $Id: HotSpot.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
14
15import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
16import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
17import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences;
18
19/**
20 * @author sveyrier
21 */
22public class HotSpot extends GraphNode {
23
24 protected BasicExecutionOccurrence execOcc = null;
25 protected int occurrence = 0;
26 protected IImage image = null;
27
28 /**
29 * The grahNode ID constant
30 */
31 public static final String GLYPH = "Glyph"; //$NON-NLS-1$
32
33 public HotSpot() {
34 prefId = ISDPreferences.PREF_EXEC;
35 }
36
37 public void setImage(IImage img) {
38 image = img;
39 }
40
41 @Override
42 public int getX() {
43 if (execOcc != null)
44 return execOcc.getX() - 3;
45 else
46 return 0;
47
48 }
49
50 @Override
51 public int getY() {
52 if (execOcc != null)
53 return execOcc.getY();
54 else
55 return 0;
56 }
57
58 @Override
59 public int getWidth() {
60 if (execOcc != null)
61 return execOcc.getWidth() + 7;
62 else
63 return 0;
64 }
65
66 @Override
67 public int getHeight() {
68 if (execOcc != null)
69 return execOcc.getWidth() + 10;
70 else
71 return 0;
72 }
73
74 /**
75 * Set the lifeline on which the execution occurrence appears.
76 *
77 * @param theLifeline - the parent lifeline
78 */
79 public void setExecution(BasicExecutionOccurrence occ) {
80 execOcc = occ;
81 execOcc.addNode(this);
82 }
83
84 /**
85 * Get the lifeline on which the execution occurrence appears.
86 *
87 * @return - the parent lifeline
88 */
89 public BasicExecutionOccurrence getExecOcc() {
90 return execOcc;
91 }
92
93 public int getOccurrence() {
94 return occurrence;
95 }
96
97 public void setOccurrence(int occ) {
98 occurrence = occ;
99 }
100
101 @Override
102 public void draw(IGC context) {
103
104 // The execution occurrence is selected
105 // if the owning lifeline is selected
106 if (isSelected() || (execOcc != null && execOcc.isSelected()) || (execOcc != null && execOcc.getLifeline() != null && execOcc.getLifeline().isSelected())) {
107 context.setBackground(Frame.getUserPref().getBackGroundColorSelection());
108 context.setForeground(Frame.getUserPref().getForeGroundColorSelection());
109 } else {
110 context.setBackground(Frame.getUserPref().getBackGroundColor(ISDPreferences.PREF_EXEC));
111 context.setForeground(Frame.getUserPref().getForeGroundColor(ISDPreferences.PREF_EXEC));
112 }
113 context.drawImage(image, getX(), getY(), getWidth(), getHeight());
114 }
115
116 @Override
117 public String getArrayId() {
118 return GLYPH;
119 }
120
121 @Override
122 public boolean isVisible(int x, int y, int width, int height) {
123 return true;
124 }
125
126 @Override
127 public boolean contains(int _x, int _y) {
128 int x = getX();
129 int y = getY();
130 int width = getWidth();
131 int height = getHeight();
132
133 if (Frame.contains(x, y, width, height, _x, _y)) {
134 return true;
135 }
136 return false;
137 }
138}
This page took 0.038415 seconds and 5 git commands to generate.