ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / BasicFrame.java
CommitLineData
73005152 1/**********************************************************************
c8422608 2 * Copyright (c) 2005, 2013 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
a55887ca
AM
7 *
8 * Contributors:
c8422608
AM
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
73005152
BH
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
14
15import java.util.ArrayList;
16import java.util.Iterator;
17import java.util.List;
18
3bd46eef
AM
19import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
20import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
73005152 21import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
df0b8ff4 22import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
73005152
BH
23import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
24
25/**
26 * The Frame class is the base sequence diagram graph nodes container.<br>
27 * For instance, only one frame can be drawn in the View.<br>
28 * Lifelines, Messages and Stop which are supposed to represent a Sequence diagram are drawn in a Frame.<br>
29 * Only the graph node added to their representing list will be drawn.
a55887ca 30 *
73005152
BH
31 * The lifelines are appended along the X axsis when added in a frame.<br>
32 * The syncMessages are ordered along the Y axsis depending on the event occurrence they are attached to.<br>
a55887ca 33 *
73005152
BH
34 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
35 * @author sveyrier
36 * @version 1.0
37 */
38public class BasicFrame extends GraphNode {
39
df0b8ff4
BH
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
3145ec83 43
73005152
BH
44 /**
45 * Contains the max elapsed time between two consecutive messages in the whole frame
46 */
cab6c8ff 47 private ITmfTimestamp fMaxTime = new TmfTimestamp(0);
73005152
BH
48 /**
49 * Contains the min elapsed time between two consecutive messages in the whole frame
50 */
cab6c8ff 51 private ITmfTimestamp fMinTime = new TmfTimestamp(0);
73005152
BH
52 /**
53 * Indicate if the min and max elapsed time between two consecutive messages in the whole frame need to be computed
54 */
cab6c8ff 55 private boolean fComputeMinMax = true;
73005152
BH
56 /**
57 * Store the preference set by the user regarding the external time. This flag is used determine if the min and max
58 * need to be recomputed in case this preference is changed.
59 */
cab6c8ff 60 private boolean fLastExternalTimePref = SDViewPref.getInstance().excludeExternalTime();
73005152
BH
61 /**
62 * The greater event occurrence created on graph nodes drawn in this Frame This directly impact the Frame height
63 */
cab6c8ff 64 private int fVerticalIndex = 0;
73005152
BH
65 /**
66 * The index along the x axis where the next lifeline will is drawn This directly impact the Frame width
67 */
cab6c8ff 68 private int fHorizontalIndex = 0;
df0b8ff4 69 /**
eb63f5ff 70 * The time information flag.
df0b8ff4 71 */
cab6c8ff 72 private boolean fHasTimeInfo = false;
73005152 73 /**
df0b8ff4 74 * The current Frame visible area - x coordinates
73005152 75 */
cab6c8ff 76 private int fVisibleAreaX;
df0b8ff4
BH
77 /**
78 * The current Frame visible area - y coordinates
79 */
cab6c8ff 80 private int fVisibleAreaY;
df0b8ff4
BH
81 /**
82 * The current Frame visible area - width
83 */
cab6c8ff 84 private int fVisibleAreaWidth;
df0b8ff4
BH
85 /**
86 * The current Frame visible area - height
87 */
cab6c8ff 88 private int fVisibleAreaHeight;
df0b8ff4
BH
89 /**
90 * The event occurrence spacing (-1 for none)
91 */
cab6c8ff 92 private int fForceEventOccurrenceSpacing = -1;
df0b8ff4
BH
93 /**
94 * Flag to indicate customized minumum and maximum.
95 */
cab6c8ff 96 private boolean fCustomMinMax = false;
df0b8ff4
BH
97 /**
98 * The minimum time between messages of the sequence diagram frame.
99 */
cab6c8ff 100 private ITmfTimestamp fMinSDTime = new TmfTimestamp();
df0b8ff4
BH
101 /**
102 * The maximum time between messages of the sequence diagram frame.
103 */
cab6c8ff 104 private ITmfTimestamp fMaxSDTime = new TmfTimestamp();
df0b8ff4
BH
105 /**
106 * Flag to indicate that initial minimum has to be computed.
107 */
cab6c8ff 108 private boolean fInitSDMin = true;
73005152 109
df0b8ff4
BH
110 // ------------------------------------------------------------------------
111 // Constructors
112 // ------------------------------------------------------------------------
a55887ca 113
73005152
BH
114 /**
115 * Creates an empty frame.
116 */
117 public BasicFrame() {
eb63f5ff 118 Metrics.setForcedEventSpacing(fForceEventOccurrenceSpacing);
73005152
BH
119 }
120
df0b8ff4
BH
121 // ------------------------------------------------------------------------
122 // Methods
123 // ------------------------------------------------------------------------
124
73005152 125 /**
a55887ca 126 *
73005152 127 * Returns the greater event occurence known by the Frame
a55887ca 128 *
73005152
BH
129 * @return the greater event occurrence
130 */
131 protected int getMaxEventOccurrence() {
eb63f5ff 132 return fVerticalIndex;
73005152
BH
133 }
134
135 /**
136 * Set the greater event occurrence created in GraphNodes included in the frame
a55887ca 137 *
73005152
BH
138 * @param eventOccurrence the new greater event occurrence
139 */
140 protected void setMaxEventOccurrence(int eventOccurrence) {
eb63f5ff 141 fVerticalIndex = eventOccurrence;
73005152
BH
142 }
143
144 /**
145 * This method increase the lifeline place holder The return value is usually assign to a lifeline. This can be used
146 * to set the lifelines drawing order. Also, calling this method two times and assigning only the last given index
147 * to a lifeline will increase this lifeline draw spacing (2 times the default spacing) from the last added
148 * lifeline.
a55887ca 149 *
73005152
BH
150 * @return a new lifeline index
151 */
152 protected int getNewHorizontalIndex() {
eb63f5ff 153 return ++fHorizontalIndex;
73005152
BH
154 }
155
156 /**
157 * Returns the current horizontal index
a55887ca 158 *
73005152
BH
159 * @return the current horizontal index
160 * @see Frame#getNewHorizontalIndex() for horizontal index description
161 */
162 protected int getHorizontalIndex() {
eb63f5ff 163 return fHorizontalIndex;
73005152
BH
164 }
165
73005152
BH
166 @Override
167 public void addNode(GraphNode nodeToAdd) {
cab6c8ff 168 setComputeMinMax(true);
73005152
BH
169 super.addNode(nodeToAdd);
170 }
171
73005152
BH
172 @Override
173 public int getX() {
174 return Metrics.FRAME_H_MARGIN;
175 }
176
73005152
BH
177 @Override
178 public int getY() {
179 return Metrics.FRAME_V_MARGIN;
180 }
181
73005152
BH
182 @Override
183 public int getWidth() {
eb63f5ff 184 if (fHorizontalIndex == 0) {
73005152 185 return 3 * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 - Metrics.FRAME_H_MARGIN - Metrics.LIFELINE_SPACING / 2;
df0b8ff4 186 }
abbdd66a 187 return fHorizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
73005152
BH
188 }
189
73005152
BH
190 @Override
191 public int getHeight() {
df0b8ff4 192 // The Frame height depends on the maximum number of messages added to a lifeline
eb63f5ff 193 if (fVerticalIndex == 0) {
73005152
BH
194 return 5 * (Metrics.getMessagesSpacing() + Metrics.getMessageFontHeigth()) + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getFrameFontHeigth() + Metrics.LIFELINE_VT_MAGIN + Metrics.LIFELINE_VB_MAGIN
195 + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getLifelineFontHeigth() * 2;
df0b8ff4 196 }
eb63f5ff
BH
197 if (fForceEventOccurrenceSpacing >= 0) {
198 Metrics.setForcedEventSpacing(fForceEventOccurrenceSpacing);
df0b8ff4 199 }
eb63f5ff 200 return fVerticalIndex * (Metrics.getMessagesSpacing() + Metrics.getMessageFontHeigth()) + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getFrameFontHeigth() + Metrics.LIFELINE_VT_MAGIN + Metrics.LIFELINE_VB_MAGIN
73005152
BH
201 + Metrics.LIFELINE_NAME_H_MARGIN + Metrics.FRAME_NAME_H_MARGIN + Metrics.getLifelineFontHeigth() * 2;
202 }
203
cab6c8ff
BH
204 /**
205 * @return true if mininum and maximum time needs to be calculated else false
206 * @since 2.0
207 */
208 protected boolean isComputeMinMax() {
209 return fComputeMinMax;
210 }
211
212 /**
213 * @return true if mininum and maximum time needs to be calculated else false
214 * @since 2.0
215 */
216 protected boolean isCustomMinMax() {
217 return fCustomMinMax;
218 }
219
220 /**
221 * gets the initialization flag for SD minimum.
222 *
223 * @return the initialization flag for SD minimum
224 * @since 2.0
225 */
226 protected boolean getInitSDMin() {
227 return fInitSDMin;
228 }
229
73005152
BH
230 /**
231 * Returns the graph node which contains the point given in parameter for the given graph node list and starting the
232 * iteration at the given index<br>
233 * WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.<br>
a55887ca 234 *
73005152
BH
235 * @param x the x coordinate of the point to test
236 * @param y the y coordinate of the point to test
237 * @param list the list to search in
238 * @param fromIndex list browsing starting point
239 * @return the graph node containing the point given in parameter, null otherwise
df0b8ff4
BH
240 *
241 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#getNodeFromListAt(int, int, java.util.List, int)
73005152
BH
242 */
243 @Override
244 protected GraphNode getNodeFromListAt(int x, int y, List<GraphNode> list, int fromIndex) {
df0b8ff4 245 if (list == null) {
73005152 246 return null;
df0b8ff4 247 }
73005152 248 for (int i = fromIndex; i < list.size(); i++) {
abbdd66a 249 GraphNode node = list.get(i);
73005152
BH
250 // only lifeline list is x ordered
251 // Stop browsing the list if the node is outside the visible area
252 // all others nodes will be not visible
eb63f5ff 253 if ((node instanceof Lifeline) && (node.getX() > fVisibleAreaX + fVisibleAreaWidth)) {
73005152 254 break;
df0b8ff4 255 }
73005152 256 if (node.getHeight() < 0) {
eb63f5ff 257 if (node.getY() + node.getHeight() > fVisibleAreaY + fVisibleAreaHeight) {
73005152 258 break;
df0b8ff4 259 }
73005152 260 } else {
eb63f5ff 261 if (node.getY() > fVisibleAreaY + fVisibleAreaHeight) {
73005152 262 break;
df0b8ff4 263 }
73005152 264 }
df0b8ff4 265 if (node.contains(x, y)) {
73005152 266 return node;
df0b8ff4 267 }
73005152
BH
268 }
269 return null;
270 }
271
272 /**
273 * Draw the Frame rectangle
a55887ca 274 *
73005152
BH
275 * @param context the context to draw to
276 */
277 protected void drawFrame(IGC context) {
a55887ca 278
3145ec83 279 ISDPreferences pref = SDViewPref.getInstance();
a55887ca 280
3145ec83
BH
281 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
282 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_FRAME));
73005152
BH
283
284 int x = getX();
285 int y = getY();
286 int w = getWidth();
287 int h = getHeight();
288
289 // Draw the frame main rectangle
290 context.fillRectangle(x, y, w, h);
291 context.drawRectangle(x, y, w, h);
292
3145ec83
BH
293 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME_NAME));
294 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_FRAME_NAME));
295 context.setFont(pref.getFont(ISDPreferences.PREF_FRAME_NAME));
73005152
BH
296
297 int nameWidth = context.textExtent(getName()) + 2 * Metrics.FRAME_NAME_V_MARGIN;
298 int nameHeight = Metrics.getFrameFontHeigth() + +Metrics.FRAME_NAME_H_MARGIN * 2;
299
300 // Draw the frame name area
df0b8ff4 301 if (nameWidth > w) {
73005152 302 nameWidth = w;
df0b8ff4 303 }
73005152
BH
304
305 int[] points = { x, y, x + nameWidth, y, x + nameWidth, y - 11 + nameHeight, x - 11 + nameWidth, y + nameHeight, x, y + nameHeight, x, y + nameHeight };
306 context.fillPolygon(points);
307 context.drawPolygon(points);
308 context.drawLine(x, y, x, y + nameHeight);
309
3145ec83 310 context.setForeground(pref.getFontColor(ISDPreferences.PREF_FRAME_NAME));
73005152
BH
311 context.drawTextTruncatedCentred(getName(), x, y, nameWidth - 11, nameHeight, false);
312
3145ec83
BH
313 context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
314 context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_FRAME));
73005152
BH
315 }
316
73005152
BH
317 @Override
318 public void draw(IGC context) {
319 draw(context, true);
320 }
321
322 /**
323 * Draws the Frame on the given context.<br>
324 * This method start width GraphNodes ordering if needed.<br>
325 * After, depending on the visible area, only visible GraphNodes are drawn.<br>
a55887ca 326 *
73005152
BH
327 * @param context the context to draw to
328 * @param drawFrame indicate if the frame rectangle need to be redrawn
329 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(IGC)
330 */
331 protected void draw(IGC context, boolean drawFrame) {
eb63f5ff
BH
332 fVisibleAreaHeight = context.getVisibleHeight();
333 fVisibleAreaWidth = context.getVisibleWidth();
334 fVisibleAreaX = context.getContentsX();
335 fVisibleAreaY = context.getContentsY();
73005152 336
eb63f5ff
BH
337 if (fForceEventOccurrenceSpacing >= 0) {
338 Metrics.setForcedEventSpacing(fForceEventOccurrenceSpacing);
df0b8ff4 339 } else {
73005152 340 Metrics.setForcedEventSpacing(-1);
df0b8ff4 341 }
73005152 342
3145ec83 343 super.drawChildenNodes(context);
73005152
BH
344 }
345
df0b8ff4
BH
346 /**
347 * Sets the event occurrence spacing (-1 for none)
a55887ca 348 *
df0b8ff4
BH
349 * @param space A spacing to set.
350 */
73005152 351 public void forceEventOccurrenceSpacing(int space) {
eb63f5ff 352 fForceEventOccurrenceSpacing = space;
73005152
BH
353 }
354
355 /**
356 * Return the X coordinates of the frame visible area
a55887ca 357 *
73005152
BH
358 * @return the X coordinates of the frame visible area
359 */
360 public int getVisibleAreaX() {
eb63f5ff 361 return fVisibleAreaX;
73005152
BH
362 }
363
364 /**
365 * Return the frame visible area width
a55887ca 366 *
73005152
BH
367 * @return the frame visible area width
368 */
369 public int getVisibleAreaWidth() {
eb63f5ff 370 return fVisibleAreaWidth;
73005152
BH
371 }
372
373 /**
374 * Return the frame visible area height
a55887ca 375 *
73005152
BH
376 * @return the frame visible area height
377 */
378 public int getVisibleAreaHeight() {
eb63f5ff 379 return fVisibleAreaHeight;
73005152
BH
380 }
381
382 /**
383 * Return the X coordinates of the frame visible area
a55887ca 384 *
73005152
BH
385 * @return the X coordinates of the frame visible area
386 */
387 public int getVisibleAreaY() {
eb63f5ff 388 return fVisibleAreaY;
73005152
BH
389 }
390
391 /**
392 * Return the minimum time stored in the frame taking all GraphNodes into account
a55887ca 393 *
73005152 394 * @return the minimum GraphNode time
3bd46eef 395 * @since 2.0
73005152 396 */
4df4581d 397 public ITmfTimestamp getMinTime() {
eb63f5ff
BH
398 if (fLastExternalTimePref != SDViewPref.getInstance().excludeExternalTime()) {
399 fLastExternalTimePref = SDViewPref.getInstance().excludeExternalTime();
cab6c8ff 400 setComputeMinMax(true);
73005152 401 }
eb63f5ff 402 if ((fComputeMinMax) && (!fCustomMinMax)) {
73005152 403 computeMinMax();
cab6c8ff 404 setComputeMinMax(false);
73005152 405 }
eb63f5ff 406 return fMinTime;
73005152
BH
407 }
408
a55887ca
AM
409 /**
410 * Set the minimum timestamp of the frame.
411 *
412 * @param min
413 * The minimum timestamp
3bd46eef 414 * @since 2.0
a55887ca 415 */
d7dbf09a 416 public void setMin(ITmfTimestamp min) {
eb63f5ff
BH
417 fMinTime = min;
418 fCustomMinMax = true;
73005152
BH
419 }
420
a55887ca
AM
421 /**
422 * Set the maximum timestamp of the frame.
423 *
424 * @param max
425 * The maximum timestamp
3bd46eef 426 * @since 2.0
a55887ca 427 */
d7dbf09a 428 public void setMax(ITmfTimestamp max) {
eb63f5ff
BH
429 fMaxTime = max;
430 fCustomMinMax = true;
73005152
BH
431 }
432
a55887ca
AM
433 /**
434 * Reset min/max timestamp values to the default ones.
435 */
73005152 436 public void resetCustomMinMax() {
eb63f5ff 437 fCustomMinMax = false;
cab6c8ff 438 setComputeMinMax(true);
73005152
BH
439 }
440
441 /**
442 * Return the maximum time stored in the frame taking all GraphNodes into account
a55887ca 443 *
73005152 444 * @return the maximum GraphNode time
3bd46eef 445 * @since 2.0
73005152 446 */
4df4581d 447 public ITmfTimestamp getMaxTime() {
eb63f5ff
BH
448 if (fLastExternalTimePref != SDViewPref.getInstance().excludeExternalTime()) {
449 fLastExternalTimePref = SDViewPref.getInstance().excludeExternalTime();
cab6c8ff 450 setComputeMinMax(true);
73005152 451 }
eb63f5ff 452 if (fComputeMinMax) {
73005152 453 computeMinMax();
cab6c8ff 454 setComputeMinMax(false);
73005152 455 }
eb63f5ff 456 return fMaxTime;
73005152
BH
457 }
458
df0b8ff4 459 /**
a55887ca 460 * Computes the minimum and maximum time between consecutive messages within the frame.
df0b8ff4 461 */
73005152 462 protected void computeMaxMinTime() {
eb63f5ff 463 if (!fInitSDMin) {
73005152 464 return;
df0b8ff4 465 }
73005152
BH
466
467 List<SDTimeEvent> timeArray = buildTimeArray();
3145ec83
BH
468
469 if ((timeArray == null) || timeArray.isEmpty()) {
73005152 470 return;
df0b8ff4 471 }
73005152 472 for (int i = 0; i < timeArray.size(); i++) {
abbdd66a 473 SDTimeEvent m = timeArray.get(i);
73005152 474
eb63f5ff
BH
475 if (m.getTime().compareTo(fMaxSDTime, true) > 0) {
476 fMaxSDTime = m.getTime();
73005152
BH
477 }
478
eb63f5ff
BH
479 if ((m.getTime().compareTo(fMinSDTime, true) < 0) || fInitSDMin) {
480 fMinSDTime = m.getTime();
481 fInitSDMin = false;
73005152
BH
482 }
483 }
484 }
485
df0b8ff4
BH
486 /**
487 * Returns the minimum time between consecutive messages.
a55887ca 488 *
df0b8ff4 489 * @return the minimum time between consecutive messages
3bd46eef 490 * @since 2.0
df0b8ff4 491 */
4df4581d 492 public ITmfTimestamp getSDMinTime() {
73005152 493 computeMaxMinTime();
eb63f5ff 494 return fMinSDTime;
73005152
BH
495 }
496
df0b8ff4
BH
497 /**
498 * Returns the maximum time between consecutive messages.
a55887ca 499 *
df0b8ff4 500 * @return the maximum time between consecutive messages
3bd46eef 501 * @since 2.0
df0b8ff4 502 */
4df4581d 503 public ITmfTimestamp getSDMaxTime() {
73005152 504 computeMaxMinTime();
eb63f5ff 505 return fMaxSDTime;
73005152
BH
506 }
507
508 /**
509 * Browse all the GraphNode to compute the min and max times store in the Frame
510 */
511 protected void computeMinMax() {
512 List<SDTimeEvent> timeArray = buildTimeArray();
3145ec83
BH
513
514 if ((timeArray == null) || timeArray.isEmpty()) {
73005152 515 return;
df0b8ff4 516 }
73005152 517 for (int i = 0; i < timeArray.size() - 1; i++) {
abbdd66a
AM
518 SDTimeEvent m1 = timeArray.get(i);
519 SDTimeEvent m2 = timeArray.get(i + 1);
a55887ca 520
73005152 521 updateMinMax(m1, m2);
73005152
BH
522 }
523 }
524
df0b8ff4
BH
525 /**
526 * Updates the minimum and maximum time between consecutive message within the frame based on the given values.
a55887ca 527 *
df0b8ff4
BH
528 * @param m1 A first SD time event.
529 * @param m2 A second SD time event.
530 */
73005152 531 protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
4df4581d 532 ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
eb63f5ff 533 if (fComputeMinMax) {
4593bd5b 534 fMinTime = delta;
eb63f5ff
BH
535 if (fMinTime.compareTo(TmfTimestamp.ZERO, false) < 0) {
536 fMinTime = new TmfTimestamp(0, m1.getTime().getScale(), m1.getTime().getPrecision());
73005152 537 }
4593bd5b 538 fMaxTime = fMinTime;
cab6c8ff 539 setComputeMinMax(false);
73005152
BH
540 }
541
eb63f5ff 542 if ((delta.compareTo(fMinTime, true) < 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
4593bd5b 543 fMinTime = delta;
73005152
BH
544 }
545
eb63f5ff 546 if ((delta.compareTo(fMaxTime, true) > 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
4593bd5b 547 fMaxTime = delta;
73005152
BH
548 }
549 }
550
df0b8ff4
BH
551 /**
552 * Builds the time array based on the list of graph nodes.
a55887ca 553 *
3145ec83 554 * @return the time array else empty list.
df0b8ff4 555 */
73005152 556 protected List<SDTimeEvent> buildTimeArray() {
cab6c8ff 557 if (!hasChildren()) {
507b1336 558 return new ArrayList<>();
df0b8ff4 559 }
73005152 560
cab6c8ff 561 Iterator<String> it = getForwardSortMap().keySet().iterator();
507b1336 562 List<SDTimeEvent> timeArray = new ArrayList<>();
73005152
BH
563 while (it.hasNext()) {
564 String nodeType = it.next();
cab6c8ff 565 List<GraphNode> list = getNodeMap().get(nodeType);
73005152
BH
566 for (int i = 0; i < list.size(); i++) {
567 Object timedNode = list.get(i);
568 if ((timedNode instanceof ITimeRange) && ((ITimeRange) timedNode).hasTimeInfo()) {
abbdd66a 569 int event = list.get(i).getStartOccurrence();
4df4581d 570 ITmfTimestamp time = ((ITimeRange) list.get(i)).getStartTime();
73005152
BH
571 SDTimeEvent f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
572 timeArray.add(f);
abbdd66a 573 if (event != list.get(i).getEndOccurrence()) {
cab6c8ff 574 event = (list.get(i)).getEndOccurrence();
73005152
BH
575 time = ((ITimeRange) list.get(i)).getEndTime();
576 f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
577 timeArray.add(f);
578 }
579 }
580 }
581 }
582 return timeArray;
583 }
584
73005152
BH
585 @Override
586 public String getArrayId() {
587 return null;
588 }
589
73005152
BH
590 @Override
591 public boolean contains(int x, int y) {
592 return false;
593 }
cab6c8ff
BH
594
595 /**
596 * @return true if frame has time info else false
597 * @since 2.0
598 */
599 public boolean hasTimeInfo() {
600 return fHasTimeInfo;
601 }
602
603 /**
604 * Sets the flag whether the frame has time info or not
605 * @since 2.0
606 * @param hasTimeInfo
607 * true if frame has time info else false
608 */
609 public void setHasTimeInfo(boolean hasTimeInfo) {
610 fHasTimeInfo = hasTimeInfo;
611 }
612
613 /**
614 * Sets the flag for minimum and maximum computation.
615 * @param computeMinMax
616 * true if mininum and maximum time needs to be calculated else false
617 * @since 2.0
618 */
619 public void setComputeMinMax(boolean computeMinMax) {
620 fComputeMinMax = computeMinMax;
621 }
622
623 /**
624 * Sets the initialization flag for SD minimum.
625 *
626 * @param initSDMin
627 * the flag to set
628 * @since 2.0
629 */
630 public void setInitSDMin(boolean initSDMin) {
631 fInitSDMin = initSDMin;
632 }
73005152 633}
This page took 0.107368 seconds and 5 git commands to generate.