Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
df0b8ff4 | 2 | * Copyright (c) 2005, 2008 IBM Corporation and others. |
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 | |
013a5f1c AM |
7 | * |
8 | * Contributors: | |
73005152 BH |
9 | * IBM - Initial API and implementation |
10 | * Bernd Hufmann - Updated for TMF | |
11 | **********************************************************************/ | |
12 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core; | |
13 | ||
14 | import java.util.Comparator; | |
15 | ||
4df4581d | 16 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
6c13869b | 17 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; |
73005152 | 18 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC; |
df0b8ff4 | 19 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences; |
3145ec83 | 20 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref; |
73005152 BH |
21 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortAsyncForBackward; |
22 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SortAsyncMessageComparator; | |
23 | ||
24 | /** | |
25 | * A AsyncMessage is a asynchronous message which appear at two different event occurrences on each lifeline ends (sender | |
26 | * and receiver).<br> | |
27 | * <br> | |
28 | * <br> | |
29 | * Usage example: | |
013a5f1c | 30 | * |
73005152 BH |
31 | * <pre> |
32 | * Frame frame; | |
33 | * Lifeline lifeLine1; | |
34 | * Lifeline lifeLine2; | |
013a5f1c | 35 | * |
73005152 BH |
36 | * AsyncMessage message = new AsyncMessage(); |
37 | * // Create a new event occurrence on each lifeline | |
38 | * lifeline1.getNewOccurrenceIndex(); | |
39 | * lifeline2.getNewOccurrenceIndex(); | |
40 | * // Set the message sender and receiver | |
41 | * message.setStartLifeline(lifeLine1); | |
42 | * message.setEndLifline(lifeline2); | |
43 | * message.setName("Message label"); | |
44 | * // add the message to the frame | |
45 | * frame.addMessage(message); | |
46 | * </pre> | |
013a5f1c | 47 | * |
73005152 | 48 | * @see Lifeline Lifeline for more event occurence details |
013a5f1c | 49 | * @version 1.0 |
73005152 | 50 | * @author sveyrier |
73005152 BH |
51 | */ |
52 | public class AsyncMessage extends BaseMessage implements ITimeRange { | |
53 | ||
df0b8ff4 BH |
54 | // ------------------------------------------------------------------------ |
55 | // Constants | |
56 | // ------------------------------------------------------------------------ | |
57 | /** | |
58 | * The grahNode ID constant | |
59 | */ | |
60 | public static final String ASYNC_MESS_TAG = "AsyncMessage"; //$NON-NLS-1$ | |
61 | ||
62 | // ------------------------------------------------------------------------ | |
63 | // Attributes | |
64 | // ------------------------------------------------------------------------ | |
65 | /** | |
66 | * Flag whether message has time information or not. | |
67 | */ | |
eb63f5ff | 68 | protected boolean fHasTime = false; |
73005152 BH |
69 | /** |
70 | * The time when the message begin | |
71 | */ | |
eb63f5ff | 72 | protected ITmfTimestamp fEndTime = new TmfTimestamp(); |
73005152 BH |
73 | /** |
74 | * The time when the message end | |
75 | */ | |
eb63f5ff | 76 | protected ITmfTimestamp fStartTime = new TmfTimestamp(); |
73005152 BH |
77 | /** |
78 | * The associated message. | |
79 | */ | |
eb63f5ff | 80 | protected AsyncMessageReturn fMessageReturn = null; |
73005152 | 81 | |
df0b8ff4 BH |
82 | // ------------------------------------------------------------------------ |
83 | // Constructors | |
84 | // ------------------------------------------------------------------------ | |
85 | /** | |
86 | * Default constructor | |
87 | */ | |
73005152 | 88 | public AsyncMessage() { |
eb63f5ff | 89 | fPrefId = ISDPreferences.PREF_ASYNC_MESS; |
73005152 BH |
90 | } |
91 | ||
df0b8ff4 BH |
92 | // ------------------------------------------------------------------------ |
93 | // Methods | |
94 | // ------------------------------------------------------------------------ | |
95 | /* | |
96 | * (non-Javadoc) | |
97 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getX() | |
98 | */ | |
73005152 BH |
99 | @Override |
100 | public int getX() { | |
101 | int x = super.getX(true); | |
102 | int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2; | |
eb63f5ff | 103 | if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) { |
73005152 BH |
104 | activationWidth = -activationWidth; |
105 | } | |
106 | ||
eb63f5ff | 107 | if (isMessageStartInActivation(fStartEventOccurrence)) { |
73005152 BH |
108 | x = x + activationWidth; |
109 | } | |
110 | return x; | |
111 | } | |
013a5f1c | 112 | |
df0b8ff4 BH |
113 | /* |
114 | * (non-Javadoc) | |
115 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getY() | |
116 | */ | |
73005152 BH |
117 | @Override |
118 | public int getY() { | |
eb63f5ff BH |
119 | if ((fStartLifeline != null) && (fEndLifeline != null)) { |
120 | return fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fStartEventOccurrence; | |
73005152 BH |
121 | } |
122 | return super.getY(); | |
123 | } | |
124 | ||
df0b8ff4 BH |
125 | /* |
126 | * (non-Javadoc) | |
127 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getWidth() | |
128 | */ | |
73005152 BH |
129 | @Override |
130 | public int getWidth() { | |
131 | int width = super.getWidth(true); | |
132 | int activationWidth = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2; | |
eb63f5ff | 133 | if ((fStartLifeline != null) && (fEndLifeline != null) && (fStartLifeline.getX() > fEndLifeline.getX())) { |
73005152 BH |
134 | activationWidth = -activationWidth; |
135 | } | |
136 | ||
eb63f5ff | 137 | if (isMessageStartInActivation(fStartEventOccurrence)) { |
73005152 | 138 | width = width - activationWidth; |
df0b8ff4 | 139 | } |
73005152 | 140 | |
eb63f5ff | 141 | if (isMessageEndInActivation(fEndEventOccurrence)) { |
73005152 | 142 | width = width - activationWidth; |
df0b8ff4 | 143 | } |
73005152 BH |
144 | |
145 | return width; | |
146 | } | |
147 | ||
df0b8ff4 BH |
148 | /* |
149 | * (non-Javadoc) | |
150 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#getHeight() | |
151 | */ | |
73005152 BH |
152 | @Override |
153 | public int getHeight() { | |
eb63f5ff BH |
154 | if ((fStartLifeline != null) && (fEndLifeline != null)) { |
155 | return (fEndLifeline.getY() + fEndLifeline.getHeight() + (Metrics.getMessageFontHeigth() + Metrics.getMessagesSpacing()) * fEndEventOccurrence) - getY(); | |
73005152 BH |
156 | } |
157 | return super.getHeight(); | |
158 | } | |
159 | ||
160 | /** | |
161 | * Set the message return associated with this message. | |
013a5f1c | 162 | * |
73005152 BH |
163 | * @param message the message return to associate |
164 | */ | |
165 | protected void setMessageReturn(AsyncMessageReturn message) { | |
eb63f5ff | 166 | fMessageReturn = message; |
73005152 BH |
167 | } |
168 | ||
169 | /** | |
170 | * Set the event occurrence attached to this message for its end lifeline | |
013a5f1c | 171 | * |
73005152 BH |
172 | * @param occurrence the event occurrence to set |
173 | */ | |
174 | public void setEndOccurrence(int occurrence) { | |
eb63f5ff | 175 | fEndEventOccurrence = occurrence; |
df0b8ff4 | 176 | if (getStartLifeline() == null) { |
eb63f5ff | 177 | fStartEventOccurrence = occurrence; |
df0b8ff4 | 178 | } |
73005152 BH |
179 | informFrame(getEndLifeline(), occurrence); |
180 | } | |
181 | ||
df0b8ff4 BH |
182 | /** |
183 | * Informs the given lifeline about the maximum occurrence if applicable. | |
013a5f1c | 184 | * |
df0b8ff4 BH |
185 | * @param lifeLine |
186 | * @param occurrence | |
187 | */ | |
73005152 | 188 | protected void informFrame(Lifeline lifeLine, int occurrence) { |
df0b8ff4 BH |
189 | if ((lifeLine != null) && (lifeLine.getFrame() != null) && (lifeLine.getFrame().getMaxEventOccurrence() < occurrence)) { |
190 | lifeLine.getFrame().setMaxEventOccurrence(occurrence); | |
191 | } | |
73005152 BH |
192 | } |
193 | ||
194 | /** | |
195 | * Set the event occurrence attached to this message for its start lifeline | |
013a5f1c | 196 | * |
73005152 BH |
197 | * @param occurrence the event occurrence to set |
198 | */ | |
199 | public void setStartOccurrence(int occurrence) { | |
eb63f5ff | 200 | fStartEventOccurrence = occurrence; |
df0b8ff4 | 201 | if (getEndLifeline() == null) { |
eb63f5ff | 202 | fEndEventOccurrence = fStartEventOccurrence; |
df0b8ff4 | 203 | } |
73005152 BH |
204 | informFrame(getStartLifeline(), occurrence); |
205 | } | |
206 | ||
207 | /** | |
208 | * Set the lifeLine which has sent the message.<br> | |
209 | * A new EventOccurence will be create on this lifeLine.<br> | |
013a5f1c | 210 | * |
73005152 | 211 | * @param lifeline the message sender |
73005152 BH |
212 | */ |
213 | public void autoSetStartLifeline(Lifeline lifeline) { | |
214 | lifeline.getNewEventOccurrence(); | |
215 | setStartLifeline(lifeline); | |
216 | } | |
217 | ||
218 | /** | |
219 | * Set the lifeLine which has received the message.<br> | |
220 | * A new EventOccurence will be create on this lifeLine.<br> | |
013a5f1c | 221 | * |
73005152 | 222 | * @param lifeline the message receiver |
73005152 BH |
223 | */ |
224 | public void autoSetEndLifeline(Lifeline lifeline) { | |
225 | lifeline.getNewEventOccurrence(); | |
226 | setEndLifeline(lifeline); | |
227 | } | |
228 | ||
df0b8ff4 BH |
229 | /* |
230 | * (non-Javadoc) | |
231 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setStartLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline) | |
73005152 BH |
232 | */ |
233 | @Override | |
234 | public void setStartLifeline(Lifeline lifeline) { | |
235 | super.setStartLifeline(lifeline); | |
236 | setStartOccurrence(getStartLifeline().getEventOccurrence()); | |
df0b8ff4 | 237 | if (getEndLifeline() == null) { |
eb63f5ff | 238 | fEndEventOccurrence = fStartEventOccurrence; |
df0b8ff4 | 239 | } |
73005152 BH |
240 | } |
241 | ||
df0b8ff4 BH |
242 | /* |
243 | * (non-Javadoc) | |
244 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#setEndLifeline(org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline) | |
73005152 BH |
245 | */ |
246 | @Override | |
247 | public void setEndLifeline(Lifeline lifeline) { | |
248 | super.setEndLifeline(lifeline); | |
249 | setEventOccurrence(getEndLifeline().getEventOccurrence()); | |
250 | } | |
251 | ||
252 | /** | |
253 | * Returns true if the point C is on the segment defined with the point A and B | |
013a5f1c | 254 | * |
73005152 BH |
255 | * @param xA point A x coordinate |
256 | * @param yA point A y coordinate | |
257 | * @param xB point B x coordinate | |
258 | * @param yB point B y coordinate | |
259 | * @param xC point C x coordinate | |
260 | * @param yC point C y coordinate | |
261 | * @return Return true if the point C is on the segment defined with the point A and B, else otherwise | |
262 | */ | |
263 | protected boolean isNearSegment(int xA, int yA, int xB, int yB, int xC, int yC) { | |
df0b8ff4 | 264 | if ((xA > xB) && (xC > xA)) { |
73005152 | 265 | return false; |
df0b8ff4 BH |
266 | } |
267 | if ((xA < xB) && (xC > xB)) { | |
73005152 | 268 | return false; |
df0b8ff4 BH |
269 | } |
270 | if ((xA < xB) && (xC < xA)) { | |
73005152 | 271 | return false; |
df0b8ff4 BH |
272 | } |
273 | if ((xA > xB) && (xC < xB)) { | |
73005152 | 274 | return false; |
df0b8ff4 | 275 | } |
73005152 BH |
276 | double distAB = Math.sqrt((xB - xA) * (xB - xA) + (yB - yA) * (yB - yA)); |
277 | double scalar = ((xB - xA) * (xC - xA) + (yB - yA) * (yC - yA)) / distAB; | |
278 | double distAC = Math.sqrt((xC - xA) * (xC - xA) + (yC - yA) * (yC - yA)); | |
279 | double distToSegment = Math.sqrt(Math.abs(distAC * distAC - scalar * scalar)); | |
df0b8ff4 | 280 | if (distToSegment <= Metrics.MESSAGE_SELECTION_TOLERANCE) { |
73005152 | 281 | return true; |
df0b8ff4 | 282 | } |
73005152 BH |
283 | return false; |
284 | } | |
285 | ||
df0b8ff4 BH |
286 | /* |
287 | * (non-Javadoc) | |
288 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#contains(int, int) | |
289 | */ | |
73005152 BH |
290 | @Override |
291 | public boolean contains(int x, int y) { | |
292 | // Is it a self message? | |
eb63f5ff | 293 | if (fStartLifeline == fEndLifeline) { |
73005152 BH |
294 | return super.contains(x, y); |
295 | } | |
013a5f1c | 296 | if (isNearSegment(getX(), getY(), getX() + getWidth(), getY() + getHeight(), x, y)) { |
73005152 | 297 | return true; |
013a5f1c | 298 | } |
73005152 BH |
299 | int messageMaxWidth = Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH; |
300 | int nameWidth = getName().length() * Metrics.getAverageCharWidth(); | |
301 | if (getName().length() * Metrics.getAverageCharWidth() > messageMaxWidth) { | |
df0b8ff4 | 302 | if (Frame.contains(getX(), getY() - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), messageMaxWidth, Metrics.getMessageFontHeigth(), x, y)) { |
73005152 | 303 | return true; |
df0b8ff4 | 304 | } |
73005152 | 305 | } else { |
df0b8ff4 | 306 | if (Frame.contains(getX() + (messageMaxWidth - nameWidth) / 2, getY() + getHeight() / 2 - Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), nameWidth, Metrics.getMessageFontHeigth(), x, y)) { |
73005152 | 307 | return true; |
df0b8ff4 | 308 | } |
73005152 BH |
309 | } |
310 | return false; | |
311 | } | |
312 | ||
df0b8ff4 BH |
313 | /** |
314 | * Draws the asynchronous message using giving graphical context. | |
013a5f1c | 315 | * |
df0b8ff4 BH |
316 | * @param context A graphical context to draw in. |
317 | */ | |
73005152 | 318 | protected void drawAsyncMessage(IGC context) { |
eb63f5ff | 319 | if (fStartLifeline != null && fEndLifeline != null && fStartLifeline == fEndLifeline && (fStartEventOccurrence != fEndEventOccurrence)) { |
73005152 BH |
320 | int x = getX(); |
321 | int y = getY(); | |
322 | int height = getHeight(); | |
323 | int tempx = 0; | |
eb63f5ff BH |
324 | boolean startInActivation = isMessageStartInActivation(fStartEventOccurrence); |
325 | boolean endInActivation = isMessageEndInActivation(fEndEventOccurrence); | |
73005152 | 326 | |
df0b8ff4 | 327 | if (endInActivation && !startInActivation) { |
73005152 | 328 | tempx = Metrics.EXECUTION_OCCURRENCE_WIDTH / 2; |
df0b8ff4 BH |
329 | } |
330 | if (startInActivation && !endInActivation) { | |
73005152 | 331 | tempx = -Metrics.EXECUTION_OCCURRENCE_WIDTH / 2; |
df0b8ff4 | 332 | } |
73005152 BH |
333 | |
334 | int tempy = Metrics.INTERNAL_MESSAGE_WIDTH / 2; | |
df0b8ff4 | 335 | if (getHeight() <= Metrics.INTERNAL_MESSAGE_WIDTH) { |
73005152 | 336 | tempy = getHeight() / 2; |
df0b8ff4 | 337 | } |
73005152 BH |
338 | |
339 | context.drawLine(x, y, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y); | |
340 | context.drawLine(x + Metrics.INTERNAL_MESSAGE_WIDTH, y + tempy, x + Metrics.INTERNAL_MESSAGE_WIDTH, y + height - tempy); | |
341 | context.drawLine(x + tempx, y + height, x + Metrics.INTERNAL_MESSAGE_WIDTH / 2, y + height); | |
342 | ||
eb63f5ff BH |
343 | Double xt = Double.valueOf(Math.cos(0.75) * 7); |
344 | Double yt = Double.valueOf(Math.sin(0.75) * 7); | |
73005152 BH |
345 | |
346 | context.drawLine(x + xt.intValue() + tempx, y + height + yt.intValue(), x + tempx, y + height); | |
347 | context.drawArc(x, y, Metrics.INTERNAL_MESSAGE_WIDTH, 2 * tempy, 0, 90); | |
348 | context.drawArc(x, y + height, Metrics.INTERNAL_MESSAGE_WIDTH, -2 * tempy, 0, -90); | |
349 | context.drawLine(x + xt.intValue() + tempx, y + height - yt.intValue(), x + tempx, y + height); | |
350 | ||
351 | context.drawTextTruncated(getName(), x + Metrics.INTERNAL_MESSAGE_WIDTH + Metrics.INTERNAL_MESSAGE_V_MARGIN, y, Metrics.swimmingLaneWidth() - Metrics.EXECUTION_OCCURRENCE_WIDTH + -Metrics.INTERNAL_MESSAGE_WIDTH, | |
352 | +Metrics.MESSAGES_NAME_SPACING - Metrics.getMessageFontHeigth(), !isSelected()); | |
df0b8ff4 | 353 | } else { |
73005152 | 354 | super.draw(context); |
df0b8ff4 | 355 | } |
73005152 BH |
356 | } |
357 | ||
df0b8ff4 BH |
358 | /* |
359 | * (non-Javadoc) | |
360 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#draw(org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC) | |
73005152 BH |
361 | */ |
362 | @Override | |
363 | public void draw(IGC context) { | |
df0b8ff4 | 364 | if (!isVisible()) { |
73005152 | 365 | return; |
df0b8ff4 | 366 | } |
3145ec83 BH |
367 | |
368 | ISDPreferences pref = SDViewPref.getInstance(); | |
369 | ||
73005152 | 370 | // Draw it selected? |
eb63f5ff | 371 | if (isSelected() && (fStartLifeline != null && fEndLifeline != null && fStartLifeline == fEndLifeline && (fStartEventOccurrence != fEndEventOccurrence))) { |
73005152 BH |
372 | /* |
373 | * Draw it twice First time, bigger inverting selection colors Second time, regular drawing using selection | |
374 | * colors This create the highlight effect | |
375 | */ | |
3145ec83 | 376 | context.setForeground(pref.getBackGroundColorSelection()); |
73005152 BH |
377 | context.setLineWidth(Metrics.SELECTION_LINE_WIDTH); |
378 | drawAsyncMessage(context); | |
3145ec83 BH |
379 | context.setBackground(pref.getBackGroundColorSelection()); |
380 | context.setForeground(pref.getForeGroundColorSelection()); | |
73005152 BH |
381 | // Second drawing is done after the else |
382 | } else { | |
3145ec83 BH |
383 | context.setBackground(pref.getBackGroundColor(fPrefId)); |
384 | context.setForeground(pref.getForeGroundColor(fPrefId)); | |
73005152 BH |
385 | } |
386 | if (hasFocus()) { | |
387 | context.setDrawTextWithFocusStyle(true); | |
388 | } | |
389 | context.setLineWidth(Metrics.NORMAL_LINE_WIDTH); | |
390 | drawAsyncMessage(context); | |
391 | if (hasFocus()) { | |
392 | context.setDrawTextWithFocusStyle(false); | |
393 | } | |
394 | } | |
395 | ||
396 | /** | |
397 | * Set the time when the message end | |
013a5f1c | 398 | * |
73005152 BH |
399 | * @param time the time when the message end |
400 | */ | |
4df4581d | 401 | public void setEndTime(ITmfTimestamp time) { |
eb63f5ff BH |
402 | fEndTime = time.clone(); |
403 | fHasTime = true; | |
df0b8ff4 | 404 | if (getStartLifeline() != null && getStartLifeline().getFrame() != null) { |
73005152 | 405 | getStartLifeline().getFrame().setHasTimeInfo(true); |
df0b8ff4 | 406 | } else if (getEndLifeline() != null && getEndLifeline().getFrame() != null) { |
73005152 | 407 | getEndLifeline().getFrame().setHasTimeInfo(true); |
df0b8ff4 | 408 | } |
73005152 BH |
409 | } |
410 | ||
411 | /** | |
412 | * Set the time when the message start | |
013a5f1c | 413 | * |
73005152 BH |
414 | * @param time the time when the message start |
415 | */ | |
4df4581d | 416 | public void setStartTime(ITmfTimestamp time) { |
eb63f5ff BH |
417 | fStartTime = time.clone(); |
418 | fHasTime = true; | |
df0b8ff4 | 419 | if (getStartLifeline() != null && getStartLifeline().getFrame() != null) { |
73005152 | 420 | getStartLifeline().getFrame().setHasTimeInfo(true); |
df0b8ff4 | 421 | } else if (getEndLifeline() != null && getEndLifeline().getFrame() != null) { |
73005152 | 422 | getEndLifeline().getFrame().setHasTimeInfo(true); |
df0b8ff4 | 423 | } |
73005152 BH |
424 | } |
425 | ||
df0b8ff4 BH |
426 | /* |
427 | * (non-Javadoc) | |
428 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getEndTime() | |
73005152 BH |
429 | */ |
430 | @Override | |
4df4581d | 431 | public ITmfTimestamp getEndTime() { |
eb63f5ff | 432 | return fEndTime; |
73005152 BH |
433 | } |
434 | ||
df0b8ff4 BH |
435 | /* |
436 | * (non-Javadoc) | |
437 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#getStartTime() | |
73005152 BH |
438 | */ |
439 | @Override | |
4df4581d | 440 | public ITmfTimestamp getStartTime() { |
eb63f5ff | 441 | return fStartTime; |
73005152 BH |
442 | } |
443 | ||
df0b8ff4 BH |
444 | /* |
445 | * (non-Javadoc) | |
446 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.ITimeRange#hasTimeInfo() | |
447 | */ | |
73005152 BH |
448 | @Override |
449 | public boolean hasTimeInfo() { | |
eb63f5ff | 450 | return fHasTime; |
73005152 BH |
451 | } |
452 | ||
df0b8ff4 BH |
453 | /* |
454 | * (non-Javadoc) | |
455 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage#isVisible(int, int, int, int) | |
456 | */ | |
73005152 BH |
457 | @Override |
458 | public boolean isVisible(int x, int y, int width, int height) { | |
459 | int toDrawY = getY(); | |
460 | int toDrawHeight = getHeight(); | |
df0b8ff4 | 461 | if ((toDrawY > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth()) && (toDrawY + toDrawHeight > y + height + Metrics.MESSAGES_NAME_SPACING + Metrics.getMessageFontHeigth())) { |
73005152 | 462 | return false; |
df0b8ff4 BH |
463 | } |
464 | if (toDrawY < y && (toDrawY + toDrawHeight < y)) { | |
73005152 | 465 | return false; |
df0b8ff4 | 466 | } |
73005152 BH |
467 | return super.isVisible(x, y, width, height); |
468 | } | |
469 | ||
df0b8ff4 BH |
470 | /* |
471 | * (non-Javadoc) | |
472 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getComparator() | |
473 | */ | |
73005152 BH |
474 | @Override |
475 | public Comparator<GraphNode> getComparator() { | |
476 | return new SortAsyncMessageComparator(); | |
477 | } | |
478 | ||
df0b8ff4 BH |
479 | /* |
480 | * (non-Javadoc) | |
481 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getArrayId() | |
482 | */ | |
73005152 BH |
483 | @Override |
484 | public String getArrayId() { | |
485 | return ASYNC_MESS_TAG; | |
486 | } | |
487 | ||
df0b8ff4 BH |
488 | /* |
489 | * (non-Javadoc) | |
490 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getBackComparator() | |
491 | */ | |
73005152 BH |
492 | @Override |
493 | public Comparator<GraphNode> getBackComparator() { | |
494 | return new SortAsyncForBackward(); | |
495 | } | |
496 | ||
df0b8ff4 BH |
497 | /* |
498 | * (non-Javadoc) | |
499 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#positiveDistanceToPoint(int, int) | |
500 | */ | |
73005152 BH |
501 | @Override |
502 | public boolean positiveDistanceToPoint(int x, int y) { | |
503 | int mY = getY(); | |
504 | int mH = getHeight(); | |
df0b8ff4 | 505 | if ((mY > y) || (mY + mH > y)) { |
73005152 | 506 | return true; |
df0b8ff4 | 507 | } |
73005152 BH |
508 | return false; |
509 | } | |
510 | } |