tmf: Simple warning fixes in tmf.core and tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / Lifeline.java
CommitLineData
73005152 1/**********************************************************************
df0b8ff4
BH
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
4 *
73005152
BH
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
73005152
BH
9 *
10 * Contributors:
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
15
16import java.util.ArrayList;
17import java.util.List;
18
19import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
20import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
21import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
df0b8ff4 22import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
3145ec83 23import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
73005152
BH
24
25/**
26 * Lifeline is the UML2 lifeline graphical representation.<br>
27 * Each lifeline owns a set of event occurrences. An event occurrence is the base element in UML2 to set an event in a
28 * sequence diagram.<br>
29 * Event occurrence define the drawing order of graph node along a lifeline. In this lifeline implementation, event
30 * occurrences are just integer index. The event occurrences with the same value on different lifelines will correspond
31 * the same y coordinate value.
32 *
df0b8ff4 33 * @version 1.0
73005152
BH
34 * @author sveyrier
35 *
36 */
37public class Lifeline extends GraphNode {
df0b8ff4
BH
38 // ------------------------------------------------------------------------
39 // Constants
40 // ------------------------------------------------------------------------
41 /**
42 * The life line tag.
43 */
44 public static final String LIFELINE_TAG = "Lifeline"; //$NON-NLS-1$
73005152 45
df0b8ff4
BH
46 // ------------------------------------------------------------------------
47 // Attribute
48 // ------------------------------------------------------------------------
73005152
BH
49 /**
50 * The lifeline position in the containing frame
51 */
eb63f5ff 52 protected int fIndexInFrame = 0;
73005152
BH
53 /**
54 * The frame where the lifeline is drawn
55 */
eb63f5ff 56 protected Frame fFrame = null;
73005152
BH
57 /**
58 * The current event occurrence created in the lifeline
59 */
eb63f5ff 60 protected int fEventOccurrence = 0;
df0b8ff4
BH
61 /**
62 * The lifeline category.
63 */
eb63f5ff 64 protected int fCategory = -1;
df0b8ff4
BH
65 /**
66 * Flag whether lifeline has time information available or not
67 */
eb63f5ff 68 protected boolean fHasTimeInfo = false;
73005152 69
df0b8ff4
BH
70 // ------------------------------------------------------------------------
71 // Constructors
72 // ------------------------------------------------------------------------
73 /**
74 * Default constructor
75 */
76 public Lifeline() {
eb63f5ff 77 fPrefId = ISDPreferences.PREF_LIFELINE;
df0b8ff4
BH
78 }
79
80 // ------------------------------------------------------------------------
81 // Methods
82 // ------------------------------------------------------------------------
83 /*
84 * (non-Javadoc)
85 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getX()
86 */
73005152
BH
87 @Override
88 public int getX() {
eb63f5ff 89 return Metrics.FRAME_H_MARGIN + Metrics.LIFELINE_H_MAGIN + (fIndexInFrame - 1) * Metrics.swimmingLaneWidth();
73005152
BH
90 }
91
df0b8ff4
BH
92 /*
93 * (non-Javadoc)
94 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getY()
95 */
73005152
BH
96 @Override
97 public int getY() {
98 return 2 * Metrics.FRAME_NAME_H_MARGIN + Metrics.LIFELINE_VT_MAGIN / 2 + Metrics.getFrameFontHeigth() + Metrics.getLifelineHeaderFontHeigth() + Metrics.FRAME_V_MARGIN + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
99 }
100
df0b8ff4
BH
101 /*
102 * (non-Javadoc)
103 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getWidth()
104 */
73005152
BH
105 @Override
106 public int getWidth() {
107 return Metrics.getLifelineWidth();
108 }
109
df0b8ff4
BH
110 /*
111 * (non-Javadoc)
112 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getHeight()
113 */
73005152
BH
114 @Override
115 public int getHeight() {
116 // Set room for two text lines
117 return Metrics.getLifelineFontHeigth()/** 2 */
118 + 2 * Metrics.LIFELINE_NAME_H_MARGIN;
119 }
120
73005152
BH
121 /**
122 * Set the lifeline category for this lifeline.
123 *
124 * @param arrayIndex the index of the category to use
125 * @see Frame#setLifelineCategories(LifelineCategories[])
126 */
127 public void setCategory(int arrayIndex) {
eb63f5ff 128 fCategory = arrayIndex;
73005152
BH
129 }
130
131 /**
132 * Returns the tooltip text for the lifeline. It is the combination between the category name(if any) and the
133 * lifeline name
134 *
135 * @return the tooltip text
136 */
137 public String getToolTipText() {
eb63f5ff
BH
138 if (fCategory >= 0) {
139 LifelineCategories[] categories = fFrame.getLifelineCategories();
140 if (fCategory < categories.length) {
141 return categories[fCategory].getName() + " " + getName(); //$NON-NLS-1$
df0b8ff4 142 } else {
73005152 143 return ""; //$NON-NLS-1$
df0b8ff4
BH
144 }
145 } else {
73005152 146 return ""; //$NON-NLS-1$
df0b8ff4 147 }
73005152
BH
148 }
149
150 /**
151 * Returns the index of the first visible Execution Occurrence in the execution occurrence array.<br>
152 * Execution Occurrences are Y ordered in this array
153 *
154 * @return the first visible Execution Occurrence
155 */
156 public int getExecOccurrenceDrawIndex() {
eb63f5ff 157 if (!fHasChilden) {
73005152 158 return 0;
df0b8ff4 159 }
eb63f5ff
BH
160 if (fIndexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG) != null) {
161 return ((Integer) fIndexes.get(BasicExecutionOccurrence.EXEC_OCC_TAG)).intValue();
df0b8ff4
BH
162 }
163 return 0;
73005152
BH
164 }
165
166 /**
167 * Set the frame on which this lifeline must be drawn
168 *
169 * @param parentFrame
170 */
171 protected void setFrame(Frame parentFrame) {
eb63f5ff
BH
172 fFrame = parentFrame;
173 if (fHasTimeInfo) {
174 fFrame.setHasTimeInfo(true);
73005152 175 }
eb63f5ff
BH
176 if (fFrame.getMaxEventOccurrence() < getEventOccurrence() + 1) {
177 fFrame.setMaxEventOccurrence(getEventOccurrence() + 1);
df0b8ff4 178 }
73005152
BH
179 }
180
181 /**
182 * Returns the frame which this lifeline is drawn
183 *
184 * @return the Frame
185 */
186 protected Frame getFrame() {
eb63f5ff 187 return fFrame;
73005152
BH
188 }
189
190 /**
191 * Set the lifeline position index in the containing frame
192 *
193 * @param index the lifeline X position
194 */
73005152 195 protected void setIndex(int index) {
eb63f5ff 196 fIndexInFrame = index;
73005152
BH
197 }
198
199 /**
200 * Returns the lifeline position in de the containing frame
201 *
202 * @return the X position
203 */
204 public int getIndex() {
eb63f5ff 205 return fIndexInFrame;
73005152
BH
206 }
207
208 /**
209 * Set the lifeline event occurrence to the value given in parameter This only change the current event occurrence,
210 * greater event created on this lifeline are still valid and usable. This also need to inform the frame of the
211 * operation mostly to store in the frame the greater event found in the diagram (used to determine the frame
212 * height)
213 *
0d9a6d76 214 * @param eventOcc the new current event occurrence
73005152
BH
215 */
216 public void setCurrentEventOccurrence(int eventOcc) {
eb63f5ff
BH
217 if ((fFrame != null) && (fFrame.getMaxEventOccurrence() < eventOcc)) {
218 fFrame.setMaxEventOccurrence(eventOcc);
df0b8ff4 219 }
eb63f5ff 220 fEventOccurrence = eventOcc;
73005152
BH
221 }
222
223 /**
224 * Returns the last created event occurrence along the lifeline.
225 *
226 * @return the current event occurrence
227 */
228 public int getEventOccurrence() {
eb63f5ff 229 return fEventOccurrence;
73005152
BH
230 }
231
232 /**
233 * Creates a new event occurrence along the lifeline.
234 *
235 * @return the new created event occurrence
236 */
237 public int getNewEventOccurrence() {
eb63f5ff
BH
238 setCurrentEventOccurrence(fEventOccurrence + 1);
239 return fEventOccurrence;
73005152
BH
240 }
241
242 /**
243 * Adds the execution occurrence given in parameter to the lifeline.<br>
244 * A Execution occurrence is never drawn in the frame instead it is added to a lifeline
245 *
246 * @param exec the execution occurrence to add
247 */
248 public void addExecution(BasicExecutionOccurrence exec) {
249 exec.setLifeline(this);
250 addNode(exec);
eb63f5ff
BH
251 if ((fFrame != null) && (fFrame.getMaxEventOccurrence() < exec.fEndEventOccurrence)) {
252 fFrame.setMaxEventOccurrence(exec.fEndEventOccurrence);
df0b8ff4 253 }
73005152
BH
254 }
255
df0b8ff4
BH
256 /**
257 * Set whether lifeline has time information available or not.
258 * @param value The value to set
259 */
73005152 260 protected void setTimeInfo(boolean value) {
eb63f5ff
BH
261 fHasTimeInfo = value;
262 if ((fFrame != null) && value) {
263 fFrame.setHasTimeInfo(value);
df0b8ff4 264 }
73005152
BH
265 }
266
267 /**
df0b8ff4
BH
268 * Returns true if at least one execution occurrence has time info.
269 *
73005152
BH
270 * @return true if at least one execution occurrence has time info
271 */
272 public boolean hasTimeInfo() {
eb63f5ff 273 return fHasTimeInfo;
73005152
BH
274 }
275
276 /**
df0b8ff4 277 * Returns the list of execution occurrence on this lifeline.
73005152
BH
278 *
279 * @return the execution occurrence list
280 */
281 public List<GraphNode> getExecutions() {
eb63f5ff
BH
282 if (fHasChilden) {
283 return (List<GraphNode>) fNodes.get(BasicExecutionOccurrence.EXEC_OCC_TAG);
df0b8ff4
BH
284 }
285 return new ArrayList<GraphNode>();
73005152
BH
286 }
287
df0b8ff4
BH
288 /*
289 * (non-Javadoc)
290 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#contains(int, int)
291 */
73005152 292 @Override
eb63f5ff 293 public boolean contains(int xValue, int yValue) {
73005152
BH
294 int x = getX();
295 int y = getY();
296 int width = getWidth();
297 int height = getHeight();
298
eb63f5ff 299 if (fFrame == null) {
73005152 300 return false;
df0b8ff4 301 }
eb63f5ff 302 if (Frame.contains(x, y, width, height, xValue, yValue)) {
73005152
BH
303 return true;
304 }
eb63f5ff
BH
305 if (Frame.contains(x + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2, y + height, Metrics.EXECUTION_OCCURRENCE_WIDTH, (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fFrame.getMaxEventOccurrence()
306 + Metrics.LIFELINE_VB_MAGIN - 4, xValue, yValue)) {
73005152
BH
307 return true;
308 }
309
310 height = Metrics.getLifelineFontHeigth() + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
311 int hMargin = (Metrics.LIFELINE_VT_MAGIN - height) / 2;
312
313 if (hMargin >= 2) {
eb63f5ff
BH
314 if (fFrame.getVisibleAreaY() < y - height - hMargin) {
315 if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height + 1, xValue, yValue)) {
73005152 316 return true;
df0b8ff4 317 }
73005152 318 } else {
eb63f5ff 319 if (Frame.contains(x - Metrics.LIFELINE_SPACING / 2 + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height, xValue, yValue)) {
73005152 320 return true;
df0b8ff4 321 }
73005152
BH
322 }
323 }
eb63f5ff 324 if (getNodeAt(xValue, yValue) != null) {
73005152 325 return true;
df0b8ff4 326 }
73005152
BH
327 return false;
328 }
329
330 /**
331 * Returns the lifeline visibility for the given visible area
332 *
df0b8ff4
BH
333 * @param vx The x coordinate of the visible area
334 * @param vy The y coordinate of the visible area
335 * @param vwidth The width of the visible area
336 * @param vheight The height of the visible area
73005152
BH
337 * @return true if visible false otherwise
338 */
339 @Override
340 public boolean isVisible(int vx, int vy, int vwidth, int vheight) {
341 int x = getX();
342 int width = getWidth();
df0b8ff4 343 if (((x >= vx) && (x <= vx + vwidth)) || ((x + width >= vx) && (x <= vx))) {
73005152 344 return true;
df0b8ff4 345 }
73005152
BH
346 return false;
347 }
348
df0b8ff4
BH
349 /**
350 * Draws the name within the graphical context.
351 *
352 * @param context The graphical context.
353 */
73005152 354 protected void drawName(IGC context) {
3145ec83
BH
355 ISDPreferences pref = SDViewPref.getInstance();
356
73005152
BH
357 int x = getX();
358 int y = getY();
359 int height = Metrics.getLifelineHeaderFontHeigth() + 2 * Metrics.LIFELINE_HEARDER_TEXT_V_MARGIN;
360 int hMargin = Metrics.LIFELINE_VT_MAGIN / 4;// (Metrics.LIFELINE_NAME_H_MARGIN)/2;
361
362 context.setLineStyle(context.getLineSolidStyle());
3145ec83
BH
363 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
364 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_LIFELINE_HEADER));
365 context.setFont(pref.getFont(ISDPreferences.PREF_LIFELINE_HEADER));
73005152 366 if (hMargin >= 0) {
eb63f5ff 367 if (fFrame.getVisibleAreaY() < y - height - hMargin) {
73005152
BH
368 context.fillRectangle(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height);
369 context.drawRectangle(x - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2, height);
3145ec83 370 context.setForeground(pref.getFontColor(ISDPreferences.PREF_LIFELINE_HEADER));
73005152
BH
371 context.drawTextTruncatedCentred(getName(), x + Metrics.LIFELINE_NAME_V_MARGIN - Metrics.LIFELINE_SPACING / 2 + 1, y - height - hMargin, Metrics.swimmingLaneWidth() - 2 * Metrics.LIFELINE_NAME_V_MARGIN - 2, height, true);
372 } else {
eb63f5ff
BH
373 context.fillRectangle(x - Metrics.LIFELINE_SPACING / 2 + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height);
374 context.drawRectangle(x - Metrics.LIFELINE_SPACING / 2 + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2, height);
3145ec83 375 context.setForeground(pref.getFontColor(ISDPreferences.PREF_LIFELINE_HEADER));
eb63f5ff 376 context.drawTextTruncatedCentred(getName(), x - Metrics.LIFELINE_SPACING / 2 + Metrics.LIFELINE_NAME_V_MARGIN + 1, fFrame.getVisibleAreaY(), Metrics.swimmingLaneWidth() - 2 * Metrics.LIFELINE_NAME_V_MARGIN - 2, height, true);
73005152
BH
377 }
378 }
379 }
380
381 /**
382 * Force the lifeline to be drawn at the given coordinate
383 *
384 * @param context - the context to draw into
0d9a6d76
FC
385 * @param x - the x coordinate
386 * @param y - the y coordinate
73005152
BH
387 */
388 public void draw(IGC context, int x, int y) {
3145ec83
BH
389
390 ISDPreferences pref = SDViewPref.getInstance();
391
73005152
BH
392 // Set the draw color depending if the lifeline must be selected or not
393 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
394 if (isSelected()) {
3145ec83
BH
395 if (pref.useGradienColor()) {
396 context.setGradientColor(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE));
73005152 397 }
3145ec83
BH
398 context.setBackground(pref.getBackGroundColorSelection());
399 context.setForeground(pref.getForeGroundColorSelection());
73005152 400 } else {
3145ec83
BH
401 if (pref.useGradienColor()) {
402 context.setGradientColor(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE));
403 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
df0b8ff4 404 } else {
3145ec83 405 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_LIFELINE));
df0b8ff4 406 }
3145ec83 407 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_LIFELINE));
73005152
BH
408 }
409 // Store the lifeline coordinates to save some calls
410 int width = getWidth();
411 int height = getHeight();
412
413 // Draw the rectangle which contain the lifeline name
3145ec83 414 if (pref.useGradienColor()) {
73005152
BH
415 context.fillGradientRectangle(x, y, width, height / 2 - 7, true);
416 context.fillRectangle(x, y + height / 2 - 8, width, +height / 2 - 5);
417 context.fillGradientRectangle(x, y + height, width, -height / 2 + 6, true);
df0b8ff4 418 } else {
73005152 419 context.fillRectangle(x, y, width, height);
df0b8ff4 420 }
73005152
BH
421 context.drawRectangle(x, y, width, height);
422
eb63f5ff
BH
423 if (fCategory >= 0) {
424 LifelineCategories[] categories = fFrame.getLifelineCategories();
425 if (fCategory < categories.length) {
426 IImage image = categories[fCategory].getImage();
df0b8ff4 427 if (image != null) {
73005152 428 context.drawImage(image, x, y, width, height);
df0b8ff4 429 }
73005152
BH
430 }
431 }
432
433 // Draw the lifeline label into the rectangle
434 // The label is truncated if it cannot fit
435 IColor temp = context.getForeground();
3145ec83
BH
436 context.setFont(pref.getFont(ISDPreferences.PREF_LIFELINE));
437 context.setForeground(pref.getFontColor(ISDPreferences.PREF_LIFELINE));
73005152
BH
438 context.drawTextTruncatedCentred(getName(), x + Metrics.LIFELINE_NAME_V_MARGIN, y, Metrics.getLifelineWidth() - 2 * Metrics.LIFELINE_NAME_V_MARGIN, height, true);
439
440 context.setLineStyle(context.getLineDashStyle());
441 context.setForeground(temp);
442 int oldStyle = context.getLineStyle();
443
444 // Now draw the lifeline vertical line
445 // this line height depends on a stop assignment
446 // if there is no stop the line is drawn to the bottom of the frame
447
448 // by default set the height to reach the frame bottom
eb63f5ff 449 int dashedLineEnd = y + height + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fFrame.getMaxEventOccurrence() + Metrics.LIFELINE_VB_MAGIN;
73005152
BH
450 /*
451 * if (stop != null) { dashedLineEnd = stop.getY(); }
452 */
453
454 if (isSelected()) {
3145ec83 455 context.setForeground(pref.getBackGroundColorSelection());
73005152
BH
456 context.setLineWidth(5);
457 context.drawLine(x + Metrics.getLifelineWidth() / 2, y + height, x + Metrics.getLifelineWidth() / 2, dashedLineEnd - 4);
3145ec83 458 context.setForeground(pref.getForeGroundColorSelection());
73005152
BH
459 }
460
461 context.setLineWidth(Metrics.NORMAL_LINE_WIDTH);
462 context.drawLine(x + Metrics.getLifelineWidth() / 2, y + height, x + Metrics.getLifelineWidth() / 2, dashedLineEnd - 4);
463 context.drawLine(x + Metrics.getLifelineWidth() / 2, y + height, x + Metrics.getLifelineWidth() / 2, dashedLineEnd - 4);
464 context.setLineStyle(oldStyle);
465
466 context.setLineStyle(context.getLineSolidStyle());
467
df0b8ff4 468 if (hasFocus()) {
73005152 469 drawFocus(context);
df0b8ff4 470 }
73005152
BH
471
472 super.drawChildenNodes(context);
473 }
474
475 /**
476 * Draws the select execution occurrence region using the given color
477 *
478 * @param context the graphical context
479 * @param startEvent the region start
480 * @param nbEvent the region height
481 * @param color the color to use
482 */
483 public void highlightExecOccurrenceRegion(IGC context, int startEvent, int nbEvent, IColor color) {
484 IColor backupColor = context.getBackground();
485 context.setBackground(color);
486 int x = getX() + Metrics.getLifelineWidth() / 2 - Metrics.EXECUTION_OCCURRENCE_WIDTH / 2;
487 int y = getY() + getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * startEvent;
488 int width = Metrics.EXECUTION_OCCURRENCE_WIDTH;
489 int height = ((Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing())) * nbEvent;
490 context.fillRectangle(x, y, width, height);
491 context.setBackground(backupColor);
492 }
493
df0b8ff4
BH
494 /*
495 * (non-Javadoc)
496 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC)
497 */
73005152
BH
498 @Override
499 public void draw(IGC context) {
500 draw(context, getX(), getY());
501 }
502
df0b8ff4
BH
503 /*
504 * (non-Javadoc)
505 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId()
506 */
73005152
BH
507 @Override
508 public String getArrayId() {
509 return LIFELINE_TAG;
510 }
511
df0b8ff4
BH
512 /*
513 * (non-Javadoc)
514 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int)
515 */
73005152
BH
516 @Override
517 public boolean positiveDistanceToPoint(int x, int y) {
518 if (getX() > x - Metrics.swimmingLaneWidth())
519 return true;
520 return false;
521 }
522
df0b8ff4
BH
523 /*
524 * (non-Javadoc)
525 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getNodeAt(int, int)
526 */
73005152
BH
527 @Override
528 public GraphNode getNodeAt(int x, int y) {
529 int vy = 0;
530 int vh = 0;
531 if (getFrame() != null) {
532 vy = getFrame().getVisibleAreaY();
533 vh = getFrame().getVisibleAreaHeight();
df0b8ff4 534 } else {
73005152 535 return null;
df0b8ff4
BH
536 }
537 if (getExecutions() == null) {
73005152 538 return null;
df0b8ff4 539 }
73005152
BH
540 for (int i = getExecOccurrenceDrawIndex(); i < getExecutions().size(); i++) {
541 GraphNode node = (GraphNode) getExecutions().get(i);
542 if (node.getHeight() < 0) {
df0b8ff4 543 if (node.getY() + node.getHeight() > vy + vh) {
73005152 544 break;
df0b8ff4 545 }
73005152 546 } else {
df0b8ff4 547 if (node.getY() > vy + vh) {
73005152 548 break;
df0b8ff4 549 }
73005152
BH
550 }
551 if (node.contains(x, y)) {
552 GraphNode internal = node.getNodeAt(x, y);
df0b8ff4 553 if (internal != null) {
73005152 554 return internal;
df0b8ff4
BH
555 }
556 return node;
73005152
BH
557 }
558 }
559 return null;
560 }
561}
This page took 0.057428 seconds and 5 git commands to generate.