1 /**********************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
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
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
;
16 import java
.io
.Serializable
;
17 import java
.util
.Comparator
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.AsyncMessage
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
23 * Asynchronous message comparator.
25 * Compares two asyncMessages only taking into account the event occurrence when their
28 * Used to order the AsyncMessage list insuring that the previous node has both of his ends smaller than the current node
34 public class SortAsyncForBackward
implements Comparator
<GraphNode
>, Serializable
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
42 private static final long serialVersionUID
= 603959931263853359L;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
50 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
53 public int compare(GraphNode arg0
, GraphNode arg1
) {
54 if (arg0
instanceof AsyncMessage
&& arg1
instanceof AsyncMessage
) {
55 AsyncMessage m1
= (AsyncMessage
) arg0
;
56 AsyncMessage m2
= (AsyncMessage
) arg1
;
58 // AsyncMessage has two ends which may have different event occurrences
59 // Search for the greater event occurrence for each messages
60 if (m1
.getStartOccurrence() > m1
.getEndOccurrence()) {
61 m1Max
= m1
.getStartOccurrence();
63 m1Max
= m1
.getEndOccurrence();
65 if (m2
.getStartOccurrence() > m2
.getEndOccurrence()) {
66 m2Max
= m2
.getStartOccurrence();
68 m2Max
= m2
.getEndOccurrence();
72 // Search for the smaller event occurrence for each messages
73 if (m1
.getStartOccurrence() > m1
.getEndOccurrence()) {
74 m1Min
= m1
.getEndOccurrence();
76 m1Min
= m1
.getStartOccurrence();
78 if (m2
.getStartOccurrence() > m2
.getEndOccurrence()) {
79 m2Min
= m2
.getEndOccurrence();
81 m2Min
= m2
.getStartOccurrence();
86 } else if (m1Max
== m2Max
) {
89 } else if (m1Min
> m2Min
) {
This page took 0.034901 seconds and 6 git commands to generate.