1 /**********************************************************************
2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.util
;
15 import java
.io
.Serializable
;
16 import java
.util
.Comparator
;
18 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
.AsyncMessage
;
19 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
22 * Asynchronous message comparator.
24 * Compares two asyncMessages only taking into account the event occurrence when their
27 * Used to order the AsyncMessage list insuring that the previous node has both of his ends smaller than the current node
33 public class SortAsyncForBackward
implements Comparator
<GraphNode
>, Serializable
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
41 private static final long serialVersionUID
= 603959931263853359L;
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
48 public int compare(GraphNode arg0
, GraphNode arg1
) {
49 if (arg0
instanceof AsyncMessage
&& arg1
instanceof AsyncMessage
) {
50 AsyncMessage m1
= (AsyncMessage
) arg0
;
51 AsyncMessage m2
= (AsyncMessage
) arg1
;
53 // AsyncMessage has two ends which may have different event occurrences
54 // Search for the greater event occurrence for each messages
55 if (m1
.getStartOccurrence() > m1
.getEndOccurrence()) {
56 m1Max
= m1
.getStartOccurrence();
58 m1Max
= m1
.getEndOccurrence();
60 if (m2
.getStartOccurrence() > m2
.getEndOccurrence()) {
61 m2Max
= m2
.getStartOccurrence();
63 m2Max
= m2
.getEndOccurrence();
67 // Search for the smaller event occurrence for each messages
68 if (m1
.getStartOccurrence() > m1
.getEndOccurrence()) {
69 m1Min
= m1
.getEndOccurrence();
71 m1Min
= m1
.getStartOccurrence();
73 if (m2
.getStartOccurrence() > m2
.getEndOccurrence()) {
74 m2Min
= m2
.getEndOccurrence();
76 m2Min
= m2
.getStartOccurrence();
81 } else if (m1Max
== m2Max
) {
84 } else if (m1Min
> m2Min
) {
This page took 0.032932 seconds and 5 git commands to generate.