tmf.ui: Remove overriding methods
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / core / BasicExecutionOccurrence.java
CommitLineData
73005152 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
73005152
BH
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
abbdd66a
AM
7 *
8 * Contributors:
c8422608
AM
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.uml2sd.core;
73005152 14
2bdf0193
AM
15import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IColor;
16import org.eclipse.tracecompass.tmf.ui.views.uml2sd.drawings.IGC;
17import org.eclipse.tracecompass.tmf.ui.views.uml2sd.preferences.ISDPreferences;
18import org.eclipse.tracecompass.tmf.ui.views.uml2sd.preferences.SDViewPref;
73005152
BH
19
20/**
21 * BasicExecutionOccurrence is the UML2 execution occurrence graphical representation. It is attached to one Lifeline,
22 * the event occurrence "duration" along the lifeline is defined by two event occurrences
abbdd66a 23 *
2bdf0193 24 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
abbdd66a 25 * @version 1.0
73005152 26 * @author sveyrier
abbdd66a 27 *
73005152
BH
28 */
29public class BasicExecutionOccurrence extends GraphNode {
30
df0b8ff4
BH
31 // ------------------------------------------------------------------------
32 // Constants
33 // ------------------------------------------------------------------------
34 /**
35 * The grahNode ID constant
36 */
73005152
BH
37 public static final String EXEC_OCC_TAG = "Execution_Occ"; //$NON-NLS-1$
38
df0b8ff4
BH
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
42
43 /**
abbdd66a 44 * The corresponding lifeline.
df0b8ff4 45 */
cab6c8ff 46 private Lifeline fLifeline = null;
df0b8ff4
BH
47
48 // ------------------------------------------------------------------------
49 // Constructors
50 // ------------------------------------------------------------------------
51 /**
52 * Default constructore
53 */
73005152 54 public BasicExecutionOccurrence() {
cab6c8ff 55 setColorPrefId(ISDPreferences.PREF_EXEC);
73005152
BH
56 }
57
df0b8ff4
BH
58 // ------------------------------------------------------------------------
59 // Constants
60 // ------------------------------------------------------------------------
61
73005152
BH
62 @Override
63 public int getX() {
eb63f5ff 64 if (fLifeline == null) {
73005152 65 return 0;
df0b8ff4 66 }
eb63f5ff 67 return fLifeline.getX() + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
73005152
BH
68 }
69
70 @Override
71 public int getY() {
eb63f5ff 72 if (fLifeline == null) {
73005152 73 return 0;
df0b8ff4 74 }
cab6c8ff 75 return fLifeline.getY() + fLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * getStartOccurrence();
73005152
BH
76 }
77
78 @Override
79 public int getWidth() {
eb63f5ff 80 if (fLifeline == null) {
73005152 81 return 0;
df0b8ff4 82 }
73005152
BH
83 return Metrics.EXECUTION_OCCURRENCE_WIDTH;
84 }
85
86 @Override
87 public int getHeight() {
eb63f5ff 88 if (fLifeline == null) {
73005152 89 return 0;
df0b8ff4 90 }
cab6c8ff 91 return ((Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing())) * (getEndOccurrence() - getStartOccurrence());
73005152
BH
92 }
93
94 @Override
eb63f5ff 95 public boolean contains(int xValue, int yValue) {
73005152
BH
96 int x = getX();
97 int y = getY();
98 int width = getWidth();
99 int height = getHeight();
100
abbdd66a 101 if (GraphNode.contains(x, y, width, height, xValue, yValue)) {
73005152
BH
102 return true;
103 }
104
eb63f5ff 105 if (getNodeAt(xValue, yValue) != null) {
73005152 106 return true;
df0b8ff4 107 }
73005152
BH
108 return false;
109 }
110
111 @Override
112 public String getName() {
df0b8ff4 113 if (super.getName() == null || super.getName().equals("")) { //$NON-NLS-1$
eb63f5ff 114 return fLifeline.getToolTipText();
df0b8ff4 115 }
abbdd66a 116 return super.getName();
73005152
BH
117 }
118
119 /**
120 * Set the lifeline on which the execution occurrence appears.
abbdd66a 121 *
73005152
BH
122 * @param theLifeline - the parent lifeline
123 */
124 public void setLifeline(Lifeline theLifeline) {
eb63f5ff 125 fLifeline = theLifeline;
73005152
BH
126 }
127
128 /**
129 * Get the lifeline on which the execution occurrence appears.
abbdd66a 130 *
73005152
BH
131 * @return - the parent lifeline
132 */
133 public Lifeline getLifeline() {
eb63f5ff 134 return fLifeline;
73005152
BH
135 }
136
73005152
BH
137 /**
138 * Set the execution start event occurrence
abbdd66a 139 *
73005152
BH
140 * @param occurrence the start event occurrence to set
141 */
cab6c8ff 142 @Override
73005152 143 public void setStartOccurrence(int occurrence) {
cab6c8ff 144 super.setStartOccurrence(occurrence);
73005152
BH
145 }
146
147 /**
148 * Set the execution end event occurrence
abbdd66a 149 *
73005152
BH
150 * @param occurrence the end event occurrence to set
151 */
cab6c8ff 152 @Override
73005152 153 public void setEndOccurrence(int occurrence) {
cab6c8ff 154 super.setEndOccurrence(occurrence);
73005152
BH
155 }
156
157 @Override
158 public void draw(IGC context) {
159 int x = getX();
160 int y = getY();
161 int width = getWidth();
162 int height = getHeight();
eb63f5ff
BH
163 IColor tempFillColor = null;
164 IColor tempStrokeColor = null;
73005152 165
3145ec83 166 ISDPreferences pref = SDViewPref.getInstance();
abbdd66a 167
73005152
BH
168 // The execution occurrence is selected
169 // if the owning lifeline is selected
eb63f5ff 170 if (fLifeline.isSelected() || isSelected()) {
3145ec83
BH
171 context.setBackground(pref.getBackGroundColorSelection());
172 context.setForeground(pref.getForeGroundColorSelection());
73005152
BH
173 } else {
174 tempFillColor = setUnselectedFillColor(context);
175 }
3145ec83 176 if (pref.useGradienColor()) {
73005152 177 context.fillGradientRectangle(x, y, width, height, false);
df0b8ff4 178 } else {
73005152 179 context.fillRectangle(x, y, width, height);
df0b8ff4 180 }
73005152
BH
181 tempStrokeColor = setUnselectedStrokeColor(context);
182 context.drawRectangle(x, y, width, height);
183 if (tempFillColor != null) {
184 tempFillColor.dispose();
73005152
BH
185 }
186 if (tempStrokeColor != null) {
187 tempStrokeColor.dispose();
73005152 188 }
df0b8ff4 189 if (hasFocus()) {
73005152 190 drawFocus(context);
df0b8ff4 191 }
73005152
BH
192 super.drawChildenNodes(context);
193 }
194
195 /**
196 * Rewrite this method in your extension in order to support customized fill colors
abbdd66a 197 *
a0a88f65 198 * @param context Graphics context
73005152
BH
199 * @return IColor
200 */
201 protected IColor setUnselectedFillColor(IGC context) {
3145ec83
BH
202
203 ISDPreferences pref = SDViewPref.getInstance();
204
205 if (pref.useGradienColor()) {
206 context.setGradientColor(pref.getBackGroundColor(ISDPreferences.PREF_EXEC));
207 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
df0b8ff4 208 } else {
3145ec83 209 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_EXEC));
df0b8ff4 210 }
73005152
BH
211 return null;
212 }
213
214 /**
215 * Rewrite this method in your extension in order to support customized stroke colors
abbdd66a 216 *
a0a88f65 217 * @param context Graphics context
73005152
BH
218 * @return IColor
219 */
220 protected IColor setUnselectedStrokeColor(IGC context) {
3145ec83 221 context.setForeground(SDViewPref.getInstance().getForeGroundColor(ISDPreferences.PREF_EXEC));
73005152
BH
222 return null;
223 }
224
225 @Override
226 public String getArrayId() {
227 return EXEC_OCC_TAG;
228 }
229
230 @Override
231 public boolean positiveDistanceToPoint(int x, int y) {
df0b8ff4 232 if (getY() + getHeight() > y) {
73005152 233 return true;
df0b8ff4 234 }
73005152
BH
235 return false;
236 }
237
238 @Override
239 public boolean isVisible(int x, int y, int width, int height) {
240 if ((getLifeline() != null) && (getLifeline().isVisible(x, y, width, height))) {
241 int ly = getY();
242 int lh = getHeight();
df0b8ff4 243 if (ly >= y && ly < y + height) {
73005152 244 return true;
df0b8ff4
BH
245 }
246 if (ly + lh > y && ly + lh <= y + height) {
73005152 247 return true;
df0b8ff4
BH
248 }
249 if ((ly < y) && (ly + lh > y + height)) {
73005152 250 return true;
df0b8ff4 251 }
73005152
BH
252 }
253 return false;
254 }
255}
This page took 0.13053 seconds and 5 git commands to generate.