Java Doc and API clean up of TMF UML Sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / TimeCompressionBar.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 *
14 **********************************************************************/
15package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
16
17import java.util.ArrayList;
18import java.util.Arrays;
19import java.util.List;
20
df0b8ff4
BH
21import org.eclipse.core.runtime.IStatus;
22import org.eclipse.core.runtime.Status;
23import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
4df4581d 24import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
6c13869b 25import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
73005152
BH
26import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessage;
27import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.AsyncMessageReturn;
28import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
29import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ExecutionOccurrence;
30import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
31import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
32import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange;
33import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline;
34import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Metrics;
35import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SDTimeEvent;
36import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
37import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
38import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.ColorImpl;
39import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
40import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.TimeEventComparator;
41import org.eclipse.swt.SWT;
42import org.eclipse.swt.accessibility.ACC;
43import org.eclipse.swt.accessibility.Accessible;
44import org.eclipse.swt.accessibility.AccessibleAdapter;
45import org.eclipse.swt.accessibility.AccessibleControlAdapter;
46import org.eclipse.swt.accessibility.AccessibleControlEvent;
47import org.eclipse.swt.accessibility.AccessibleEvent;
48import org.eclipse.swt.events.DisposeEvent;
49import org.eclipse.swt.events.DisposeListener;
50import org.eclipse.swt.events.FocusEvent;
51import org.eclipse.swt.events.FocusListener;
52import org.eclipse.swt.events.KeyEvent;
53import org.eclipse.swt.events.MouseEvent;
54import org.eclipse.swt.events.TraverseEvent;
55import org.eclipse.swt.events.TraverseListener;
56import org.eclipse.swt.graphics.Color;
57import org.eclipse.swt.graphics.GC;
58import org.eclipse.swt.graphics.Image;
59import org.eclipse.swt.widgets.Composite;
60import org.eclipse.swt.widgets.Control;
61import org.eclipse.swt.widgets.Display;
62
63/**
df0b8ff4
BH
64 * <p>
65 * The time compression bar implementation.
66 * </p>
67 *
68 * @version 1.0
73005152
BH
69 * @author sveyrier
70 *
71 */
72public class TimeCompressionBar extends ScrollView implements DisposeListener {
73
df0b8ff4
BH
74 // ------------------------------------------------------------------------
75 // Attributes
76 // ------------------------------------------------------------------------
77
73005152
BH
78 /**
79 * The listener list
80 */
81 protected ArrayList<ITimeCompressionListener> listenerList = null;
df0b8ff4
BH
82 /**
83 * The current frame displayed.
84 */
73005152 85 protected Frame frame = null;
df0b8ff4
BH
86 /**
87 * List of time events.
88 */
73005152 89 protected List<SDTimeEvent> nodeList = null;
df0b8ff4
BH
90 /**
91 * The minimum time delta.
92 */
4df4581d 93 protected ITmfTimestamp min = new TmfTimestamp();
df0b8ff4
BH
94 /**
95 * The maximum time delta.
96 */
4df4581d 97 protected ITmfTimestamp max = new TmfTimestamp();
df0b8ff4
BH
98 /**
99 * The current zoom value.
100 */
73005152 101 protected float zoomValue = 1;
df0b8ff4
BH
102 /**
103 * The tooltip to display.
104 */
73005152 105 protected DrawableToolTip tooltip = null;
df0b8ff4
BH
106 /**
107 * Array of colors for displaying wight of time deltas.
108 */
73005152 109 protected ColorImpl[] col;
df0b8ff4
BH
110 /**
111 * The accessible object reference.
112 */
73005152 113 protected Accessible accessible = null;
df0b8ff4
BH
114 /**
115 * The focused widget reference.
116 */
73005152 117 protected int focusedWidget = -1;
df0b8ff4
BH
118 /**
119 * The sequence diagram view reference.
120 */
73005152 121 protected SDView view = null;
df0b8ff4
BH
122 /**
123 * The current lifeline.
124 */
73005152 125 protected Lifeline ll = null;
df0b8ff4
BH
126 /**
127 * The current start event value.
128 */
73005152 129 protected int ls = 0;
df0b8ff4
BH
130 /**
131 * The current number of events.
132 */
73005152 133 protected int ln = 0;
df0b8ff4
BH
134 /**
135 * The Current color of range to display.
136 */
73005152 137 protected IColor lc = null;
df0b8ff4
BH
138 /**
139 * The next graph node y coordinate.
140 */
73005152 141 protected int nextNodeY = 0;
df0b8ff4
BH
142 /**
143 * The previous graph node y coordinate.
144 */
73005152
BH
145 protected int prevNodeY = 0;
146
df0b8ff4
BH
147 // ------------------------------------------------------------------------
148 // Constructors
149 // ------------------------------------------------------------------------
150 /**
151 * Standard constructor
152 *
153 * @param parent The parent composite
154 * @param s The style bits
155 */
73005152
BH
156 public TimeCompressionBar(Composite parent, int s) {
157 super(parent, s | SWT.NO_BACKGROUND, false);
158 setVScrollBarMode(ScrollView.ALWAYS_OFF);
159 setHScrollBarMode(ScrollView.ALWAYS_OFF);
160 listenerList = new ArrayList<ITimeCompressionListener>();
161 col = new ColorImpl[10];
162 col[0] = new ColorImpl(Display.getDefault(), 255, 229, 229);
163 col[1] = new ColorImpl(Display.getDefault(), 255, 204, 204);
164 col[2] = new ColorImpl(Display.getDefault(), 255, 178, 178);
165 col[3] = new ColorImpl(Display.getDefault(), 255, 153, 153);
166 col[4] = new ColorImpl(Display.getDefault(), 255, 127, 127);
167 col[5] = new ColorImpl(Display.getDefault(), 255, 102, 102);
168 col[6] = new ColorImpl(Display.getDefault(), 255, 76, 76);
169 col[7] = new ColorImpl(Display.getDefault(), 255, 51, 51);
170 col[8] = new ColorImpl(Display.getDefault(), 255, 25, 25);
171 col[9] = new ColorImpl(Display.getDefault(), 255, 0, 0);
172 super.addDisposeListener(this);
173
174 accessible = getViewControl().getAccessible();
175
176 accessible.addAccessibleListener(new AccessibleAdapter() {
177 @Override
178 public void getName(AccessibleEvent e) {
179 if (e.childID == ACC.CHILDID_SELF) {
180 // e.result = "Sequence Diagram";
181 }
182 // Case toolTip
183 else if (e.childID == 0) {
df0b8ff4 184 if (tooltip != null) {
73005152 185 e.result = tooltip.getAccessibleText();
df0b8ff4 186 }
73005152
BH
187 } else if (e.childID == 1) {
188 createFakeTooltip();
189 e.result = tooltip.getAccessibleText();
190 }
191 }
192 });
193
194 accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
df0b8ff4
BH
195 /*
196 * (non-Javadoc)
197 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getFocus(org.eclipse.swt.accessibility.AccessibleControlEvent)
198 */
73005152
BH
199 @Override
200 public void getFocus(AccessibleControlEvent e) {
df0b8ff4 201 if (focusedWidget == -1) {
73005152 202 e.childID = ACC.CHILDID_SELF;
df0b8ff4
BH
203 }
204 else {
73005152 205 e.childID = focusedWidget;
df0b8ff4 206 }
73005152
BH
207 }
208
df0b8ff4
BH
209 /*
210 * (non-Javadoc)
211 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getRole(org.eclipse.swt.accessibility.AccessibleControlEvent)
212 */
73005152
BH
213 @Override
214 public void getRole(AccessibleControlEvent e) {
215 switch (e.childID) {
216 case ACC.CHILDID_SELF:
217 e.detail = ACC.ROLE_CLIENT_AREA;
218 break;
219 case 0:
220 e.detail = ACC.ROLE_TOOLTIP;
221 break;
222 case 1:
223 e.detail = ACC.ROLE_LABEL;
224 break;
225 }
226 }
227
df0b8ff4
BH
228 /*
229 * (non-Javadoc)
230 * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getState(org.eclipse.swt.accessibility.AccessibleControlEvent)
231 */
73005152
BH
232 @Override
233 public void getState(AccessibleControlEvent e) {
234 e.detail = ACC.STATE_FOCUSABLE;
235 if (e.childID == ACC.CHILDID_SELF) {
236 e.detail |= ACC.STATE_FOCUSED;
237 } else {
238 e.detail |= ACC.STATE_SELECTABLE;
df0b8ff4 239 if (e.childID == focusedWidget) {
73005152 240 e.detail |= ACC.STATE_FOCUSED | ACC.STATE_SELECTED | ACC.STATE_CHECKED;
df0b8ff4 241 }
73005152
BH
242 }
243 }
244 });
245
246 getViewControl().addTraverseListener(new TraverseListener() {
247
df0b8ff4
BH
248 /*
249 * (non-Javadoc)
250 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
251 */
73005152
BH
252 @Override
253 public void keyTraversed(TraverseEvent e) {
df0b8ff4 254 if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
73005152 255 e.doit = true;
df0b8ff4 256 }
73005152
BH
257 }
258
259 });
260
261 addTraverseListener(new TraverseListener() {
262
df0b8ff4
BH
263 /*
264 * (non-Javadoc)
265 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse.swt.events.TraverseEvent)
266 */
73005152
BH
267 @Override
268 public void keyTraversed(TraverseEvent e) {
df0b8ff4 269 if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
73005152 270 e.doit = true;
df0b8ff4 271 }
73005152
BH
272 }
273
274 });
275
276 getViewControl().addFocusListener(new FocusListener() {
277
df0b8ff4
BH
278 /*
279 * (non-Javadoc)
280 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
281 */
73005152
BH
282 @Override
283 public void focusGained(FocusEvent e) {
73005152
BH
284 redraw();
285 }
286
df0b8ff4
BH
287 /*
288 * (non-Javadoc)
289 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
290 */
73005152
BH
291 @Override
292 public void focusLost(FocusEvent e) {
293 redraw();
294 }
295 });
296 }
297
df0b8ff4
BH
298 // ------------------------------------------------------------------------
299 // Methods
300 // ------------------------------------------------------------------------
301
302 /**
303 * Sets the focus widget
304 *
305 * @param newFocusShape widget reference to set
306 */
73005152
BH
307 void setFocus(int newFocusShape) {
308 focusedWidget = newFocusShape;
309 if (focusedWidget == -1) {
310 getViewControl().getAccessible().setFocus(ACC.CHILDID_SELF);
311 } else {
312 getViewControl().getAccessible().setFocus(focusedWidget);
313 }
314 }
315
df0b8ff4
BH
316 /**
317 * Sets the current frame.
318 *
319 * @param theFrame The frame to set
320 */
73005152
BH
321 public void setFrame(Frame theFrame) {
322 frame = theFrame;
323 min = frame.getMinTime();
324 max = frame.getMaxTime();
325 }
326
df0b8ff4
BH
327 /*
328 * (non-Javadoc)
329 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#drawContents(org.eclipse.swt.graphics.GC, int, int, int, int)
330 */
73005152
BH
331 @Override
332 protected void drawContents(GC gc, int clipx, int clipy, int clipw, int cliph) {
df0b8ff4 333 if (frame == null) {
73005152 334 return;
df0b8ff4 335 }
73005152
BH
336 nodeList = new ArrayList<SDTimeEvent>();
337 int messageArraysStep = 1;
338
df0b8ff4 339 if ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * zoomValue < Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1) {
73005152 340 messageArraysStep = Math.round(Metrics.MESSAGE_SIGNIFICANT_VSPACING + 1 / ((Metrics.getMessageFontHeigth() + Metrics.MESSAGES_NAME_SPACING * 2) * zoomValue));
df0b8ff4 341 }
73005152
BH
342
343 int firstVisible = frame.getFirstVisibleSyncMessage();
df0b8ff4 344 if (firstVisible > 0) {
73005152 345 firstVisible = firstVisible - 1;
df0b8ff4 346 }
73005152
BH
347 for (int i = firstVisible; i < frame.syncMessageCount(); i = i + messageArraysStep) {
348 SyncMessage m = frame.getSyncMessage(i);
349 if (m.hasTimeInfo()) {
350 SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
351 nodeList.add(t);
df0b8ff4 352 if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
73005152 353 break;
df0b8ff4 354 }
73005152
BH
355 }
356 }
357
358 firstVisible = frame.getFirstVisibleSyncMessageReturn();
df0b8ff4 359 if (firstVisible > 0) {
73005152 360 firstVisible = firstVisible - 1;
df0b8ff4 361 }
73005152
BH
362 for (int i = firstVisible; i < frame.syncMessageReturnCount(); i = i + messageArraysStep) {
363 SyncMessage m = frame.getSyncMessageReturn(i);
364 if (m.hasTimeInfo()) {
365 SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getEventOccurrence(), (ITimeRange) m);
366 nodeList.add(t);
df0b8ff4 367 if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
73005152 368 break;
df0b8ff4 369 }
73005152
BH
370 }
371 }
372
373 firstVisible = frame.getFirstVisibleAsyncMessage();
df0b8ff4 374 if (firstVisible > 0) {
73005152 375 firstVisible = firstVisible - 1;
df0b8ff4 376 }
73005152
BH
377 for (int i = firstVisible; i < frame.asyncMessageCount(); i = i + messageArraysStep) {
378 AsyncMessage m = frame.getAsyncMessage(i);
379 if (m.hasTimeInfo()) {
380 SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
381 nodeList.add(t);
382 t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
383 nodeList.add(t);
df0b8ff4 384 if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
73005152 385 break;
df0b8ff4 386 }
73005152
BH
387 }
388 }
389
390 firstVisible = frame.getFirstVisibleAsyncMessageReturn();
df0b8ff4 391 if (firstVisible > 0) {
73005152 392 firstVisible = firstVisible - 1;
df0b8ff4 393 }
73005152
BH
394 for (int i = firstVisible; i < frame.asyncMessageReturnCount(); i = i + messageArraysStep) {
395 AsyncMessageReturn m = frame.getAsyncMessageReturn(i);
396 if (m.hasTimeInfo()) {
397 SDTimeEvent t = new SDTimeEvent(m.getStartTime(), m.getStartOccurrence(), (ITimeRange) m);
398 nodeList.add(t);
399 t = new SDTimeEvent(m.getEndTime(), m.getEndOccurrence(), (ITimeRange) m);
400 nodeList.add(t);
df0b8ff4 401 if (m.getY() * zoomValue > getContentsY() + getVisibleHeight()) {
73005152 402 break;
df0b8ff4 403 }
73005152
BH
404 }
405 }
406
73005152
BH
407 List<SDTimeEvent> executionOccurrencesWithTime = frame.getExecutionOccurrencesWithTime();
408 if (executionOccurrencesWithTime != null) {
409 nodeList.addAll(executionOccurrencesWithTime);
410 }
411
412 SDTimeEvent[] temp = nodeList.toArray(new SDTimeEvent[0]);
413 Arrays.sort(temp, new TimeEventComparator());
414 nodeList = Arrays.asList(temp);
415
416 Image dbuffer = null;
417 GC gcim = null;
418 try {
419 dbuffer = new Image(getDisplay(), getClientArea().width, getClientArea().height);
420 } catch (Exception e) {
df0b8ff4 421 TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error creating image", e)); //$NON-NLS-1$
73005152
BH
422 }
423 gcim = new GC(dbuffer);
424 for (int i = 0; i < nodeList.size() - 1; i++) {
425 SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
426 SDTimeEvent m2 = (SDTimeEvent) nodeList.get(i + 1);
427
428 if (SDViewPref.getInstance().excludeExternalTime()) {
429 if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
430 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
431 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
df0b8ff4 432 if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
73005152 433 continue;
df0b8ff4 434 }
73005152
BH
435 }
436 }
437
438 min = frame.getMinTime();
439 max = frame.getMaxTime();
df0b8ff4 440 ITmfTimestamp minMaxdelta = max.getDelta(min);
73005152
BH
441 double gr = (minMaxdelta.getValue()) / (double) 10;
442
df0b8ff4 443 ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
73005152
BH
444 long absDelta = Math.abs(delta.getValue());
445
446 ColorImpl color;
447 if (gr != 0) {
448 int colIndex = Math.round((float) (absDelta / gr));
df0b8ff4 449 if (colIndex < col.length && colIndex > 0) {
73005152 450 color = col[colIndex - 1];
df0b8ff4 451 } else if (colIndex <= 0) {
73005152 452 color = col[0];
df0b8ff4 453 } else {
73005152 454 color = col[col.length - 1];
df0b8ff4
BH
455 }
456 } else {
73005152 457 color = col[0];
df0b8ff4 458 }
73005152 459
df0b8ff4 460 if (color.getColor() instanceof Color) {
73005152 461 gcim.setBackground((Color) color.getColor());
df0b8ff4 462 }
73005152
BH
463 int y1 = ((GraphNode) m1.getGraphNode()).getY();
464 int y2 = ((GraphNode) m2.getGraphNode()).getY();
465 if (m1.getGraphNode() instanceof AsyncMessage) {
466 AsyncMessage as = (AsyncMessage) m1.getGraphNode();
df0b8ff4 467 if (as.getEndTime() == m1.getTime()) {
73005152 468 y1 += as.getHeight();
df0b8ff4 469 }
73005152
BH
470 }
471 if (m2.getGraphNode() instanceof AsyncMessage) {
472 AsyncMessage as = (AsyncMessage) m2.getGraphNode();
df0b8ff4 473 if (as.getEndTime() == m2.getTime()) {
73005152 474 y2 += as.getHeight();
df0b8ff4 475 }
73005152
BH
476 }
477 if (m1.getGraphNode() instanceof ExecutionOccurrence) {
478
479 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
df0b8ff4 480 if (m1.getEvent() == eo.getEndOccurrence()) {
73005152 481 y1 += eo.getHeight();
df0b8ff4 482 }
73005152
BH
483
484 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
485
486 ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
df0b8ff4 487 if (m2.getEvent() == eo2.getEndOccurrence()) {
73005152 488 y2 += eo2.getHeight();
df0b8ff4 489 }
73005152
BH
490
491 }
492 }
493 gcim.fillRectangle(contentsToViewX(0), contentsToViewY(Math.round(y1 * zoomValue)), 10, Math.round((y2 - y1) * zoomValue) + 1);
494 if (messageArraysStep == 1) {
495 Color backupColor = gcim.getForeground();
496 gcim.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
497 gcim.drawRectangle(contentsToViewX(0), contentsToViewY(Math.round(y1 * zoomValue)), 9, Math.round((y2 - y1) * zoomValue));
498 gcim.setForeground(backupColor);
499 }
500 }
501 if (getViewControl().isFocusControl() || isFocusControl()) {
502 gcim.drawFocus(contentsToViewX(0), contentsToViewY(Math.round(prevNodeY * zoomValue)), contentsToViewX(10), Math.round((nextNodeY - prevNodeY) * zoomValue));
503 }
504 try {
505 gc.drawImage(dbuffer, 0, 0, getClientArea().width, getClientArea().height, 0, 0, getClientArea().width, getClientArea().height);
506 } catch (Exception e) {
df0b8ff4 507 TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,TmfUiPlugin.PLUGIN_ID, "Error drawing image", e)); //$NON-NLS-1$
73005152
BH
508 }
509 gcim.dispose();
510 if (dbuffer != null) {
511 dbuffer.dispose();
512 }
513 gc.dispose();
514 }
515
df0b8ff4
BH
516 /**
517 * Checks for focus of children.
518 *
519 * @param children Control to check
520 * @return true if child is on focus else false
521 */
73005152
BH
522 protected boolean checkFocusOnChilds(Control childs) {
523 if (childs instanceof Composite) {
524 Control[] child = ((Composite) childs).getChildren();
525 for (int i = 0; i < child.length; i++) {
526 if (child[i].isFocusControl()) {
527 return true;
df0b8ff4 528 } else {
73005152 529 checkFocusOnChilds(child[i]);
df0b8ff4 530 }
73005152
BH
531 }
532 }
533 return false;
534 }
535
df0b8ff4
BH
536 /*
537 * (non-Javadoc)
538 * @see org.eclipse.swt.widgets.Control#isFocusControl()
539 */
73005152
BH
540 @Override
541 public boolean isFocusControl() {
542 Control[] child = getChildren();
543 for (int i = 0; i < child.length; i++) {
544 if (child[i].isFocusControl()) {
545 return true;
df0b8ff4 546 } else {
73005152 547 checkFocusOnChilds(child[i]);
df0b8ff4 548 }
73005152
BH
549 }
550 return false;
551 }
552
df0b8ff4
BH
553 /*
554 * (non-Javadoc)
555 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseMoveEvent(org.eclipse.swt.events.MouseEvent)
556 */
73005152
BH
557 @Override
558 protected void contentsMouseMoveEvent(MouseEvent event) {
df0b8ff4 559 if (tooltip != null) {
73005152 560 tooltip.hideToolTip();
df0b8ff4 561 }
73005152
BH
562 super.contentsMouseMoveEvent(event);
563 if (!isFocusControl() || getViewControl().isFocusControl()) {
564 Control[] child = getParent().getChildren();
565 for (int i = 0; i < child.length; i++) {
566 if (child[i].isFocusControl()) {
73005152
BH
567 break;
568 }
569 }
570 }
571 setFocus(-1);
572 }
573
df0b8ff4
BH
574 /*
575 * (non-Javadoc)
576 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseHover(org.eclipse.swt.events.MouseEvent)
577 */
73005152
BH
578 @Override
579 protected void contentsMouseHover(MouseEvent e) {
580 if (tooltip == null) {
581 tooltip = new DrawableToolTip(this);
582 }
583 if (frame != null) {
584 setFocus(0);
585 for (int i = 0; i < nodeList.size() - 1; i++) {
586 SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
587 SDTimeEvent m2 = (SDTimeEvent) nodeList.get(i + 1);
588
589 if (SDViewPref.getInstance().excludeExternalTime()) {
590 if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
591 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
592 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
df0b8ff4 593 if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
73005152 594 continue;
df0b8ff4 595 }
73005152
BH
596 }
597 }
598
599 int y1 = ((GraphNode) m1.getGraphNode()).getY();
600 int y2 = ((GraphNode) m2.getGraphNode()).getY();
601
602 if (m1.getGraphNode() instanceof AsyncMessage) {
603 AsyncMessage as = (AsyncMessage) m1.getGraphNode();
df0b8ff4 604 if (as.getEndTime() == m1.getTime()) {
73005152 605 y1 += as.getHeight();
df0b8ff4 606 }
73005152
BH
607 }
608 if (m2.getGraphNode() instanceof AsyncMessage) {
609 AsyncMessage as = (AsyncMessage) m2.getGraphNode();
df0b8ff4 610 if (as.getEndTime() == m2.getTime()) {
73005152 611 y2 += as.getHeight();
df0b8ff4 612 }
73005152
BH
613 }
614 if (m1.getGraphNode() instanceof ExecutionOccurrence) {
615 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
df0b8ff4 616 if (m1.getEvent() == eo.getEndOccurrence()) {
73005152 617 y1 += eo.getHeight();
df0b8ff4 618 }
73005152
BH
619
620 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
621
622 ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
df0b8ff4 623 if (m2.getEvent() == eo2.getEndOccurrence()) {
73005152 624 y2 += eo2.getHeight();
df0b8ff4 625 }
73005152
BH
626 }
627 }
628 int m1Y = Math.round(y1 * zoomValue);
629 int m2Y = Math.round(y2 * zoomValue);
630 if ((m1Y < e.y) && (m2Y >= e.y)) {
df0b8ff4 631 ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
73005152
BH
632 tooltip.showToolTip(delta, min, max);
633 }
634 }
635 }
636 setFocus(0);
637 }
638
df0b8ff4
BH
639 /*
640 * (non-Javadoc)
641 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseExit(org.eclipse.swt.events.MouseEvent)
642 */
73005152
BH
643 @Override
644 protected void contentsMouseExit(MouseEvent e) {
645 if (tooltip != null)
646 tooltip.hideToolTip();
647 }
648
df0b8ff4
BH
649 /*
650 * (non-Javadoc)
651 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#contentsMouseUpEvent(org.eclipse.swt.events.MouseEvent)
652 */
73005152
BH
653 @Override
654 protected void contentsMouseUpEvent(MouseEvent event) {
655 selectTimeDelta(event.y, 0);
656 setFocus();
657 super.contentsMouseUpEvent(event);
658 }
659
660 /**
661 * Force the time compression bar to highlight the event occurrences between the two given messages. The event
662 * occurrences are highlighted on the first message's end lifeline
663 *
664 * @param mes1 the first message
df0b8ff4 665 * @param mes2 the second message
73005152
BH
666 */
667 public void highlightRegion(BaseMessage mes1, BaseMessage mes2) {
df0b8ff4 668 if (frame == null) {
73005152 669 return;
df0b8ff4
BH
670 }
671 if (!(mes1 instanceof ITimeRange)) {
73005152 672 return;
df0b8ff4
BH
673 }
674 if (!(mes2 instanceof ITimeRange)) {
73005152 675 return;
df0b8ff4 676 }
73005152
BH
677 ITimeRange t1 = (ITimeRange) mes1;
678 ITimeRange t2 = (ITimeRange) mes2;
679
4df4581d 680 ITmfTimestamp time1 = t1.getStartTime();
681 ITmfTimestamp time2 = t2.getStartTime();
73005152
BH
682 int event1 = mes1.getEventOccurrence();
683 int event2 = mes2.getEventOccurrence();
684
685 if (mes1 instanceof AsyncMessage) {
686 AsyncMessage as = (AsyncMessage) mes2;
687 time1 = as.getEndTime();
688 event1 = as.getEndOccurrence();
689 }
690 if (mes2 instanceof AsyncMessage) {
691 AsyncMessage as = (AsyncMessage) mes2;
692 if (as.getEndOccurrence() > as.getStartOccurrence()) {
693 time1 = as.getEndTime();
694 event1 = as.getEndOccurrence();
695 } else {
696 time1 = as.getStartTime();
697 event1 = as.getStartOccurrence();
698 }
699 }
700
701 if (event1 > event2) {
702 BaseMessage tempMes = mes2;
703 mes2 = mes1;
704 mes1 = tempMes;
705
706 t1 = (ITimeRange) mes1;
707 t2 = (ITimeRange) mes2;
708
709 time1 = t1.getStartTime();
710 time2 = t2.getStartTime();
711 event1 = mes1.getEventOccurrence();
712 event2 = mes2.getEventOccurrence();
713
714 if (mes1 instanceof AsyncMessage) {
715 AsyncMessage as = (AsyncMessage) mes2;
716 time1 = as.getEndTime();
717 event1 = as.getEndOccurrence();
718 }
719 if (mes2 instanceof AsyncMessage) {
720 AsyncMessage as = (AsyncMessage) mes2;
721 if (as.getEndOccurrence() > as.getStartOccurrence()) {
722 time1 = as.getEndTime();
723 event1 = as.getEndOccurrence();
724 } else {
725 time1 = as.getStartTime();
726 event1 = as.getStartOccurrence();
727 }
728 }
729 }
730
df0b8ff4 731 ITmfTimestamp minMaxdelta = max.getDelta(min);
73005152
BH
732 double gr = (minMaxdelta.getValue()) / (double) 10;
733
df0b8ff4 734 ITmfTimestamp delta = time2.getDelta(time1).getDelta(min);
73005152
BH
735 long absDelta = Math.abs(delta.getValue());
736
737 int colIndex = 0;
738 if (gr != 0) {
739 colIndex = Math.round((float) (absDelta / gr));
df0b8ff4 740 if (colIndex >= col.length) {
73005152 741 colIndex = col.length - 1;
df0b8ff4 742 } else if (colIndex < 0) {
73005152 743 colIndex = 0;
df0b8ff4
BH
744 }
745 } else {
73005152 746 colIndex = 0;
df0b8ff4 747 }
73005152
BH
748 for (int j = 0; j < listenerList.size(); j++) {
749 ITimeCompressionListener list = (ITimeCompressionListener) listenerList.get(j);
750 if (mes1.getEndLifeline() != null) {
751 list.deltaSelected(mes1.getEndLifeline(), event1, event2 - event1, col[colIndex]);
752 } else if (mes2.getStartLifeline() != null) {
753 list.deltaSelected(mes2.getStartLifeline(), event1, event2 - event1, col[colIndex]);
df0b8ff4 754 } else {
73005152 755 list.deltaSelected(mes1.getStartLifeline(), event1, event2 - event1, col[colIndex]);
df0b8ff4 756 }
73005152
BH
757 }
758 }
759
760 /**
761 * Force the time compression bar to highlight the event occurrences between the two given messages. The event
762 * occurrences are highlighted on the first message's end lifeline
763 *
764 * @param mes1 the first message
df0b8ff4 765 * @param mes2 the second message
73005152
BH
766 */
767 public void highlightRegionSync(final BaseMessage mes1, final BaseMessage mes2) {
768 getDisplay().syncExec(new Runnable() {
769 @Override
770 public void run() {
771 highlightRegion(mes1, mes2);
772 }
773 });
774 }
775
df0b8ff4
BH
776 /*
777 * (non-Javadoc)
778 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#scrollBy(int, int)
779 */
73005152
BH
780 @Override
781 public void scrollBy(int x, int y) {
782 }
783
df0b8ff4
BH
784 /**
785 * Sets the zoom value.
786 *
787 * @param value The zoom value to set.
788 */
73005152
BH
789 public void setZoom(float value) {
790 zoomValue = value;
791 redraw();
792 }
793
df0b8ff4
BH
794 /**
795 * Adds a listener to the time compression listener list to be notified about selected deltas.
796 *
797 * @param listener The listener to add
798 */
73005152 799 public void addTimeCompressionListener(ITimeCompressionListener listener) {
df0b8ff4 800 if (!listenerList.contains(listener)) {
73005152 801 listenerList.add(listener);
df0b8ff4 802 }
73005152
BH
803 }
804
df0b8ff4
BH
805 /**
806 * Removes a time compression listener.
807 *
808 * @param listener The listener to remove.
809 */
73005152
BH
810 public void removeSelectionChangedListener(ITimeCompressionListener listener) {
811 listenerList.remove(listener);
812 }
813
df0b8ff4
BH
814 /*
815 * (non-Javadoc)
816 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
817 */
73005152
BH
818 @Override
819 public void widgetDisposed(DisposeEvent e) {
df0b8ff4 820 if (tooltip != null) {
73005152 821 tooltip.dispose();
df0b8ff4 822 }
73005152 823 super.removeDisposeListener(this);
df0b8ff4 824 for (int i = 0; i < col.length; i++) {
73005152 825 col[i].dispose();
df0b8ff4 826 }
73005152
BH
827 }
828
df0b8ff4
BH
829 /*
830 * (non-Javadoc)
831 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyPressedEvent(org.eclipse.swt.events.KeyEvent)
832 */
73005152
BH
833 @Override
834 protected void keyPressedEvent(KeyEvent _e) {
df0b8ff4 835 if (tooltip != null) {
73005152 836 tooltip.hideToolTip();
df0b8ff4 837 }
73005152
BH
838 if (!isFocusControl() || getViewControl().isFocusControl()) {
839 Control[] child = getParent().getChildren();
840 for (int i = 0; i < child.length; i++) {
841 if (child[i].isFocusControl()) {
842 // getViewControl().setFocus();
843 break;
844 }
845 }
846 }
847 setFocus(-1);
848
849 boolean top = false;
df0b8ff4 850 if (nextNodeY == 0) {
73005152 851 top = true;
df0b8ff4 852 }
73005152
BH
853 if ((frame != null) && (nextNodeY == 0)) {
854 for (int i = 0; i < nodeList.size() - 1 && i < 1; i++) {
855 SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
856 SDTimeEvent m2 = (SDTimeEvent) nodeList.get(i + 1);
857 if (SDViewPref.getInstance().excludeExternalTime()) {
858 if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
859 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
860 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
df0b8ff4 861 if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
73005152 862 continue;
df0b8ff4 863 }
73005152
BH
864 }
865 }
866
867 int y1 = ((GraphNode) m1.getGraphNode()).getY();
868 int y2 = ((GraphNode) m2.getGraphNode()).getY();
869 if (m1.getGraphNode() instanceof AsyncMessage) {
870 AsyncMessage as = (AsyncMessage) m1.getGraphNode();
df0b8ff4 871 if (as.getEndTime() == m1.getTime()) {
73005152 872 y1 += as.getHeight();
df0b8ff4 873 }
73005152
BH
874 }
875 if (m2.getGraphNode() instanceof AsyncMessage) {
876 AsyncMessage as = (AsyncMessage) m2.getGraphNode();
df0b8ff4 877 if (as.getEndTime() == m2.getTime()) {
73005152 878 y2 += as.getHeight();
df0b8ff4 879 }
73005152
BH
880 }
881 if (m1.getGraphNode() instanceof ExecutionOccurrence) {
882 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
df0b8ff4 883 if (m1.getEvent() == eo.getEndOccurrence()) {
73005152 884 y1 += eo.getHeight();
df0b8ff4 885 }
73005152
BH
886
887 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
888
889 ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
df0b8ff4 890 if (m2.getEvent() == eo2.getEndOccurrence()) {
73005152 891 y2 += eo2.getHeight();
df0b8ff4 892 }
73005152
BH
893 }
894 }
895 prevNodeY = Math.round(y1 * zoomValue);
896 nextNodeY = Math.round(y2 * zoomValue);
897 }
898 }
899
df0b8ff4 900 if (ll != null) {
73005152
BH
901 for (int j = 0; j < listenerList.size(); j++) {
902 ITimeCompressionListener list = (ITimeCompressionListener) listenerList.get(j);
903 list.deltaSelected(ll, ls, ln, lc);
904 }
df0b8ff4 905 }
73005152
BH
906
907 if (_e.keyCode == SWT.ARROW_DOWN) {
df0b8ff4 908 if (!top) {
73005152 909 selectTimeDelta(nextNodeY + 1, 1);
df0b8ff4 910 } else {
73005152 911 selectTimeDelta(prevNodeY + 1, 1);
df0b8ff4 912 }
73005152
BH
913 setFocus(1);
914 } else if (_e.keyCode == SWT.ARROW_UP) {
915 selectTimeDelta(prevNodeY - 1, 2);
916 setFocus(1);
917 } else if (_e.keyCode == SWT.ARROW_RIGHT) {
918 selectTimeDelta(prevNodeY, 1);
919 setFocus(1);
920 }
921 super.keyPressedEvent(_e);
922 }
923
df0b8ff4
BH
924 /*
925 * (non-Javadoc)
926 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.ScrollView#keyReleasedEvent(org.eclipse.swt.events.KeyEvent)
927 */
73005152
BH
928 @Override
929 protected void keyReleasedEvent(KeyEvent _e) {
930 super.keyReleasedEvent(_e);
931 }
932
933 /**
df0b8ff4 934 * Selects the time delta for given delta y coordinate and direction.
73005152 935 *
df0b8ff4
BH
936 * @param dy The delta in y coordinate.
937 * @param direction 0 no direction, 1 = down, 2 = up
73005152
BH
938 */
939 protected void selectTimeDelta(int dy, int direction) {
940 SDTimeEvent lastM1 = null;
941 SDTimeEvent lastM2 = null;
942 int lastY1 = 0;
943 int lastY2 = 0;
944 boolean done = false;
945 if (frame != null) {
946 for (int i = 0; i < nodeList.size() - 1; i++) {
947 SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
948 SDTimeEvent m2 = (SDTimeEvent) nodeList.get(i + 1);
949 if (SDViewPref.getInstance().excludeExternalTime()) {
950 if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
951 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
952 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
df0b8ff4 953 if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
73005152 954 continue;
df0b8ff4 955 }
73005152
BH
956 }
957 }
958
959 int y1 = ((GraphNode) m1.getGraphNode()).getY();
960 int y2 = ((GraphNode) m2.getGraphNode()).getY();
961 if (m1.getGraphNode() instanceof AsyncMessage) {
962 AsyncMessage as = (AsyncMessage) m1.getGraphNode();
df0b8ff4 963 if (as.getEndTime() == m1.getTime()) {
73005152 964 y1 += as.getHeight();
df0b8ff4 965 }
73005152
BH
966 }
967 if (m2.getGraphNode() instanceof AsyncMessage) {
968 AsyncMessage as = (AsyncMessage) m2.getGraphNode();
df0b8ff4 969 if (as.getEndTime() == m2.getTime()) {
73005152 970 y2 += as.getHeight();
df0b8ff4 971 }
73005152
BH
972 }
973 if (m1.getGraphNode() instanceof ExecutionOccurrence) {
974 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
df0b8ff4 975 if (m1.getEvent() == eo.getEndOccurrence()) {
73005152 976 y1 += eo.getHeight();
df0b8ff4 977 }
73005152
BH
978
979 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
73005152 980 ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
df0b8ff4 981 if (m2.getEvent() == eo2.getEndOccurrence()) {
73005152 982 y2 += eo2.getHeight();
df0b8ff4 983 }
73005152
BH
984 }
985 }
986 int m1Y = Math.round(y1 * zoomValue);
987 int m2Y = Math.round(y2 * zoomValue);
988
989 if ((m1Y < dy) && (m2Y > dy) || (!done && m2Y > dy && direction == 1 && lastM1 != null) || (!done && m1Y > dy && direction == 2 && lastM1 != null)) {
990 if (m1Y > dy && direction == 2) {
991 m1 = lastM1;
992 m2 = lastM2;
993 m1Y = lastY1;
994 m2Y = lastY2;
995 }
996 done = true;
997 prevNodeY = m1Y;
998 nextNodeY = m2Y;
df0b8ff4 999 ITmfTimestamp minMaxdelta = max.getDelta(min);
73005152
BH
1000 double gr = (minMaxdelta.getValue()) / (double) 10;
1001
df0b8ff4 1002 ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
73005152
BH
1003 long absDelta = Math.abs(delta.getValue());
1004
1005 int colIndex = 0;
1006 if (gr != 0) {
1007 colIndex = Math.round((float) (absDelta / gr));
df0b8ff4 1008 if (colIndex >= col.length) {
73005152 1009 colIndex = col.length - 1;
df0b8ff4 1010 } else if (colIndex < 0) {
73005152 1011 colIndex = 0;
df0b8ff4
BH
1012 }
1013 } else {
73005152 1014 colIndex = 0;
df0b8ff4 1015 }
73005152
BH
1016 if (m1.getGraphNode() instanceof BaseMessage) {
1017 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
1018 if (mes1.getEndLifeline() != null) {
1019 ll = mes1.getEndLifeline();
1020 ls = m1.getEvent();
1021 ln = m2.getEvent() - m1.getEvent();
1022 lc = col[colIndex];
1023 } else if (m2.getGraphNode() instanceof BaseMessage && ((BaseMessage) m2.getGraphNode()).getStartLifeline() != null) {
1024 ll = ((BaseMessage) m2.getGraphNode()).getStartLifeline();
1025 ls = m1.getEvent();
1026 ln = m2.getEvent() - m1.getEvent();
1027 lc = col[colIndex];
1028 } else {
1029 ll = mes1.getStartLifeline();
1030 ls = m1.getEvent();
1031 ln = m2.getEvent() - m1.getEvent();
1032 lc = col[colIndex];
1033 }
1034 } else if (m1.getGraphNode() instanceof ExecutionOccurrence) {
1035 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
1036 ExecutionOccurrence eo = (ExecutionOccurrence) m2.getGraphNode();
1037 ll = eo.getLifeline();
1038 ls = m1.getEvent();
1039 ln = m2.getEvent() - m1.getEvent();
1040 lc = col[colIndex];
1041 } else {
1042 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
1043 ll = eo.getLifeline();
1044 ls = m1.getEvent();
1045 ln = m2.getEvent() - m1.getEvent();
1046 lc = col[colIndex];
1047 }
1048 }
1049 for (int j = 0; j < listenerList.size(); j++) {
1050 ITimeCompressionListener list = (ITimeCompressionListener) listenerList.get(j);
1051 list.deltaSelected(ll, ls, ln, lc);
1052 }
1053 break;
1054 } else {
1055 lastM1 = m1;
1056 lastM2 = m2;
1057 lastY1 = m1Y;
1058 lastY2 = m2Y;
1059 }
1060 }
1061 }
1062 }
1063
df0b8ff4
BH
1064 /**
1065 * Creates a fake tool tip.
1066 */
73005152
BH
1067 protected void createFakeTooltip() {
1068 if (tooltip == null) {
1069 tooltip = new DrawableToolTip(this);
1070 }
df0b8ff4 1071
73005152
BH
1072 if (frame != null) {
1073 setFocus(0);
1074 for (int i = 0; i < nodeList.size() - 1; i++) {
1075 SDTimeEvent m1 = (SDTimeEvent) nodeList.get(i);
1076 SDTimeEvent m2 = (SDTimeEvent) nodeList.get(i + 1);
1077
1078 if (SDViewPref.getInstance().excludeExternalTime()) {
1079 if ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage)) {
1080 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
1081 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
df0b8ff4 1082 if ((mes2.getStartLifeline() == null) || (mes1.getEndLifeline() == null)) {
73005152 1083 continue;
df0b8ff4 1084 }
73005152
BH
1085 }
1086 }
1087
1088 int y1 = ((GraphNode) m1.getGraphNode()).getY();
1089 int y2 = ((GraphNode) m2.getGraphNode()).getY();
1090
1091 if (m1.getGraphNode() instanceof AsyncMessage) {
1092 AsyncMessage as = (AsyncMessage) m1.getGraphNode();
df0b8ff4 1093 if (as.getEndTime() == m1.getTime()) {
73005152 1094 y1 += as.getHeight();
df0b8ff4 1095 }
73005152
BH
1096 }
1097 if (m2.getGraphNode() instanceof AsyncMessage) {
1098 AsyncMessage as = (AsyncMessage) m2.getGraphNode();
df0b8ff4 1099 if (as.getEndTime() == m2.getTime()) {
73005152 1100 y2 += as.getHeight();
df0b8ff4 1101 }
73005152
BH
1102 }
1103 if (m1.getGraphNode() instanceof ExecutionOccurrence) {
1104 ExecutionOccurrence eo = (ExecutionOccurrence) m1.getGraphNode();
df0b8ff4 1105 if (m1.getEvent() == eo.getEndOccurrence()) {
73005152 1106 y1 += eo.getHeight();
df0b8ff4 1107 }
73005152
BH
1108
1109 if (m2.getGraphNode() instanceof ExecutionOccurrence) {
1110
1111 ExecutionOccurrence eo2 = (ExecutionOccurrence) m2.getGraphNode();
df0b8ff4 1112 if (m2.getEvent() == eo2.getEndOccurrence()) {
73005152 1113 y2 += eo2.getHeight();
df0b8ff4 1114 }
73005152
BH
1115 }
1116 }
1117 int m1Y = Math.round(y1 * zoomValue);
1118 int m2Y = Math.round(y2 * zoomValue);
1119 if ((m1Y < prevNodeY + 1) && (m2Y >= prevNodeY + 1)) {
df0b8ff4 1120 ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
73005152
BH
1121 tooltip.showToolTip(delta, min, max);
1122 tooltip.hideToolTip();
1123 }
1124 }
1125 }
1126 }
1127}
This page took 0.079134 seconds and 5 git commands to generate.