1 /**********************************************************************
2 * Copyright (c) 2005, 2006, 2011 IBM Corporation and others.
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
7 * $Id: SortAsyncForBackward.java,v 1.2 2006/09/20 20:56:27 ewchan Exp $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
;
15 import java
.io
.Serializable
;
16 import java
.util
.Comparator
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.AsyncMessage
;
19 import org
.eclipse
.linuxtools
.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
32 public class SortAsyncForBackward
implements Comparator
<GraphNode
>, Serializable
{
37 private static final long serialVersionUID
= 603959931263853359L;
40 * Compares two asynchronous messages Returns 0 (equal) if one of the message is not asynchronous
42 * @return 1 if arg0 is greater, 0 if equal, -1 otherwise
45 public int compare(GraphNode arg0
, GraphNode arg1
) {
46 if (arg0
instanceof AsyncMessage
&& arg1
instanceof AsyncMessage
) {
47 AsyncMessage m1
= (AsyncMessage
) arg0
;
48 AsyncMessage m2
= (AsyncMessage
) arg1
;
50 // AsyncMessage has two ends which may have different event occurrences
51 // Search for the greater event occurrence for each messages
52 if (m1
.getStartOccurrence() > m1
.getEndOccurrence())
53 m1Max
= m1
.getStartOccurrence();
55 m1Max
= m1
.getEndOccurrence();
56 if (m2
.getStartOccurrence() > m2
.getEndOccurrence())
57 m2Max
= m2
.getStartOccurrence();
59 m2Max
= m2
.getEndOccurrence();
62 // Search for the smaller event occurrence for each messages
63 if (m1
.getStartOccurrence() > m1
.getEndOccurrence())
64 m1Min
= m1
.getEndOccurrence();
66 m1Min
= m1
.getStartOccurrence();
67 if (m2
.getStartOccurrence() > m2
.getEndOccurrence())
68 m2Min
= m2
.getEndOccurrence();
70 m2Min
= m2
.getStartOccurrence();
74 else if (m1Max
== m2Max
)
77 else if (m1Min
> m2Min
)
This page took 0.035828 seconds and 6 git commands to generate.