tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / Frame.java
index 6dd12f1ba594a2702cd6e76c9fdbb8a45b7f447e..2a98d2302adbf3f018f95ab5d3354df2b1a624a4 100755 (executable)
@@ -1,16 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- * 
+ * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors: 
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd.core;
 
 import java.util.ArrayList;
@@ -18,7 +17,7 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
@@ -29,10 +28,10 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.TimeEventComparator;
  * For instance, only one frame can be drawn in the View.<br>
  * Lifelines, Messages and Stop which are supposed to represent a Sequence diagram are drawn in a Frame.<br>
  * Only the graph node added to their representing list will be drawn.
- * 
+ *
  * The lifelines are appended along the X axsis when added in a frame.<br>
  * The syncMessages are ordered along the Y axsis depending on the event occurrence they are attached to.<br>
- * 
+ *
  * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Lifeline Lifeline for more event occurence details
  * @author sveyrier
  * @version 1.0
@@ -74,19 +73,19 @@ public class Frame extends BasicFrame {
     /**
      * Returns a list of all lifelines known by this frame. Known lifelines are the only one which can be displayed on
      * screen.
-     * 
+     *
      * @return the lifelines list
      */
     protected List<GraphNode> getLifelines() {
         if (!fHasChilden) {
             return null;
-        } 
-        return (List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG);
+        }
+        return fNodes.get(Lifeline.LIFELINE_TAG);
     }
 
     /**
      * Returns the number of lifelines stored in the frame
-     * 
+     *
      * @return the number of lifelines
      */
     public int lifeLinesCount() {
@@ -99,7 +98,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the lifeline at the given index in the lifelines array
-     * 
+     *
      * @param index the position in the lifeline array
      * @return the lifeline or <code>null</code>
      */
@@ -113,31 +112,31 @@ public class Frame extends BasicFrame {
     /**
      * Returns a list of syncMessages known by this frame. Known syncMessages are the only on which can be displayed on
      * screen
-     * 
+     *
      * @return the syncMessages list
      */
     protected List<GraphNode> getSyncMessages() {
         if (!fHasChilden) {
             return null;
-        } 
-        return (List<GraphNode>) fNodes.get(SyncMessage.SYNC_MESS_TAG);
+        }
+        return fNodes.get(SyncMessage.SYNC_MESS_TAG);
     }
 
     /**
      * Returns the number of syncMessages stored in the frame
-     * 
+     *
      * @return the number of syncMessage
      */
     public int syncMessageCount() {
         if (getSyncMessages() != null) {
             return getSyncMessages().size();
-        } 
+        }
         return 0;
     }
 
     /**
      * Returns the syncMessage at the given index in the syncMessages array
-     * 
+     *
      * @param index the position in the syncMessages array
      * @return the syncMessage or <code>null</code>
      */
@@ -151,19 +150,19 @@ public class Frame extends BasicFrame {
     /**
      * Returns a list of asyncMessages known by this frame. Known asyncMessages are the only on which can be displayed
      * on screen
-     * 
+     *
      * @return the asyncMessages list or <code>null</code>
      */
     protected List<GraphNode> getAsyncMessages() {
         if (!fHasChilden) {
             return null;
         }
-        return (List<GraphNode>) fNodes.get(AsyncMessage.ASYNC_MESS_TAG);
+        return fNodes.get(AsyncMessage.ASYNC_MESS_TAG);
     }
 
     /**
      * Returns the number of asyncMessage stored in the frame
-     * 
+     *
      * @return the number of asyncMessage
      */
     public int asyncMessageCount() {
@@ -175,7 +174,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the asyncMessage at the given index in the asyncMessage array
-     * 
+     *
      * @param index the position in the asyncMessage array
      * @return the asyncMessage or <code>null</code>
      */
@@ -189,19 +188,19 @@ public class Frame extends BasicFrame {
     /**
      * Returns a list of syncMessages return known by this frame. Known syncMessages return are the only on which can be
      * displayed on screen
-     * 
+     *
      * @return the syncMessages return list or <code>null</code>
      */
     protected List<GraphNode> getSyncMessagesReturn() {
         if (!fHasChilden) {
             return null;
         }
-        return (List<GraphNode>) fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
+        return fNodes.get(SyncMessageReturn.SYNC_MESS_RET_TAG);
     }
 
     /**
      * Returns the number of syncMessageReturn stored in the frame
-     * 
+     *
      * @return the number of syncMessageReturn
      */
     public int syncMessageReturnCount() {
@@ -213,7 +212,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the syncMessageReturn at the given index in the syncMessageReturn array
-     * 
+     *
      * @param index the position in the syncMessageReturn array
      * @return the syncMessageReturn or <code>null</code>
      */
@@ -227,19 +226,19 @@ public class Frame extends BasicFrame {
     /**
      * Returns a list of asyncMessageRetun known by this frame. Known asyncMessageRetun are the only on which can be
      * displayed on screen
-     * 
+     *
      * @return the asyncMessageRetun list or <code>null</code>
      */
     protected List<GraphNode> getAsyncMessagesReturn() {
         if (!fHasChilden) {
             return null;
         }
-        return (List<GraphNode>) fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
+        return fNodes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG);
     }
 
     /**
      * Returns the number of asyncMessageReturn stored in the frame
-     * 
+     *
      * @return the number of asyncMessageReturn
      */
     public int asyncMessageReturnCount() {
@@ -251,7 +250,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the asyncMessageReturn at the given index in the asyncMessageReturn array
-     * 
+     *
      * @param index the position in the asyncMessageReturn array
      * @return the asyncMessageReturn or <code>null</code>
      */
@@ -265,7 +264,7 @@ public class Frame extends BasicFrame {
     /**
      * Adds a lifeline to the frame lifelines list. The lifeline X drawing order depends on the lifeline addition order
      * into the frame lifelines list.
-     * 
+     *
      * @param lifeline the lifeline to add
      */
     public void addLifeLine(Lifeline lifeline) {
@@ -287,77 +286,77 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the first visible lifeline drawn in the view
-     * 
+     *
      * @return the first visible lifeline index
      */
     public int getFirstVisibleLifeline() {
         if (!fHasChilden) {
             return 0;
         } else if (fIndexes.get(Lifeline.LIFELINE_TAG) != null) {
-            return ((Integer) fIndexes.get(Lifeline.LIFELINE_TAG)).intValue();
+            return fIndexes.get(Lifeline.LIFELINE_TAG).intValue();
         }
         return 0;
     }
 
     /**
      * Returns the first visible synchronous message drawn in the view
-     * 
+     *
      * @return the first visible synchronous message index
      */
     public int getFirstVisibleSyncMessage() {
         if (!fHasChilden) {
             return 0;
         } else if (fIndexes.get(SyncMessage.SYNC_MESS_TAG) != null) {
-            return ((Integer) fIndexes.get(SyncMessage.SYNC_MESS_TAG)).intValue();
+            return fIndexes.get(SyncMessage.SYNC_MESS_TAG).intValue();
         }
         return 0;
     }
 
     /**
      * Returns the first visible synchronous message return drawn in the view
-     * 
+     *
      * @return the first visible synchronous message return index
      */
     public int getFirstVisibleSyncMessageReturn() {
         if (!fHasChilden) {
             return 0;
         } else if (fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG) != null) {
-            return ((Integer) fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG)).intValue();
+            return fIndexes.get(SyncMessageReturn.SYNC_MESS_RET_TAG).intValue();
         }
         return 0;
     }
 
     /**
      * Returns the first visible synchronous message drawn in the view
-     * 
+     *
      * @return the first visible synchronous message index
      */
     public int getFirstVisibleAsyncMessage() {
         if (!fHasChilden) {
             return 0;
         } else if (fIndexes.get(AsyncMessage.ASYNC_MESS_TAG) != null) {
-            return ((Integer) fIndexes.get(AsyncMessage.ASYNC_MESS_TAG)).intValue();
+            return fIndexes.get(AsyncMessage.ASYNC_MESS_TAG).intValue();
         }
         return 0;
     }
 
     /**
      * Returns the first visible synchronous message return drawn in the view
-     * 
+     *
      * @return the first visible synchronous message return index
      */
     public int getFirstVisibleAsyncMessageReturn() {
         if (!fHasChilden) {
             return 0;
         } else if (fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG) != null) {
-            return ((Integer) fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG)).intValue();
+            return fIndexes.get(AsyncMessageReturn.ASYNC_MESS_RET_TAG).intValue();
         }
         return 0;
     }
 
     /**
      * Returns the list of execution occurrences.
-     * 
+     *
      * @return the list of execution occurrences
      */
     public List<SDTimeEvent> getExecutionOccurrencesWithTime() {
@@ -366,9 +365,9 @@ public class Frame extends BasicFrame {
 
     /**
      * Inserts a lifeline after a given lifeline.
-     * 
+     *
      * @param toInsert A lifeline to insert
-     * @param after A lifelife the toInsert-lifeline will be inserted after.  
+     * @param after A lifelife the toInsert-lifeline will be inserted after.
      */
     public void insertLifelineAfter(Lifeline toInsert, Lifeline after) {
         if ((toInsert == null)) {
@@ -410,9 +409,11 @@ public class Frame extends BasicFrame {
 
     /**
      * Inserts a lifeline before a given lifeline.
-     * 
-     * @param toInsert A lifeline to insert
-     * @param after A lifelife the toInsert-lifeline will be inserted before.  
+     *
+     * @param toInsert
+     *            A lifeline to insert
+     * @param before
+     *            A lifeline the toInsert-lifeline will be inserted before.
      */
     public void insertLifelineBefore(Lifeline toInsert, Lifeline before) {
         if ((toInsert == null)) {
@@ -454,9 +455,9 @@ public class Frame extends BasicFrame {
 
     /**
      * Gets the closer life line to the given x-coordinate.
-     * 
+     *
      * @param x A x coordinate
-     * @return the closer lifeline 
+     * @return the closer lifeline
      */
     public Lifeline getCloserLifeline(int x) {
         int index = (x - Metrics.FRAME_H_MARGIN + Metrics.LIFELINE_H_MAGIN) / Metrics.swimmingLaneWidth() - 1;
@@ -488,7 +489,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Re-orders the given list of lifelines.
-     * 
+     *
      * @param list A list of lifelines to reorder.
      */
     public void reorder(List<?> list) {
@@ -527,8 +528,8 @@ public class Frame extends BasicFrame {
             return;
         }
         for (int i = 0; i < timeArray.size() - 1; i++) {
-            SDTimeEvent m1 = (SDTimeEvent) timeArray.get(i);
-            SDTimeEvent m2 = (SDTimeEvent) timeArray.get(i + 1);
+            SDTimeEvent m1 = timeArray.get(i);
+            SDTimeEvent m2 = timeArray.get(i + 1);
             if (SDViewPref.getInstance().excludeExternalTime() && ((m1.getGraphNode() instanceof BaseMessage) && (m2.getGraphNode() instanceof BaseMessage))) {
                 BaseMessage mes1 = (BaseMessage) m1.getGraphNode();
                 BaseMessage mes2 = (BaseMessage) m2.getGraphNode();
@@ -545,10 +546,11 @@ public class Frame extends BasicFrame {
      * Find the two graph nodes that are closest to this date, one just earlier, second just later. If date is before
      * any graph node, bounds[0] is null and bounds[1] is the earliest. If date is after any graph node, bounds[1] is
      * null and bounds[0] is the latest.
-     * 
+     *
      * @param dateToFind date to be found
      * @param bounds a two items array that will receive bounds if found
      * @return true if both bounds not null
+     * @since 2.0
      */
     public boolean findDateBounds(ITmfTimestamp dateToFind, ITimeRange bounds[]) {
         if (hasTimeInfo()) {
@@ -561,24 +563,24 @@ public class Frame extends BasicFrame {
             bounds[0] = null;
             bounds[1] = null;
             for (int i = 0; i < timeArray.size(); i++) {
-                SDTimeEvent m = (SDTimeEvent) timeArray.get(i);
+                SDTimeEvent m = timeArray.get(i);
                 if (m.getTime().compareTo(dateToFind, true) > 0) {
                     bounds[1] = m.getGraphNode();
                     if (i > 0) {
-                        bounds[0] = ((SDTimeEvent) timeArray.get(i - 1)).getGraphNode();
+                        bounds[0] = timeArray.get(i - 1).getGraphNode();
                         return true;
                     }
                     return false;
                 }
             }
-            bounds[0] = ((SDTimeEvent) timeArray.get(timeArray.size() - 1)).getGraphNode();
+            bounds[0] = timeArray.get(timeArray.size() - 1).getGraphNode();
         }
         return false;
     }
 
     /**
      * Set whether time information is available or not
-     * 
+     *
      * @param value <code>true</code> for has time information else <code>false</code>
      */
     protected void setHasTimeInfo(boolean value) {
@@ -587,7 +589,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns whether frame has time info or not.
-     * 
+     *
      * @return <code>true</code> whether frame has time info else <code>false</code>
      */
     public boolean hasTimeInfo() {
@@ -596,7 +598,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Highlights the time compression.
-     * 
+     *
      * @param lifeline A lifeline to highlight
      * @param startEvent A start event number
      * @param nbEvent A number of events
@@ -611,7 +613,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Set the lifeline categories which will be use during the lifelines creation
-     * 
+     *
      * @see Lifeline#setCategory(int)
      * @param categories the lifeline categories array
      */
@@ -621,11 +623,11 @@ public class Frame extends BasicFrame {
 
     /**
      * Returns the lifeline categories array set for the this frame
-     * 
+     *
      * @return the lifeline categories array or null if not set
      */
     public LifelineCategories[] getLifelineCategories() {
-        return  Arrays.copyOf(fLifelineCategories, fLifelineCategories.length); 
+        return  Arrays.copyOf(fLifelineCategories, fLifelineCategories.length);
     }
 
     /**
@@ -636,7 +638,7 @@ public class Frame extends BasicFrame {
      * - asynchronous syncMessages return<br>
      * For drawing performance reason, it is recommended to add synchronous syncMessages in the same order they should
      * appear along the Y axis in the Frame.
-     * 
+     *
      * @param message the message to add
      */
     public void addMessage(BaseMessage message) {
@@ -653,7 +655,7 @@ public class Frame extends BasicFrame {
         if (!fHasChilden) {
             return;
         }
-        
+
         if (fHighlightLifeline != null) {
             IColor backupColor = context.getBackground();
             context.setBackground(SDViewPref.getInstance().getTimeCompressionSelectionColor());
@@ -669,9 +671,9 @@ public class Frame extends BasicFrame {
         if (fIndexes.size() == 0) {
             return;
         }
-        int lifeLineDrawIndex = ((Integer) fIndexes.get(Lifeline.LIFELINE_TAG)).intValue();
-        for (int i = lifeLineDrawIndex; i < ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i = i + lifelineArryStep) {
-            Lifeline toDraw = (Lifeline) ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).get(i);
+        int lifeLineDrawIndex = fIndexes.get(Lifeline.LIFELINE_TAG).intValue();
+        for (int i = lifeLineDrawIndex; i < fNodes.get(Lifeline.LIFELINE_TAG).size(); i = i + lifelineArryStep) {
+            Lifeline toDraw = (Lifeline) fNodes.get(Lifeline.LIFELINE_TAG).get(i);
             if (toDraw.getX() - Metrics.LIFELINE_SPACING / 2 > context.getContentsX() + context.getVisibleWidth()) {
                 break;
             }
@@ -721,8 +723,8 @@ public class Frame extends BasicFrame {
         List<SDTimeEvent> timeArray = super.buildTimeArray();
         fExecutionOccurrencesWithTime = null;
         if (getLifelines() != null) {
-            for (int i = 0; i < ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).size(); i++) {
-                Lifeline lifeline = (Lifeline) ((List<GraphNode>) fNodes.get(Lifeline.LIFELINE_TAG)).get(i);
+            for (int i = 0; i < fNodes.get(Lifeline.LIFELINE_TAG).size(); i++) {
+                Lifeline lifeline = (Lifeline) fNodes.get(Lifeline.LIFELINE_TAG).get(i);
                 if (lifeline.hasTimeInfo() && lifeline.getExecutions() != null) {
                     for (Iterator<GraphNode> j = lifeline.getExecutions().iterator(); j.hasNext();) {
                         GraphNode o = j.next();
@@ -762,7 +764,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get the closer leaving message.
-     * 
+     *
      * @param lifeline A lifeline reference
      * @param message A message reference
      * @param list A list of graph nodes
@@ -780,7 +782,7 @@ public class Frame extends BasicFrame {
                 event = message.getEventOccurrence();
             }
             for (int i = 0; i < list.size(); i++) {
-                GraphNode node = (GraphNode) list.get(i);
+                GraphNode node = list.get(i);
                 if (node instanceof SyncMessage) {
                     SyncMessage syncNode = (SyncMessage) node;
                     if ((syncNode.getEventOccurrence() > event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
@@ -803,7 +805,7 @@ public class Frame extends BasicFrame {
                 }
             }
             for (int i = list.size() - 1; i >= 0; i--) {
-                GraphNode node = (GraphNode) list.get(i);
+                GraphNode node = list.get(i);
                 if (node instanceof SyncMessage) {
                     SyncMessage syncNode = (SyncMessage) node;
                     if ((syncNode.getEventOccurrence() < event) && (syncNode.getStartLifeline() == lifeline) && !syncNode.isSameAs(message)) {
@@ -820,10 +822,10 @@ public class Frame extends BasicFrame {
         return null;
     }
 
-    
+
     /**
      * Get the closer entering message.
-     * 
+     *
      * @param lifeline A lifeline reference
      * @param message A message reference
      * @param list A list of graph nodes
@@ -840,7 +842,7 @@ public class Frame extends BasicFrame {
                 event = message.getEventOccurrence();
             }
             for (int i = 0; i < list.size(); i++) {
-                GraphNode node = (GraphNode) list.get(i);
+                GraphNode node = list.get(i);
                 if (node instanceof SyncMessage) {
                     SyncMessage syncNode = (SyncMessage) node;
                     if ((syncNode.getEventOccurrence() > event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
@@ -855,14 +857,15 @@ public class Frame extends BasicFrame {
             }
         } else {
             int event = getMaxEventOccurrence();
-            if (message != null)
+            if (message != null) {
                 if (message instanceof AsyncMessage) {
                     event = ((AsyncMessage) message).getStartOccurrence();
                 } else {
                     event = message.getEventOccurrence();
                 }
+            }
             for (int i = list.size() - 1; i >= 0; i--) {
-                GraphNode node = (GraphNode) list.get(i);
+                GraphNode node = list.get(i);
                 if (node instanceof SyncMessage) {
                     SyncMessage syncNode = (SyncMessage) node;
                     if ((syncNode.getEventOccurrence() < event) && (syncNode.getEndLifeline() == lifeline) && !syncNode.isSameAs(message)) {
@@ -881,7 +884,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get distance of given event from given graph node.
-     * 
+     *
      * @param node A graph node reference.
      * @param event A event number to check.
      * @return distance of event from graph node.
@@ -904,7 +907,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get node from 2 given nodes that is close to event.
-     * 
+     *
      * @param node1 A first graph node
      * @param node2 A second graph node
      * @param event A event to check.
@@ -914,20 +917,19 @@ public class Frame extends BasicFrame {
         if ((node1 != null) && (node2 != null)) {
             if (distanceFromEvent(node1, event) < distanceFromEvent(node2, event)) {
                 return node1;
-            } else {
-                return node2;
             }
+            return node2;
         } else if (node1 != null) {
             return node1;
         } else if (node2 != null) {
             return node2;
-        } 
+        }
         return null;
     }
 
     /**
      * Get called message based on given start message.
-     * 
+     *
      * @param startMessage A start message to check.
      * @return called message (graph node) or <code>null</code>
      */
@@ -936,10 +938,10 @@ public class Frame extends BasicFrame {
         GraphNode result = null;
         Lifeline lifeline = null;
         if (startMessage != null) {
-            event = ((BaseMessage) startMessage).getEventOccurrence();
-            lifeline = ((BaseMessage) startMessage).getEndLifeline();
+            event = startMessage.getEventOccurrence();
+            lifeline = startMessage.getEndLifeline();
             if (lifeline == null) {
-                lifeline = ((BaseMessage) startMessage).getStartLifeline();
+                lifeline = startMessage.getStartLifeline();
             }
         }
         if (lifeline == null) {
@@ -957,7 +959,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get caller message based on given start message.
-     * 
+     *
      * @param startMessage A start message to check.
      * @return called message (graph node) or <code>null</code>
      */
@@ -966,10 +968,10 @@ public class Frame extends BasicFrame {
         GraphNode result = null;
         Lifeline lifeline = null;
         if (startMessage != null) {
-            event = ((BaseMessage) startMessage).getEventOccurrence();
-            lifeline = ((BaseMessage) startMessage).getStartLifeline();
+            event = startMessage.getEventOccurrence();
+            lifeline = startMessage.getStartLifeline();
             if (lifeline == null) {
-                lifeline = ((BaseMessage) startMessage).getEndLifeline();
+                lifeline = startMessage.getEndLifeline();
             }
         }
         if (lifeline == null) {
@@ -987,7 +989,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get next lifeline based on given message.
-     * 
+     *
      * @param lifeline A lifeline reference
      * @param startMessage A start message to check
      * @return next lifeline or <code>null</code>
@@ -995,7 +997,7 @@ public class Frame extends BasicFrame {
     public GraphNode getNextLifelineMessage(Lifeline lifeline, BaseMessage startMessage) {
         int event = 0;
         if (startMessage != null) {
-            event = ((BaseMessage) startMessage).getEventOccurrence();
+            event = startMessage.getEventOccurrence();
         }
         if (lifeline == null) {
             return null;
@@ -1012,19 +1014,20 @@ public class Frame extends BasicFrame {
 
     /**
      * Get previous lifeline based on given message.
-     * 
+     *
      * @param lifeline A lifeline reference
      * @param startMessage A start message to check.
      * @return previous lifeline or <code>null</code>
      */
     public GraphNode getPrevLifelineMessage(Lifeline lifeline, BaseMessage startMessage) {
         int event = getMaxEventOccurrence();
-        if (startMessage != null)
+        if (startMessage != null) {
             if (startMessage instanceof AsyncMessage) {
                 event = ((AsyncMessage) startMessage).getStartOccurrence();
             } else {
                 event = startMessage.getEventOccurrence();
             }
+        }
         if (lifeline == null) {
             return null;
         }
@@ -1037,10 +1040,10 @@ public class Frame extends BasicFrame {
         result = getCloserToEvent(result, messageReturn, event);
         return result;
     }
-    
+
     /**
      * Get the first execution occurrence.
-     * 
+     *
      * @param lifeline A lifeline reference
      * @return the first execution occurrence of lifeline or <code>null</code>.
      */
@@ -1063,10 +1066,10 @@ public class Frame extends BasicFrame {
         }
         return result;
     }
-    
+
     /**
      * Get the previous execution occurrence relative to a given execution occurrence.
-     * 
+     *
      * @param exec A execution occurrence reference.
      * @return the previous execution occurrence of lifeline or <code>null</code>.
      */
@@ -1088,7 +1091,7 @@ public class Frame extends BasicFrame {
             if ((e.getStartOccurrence() < exec.fStartEventOccurrence) && (result == null)) {
                 result = e;
             }
-            if ((e.getStartOccurrence() < exec.fStartEventOccurrence) && (e.getStartOccurrence() >= result.getEndOccurrence())) {
+            if ((e.getStartOccurrence() < exec.fStartEventOccurrence) && (result != null) && (e.getStartOccurrence() >= result.getEndOccurrence())) {
                 result = e;
             }
         }
@@ -1097,7 +1100,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get the next execution occurrence relative to a given execution occurrence.
-     * 
+     *
      * @param exec A execution occurrence reference.
      * @return the next execution occurrence of lifeline or <code>null</code>.
      */
@@ -1119,7 +1122,7 @@ public class Frame extends BasicFrame {
             if ((e.getStartOccurrence() > exec.fStartEventOccurrence) && (result == null)) {
                 result = e;
             }
-            if ((e.getStartOccurrence() > exec.fStartEventOccurrence) && (e.getStartOccurrence() <= result.getEndOccurrence())) {
+            if ((e.getStartOccurrence() > exec.fStartEventOccurrence) && (result != null) && (e.getStartOccurrence() <= result.getEndOccurrence())) {
                 result = e;
             }
         }
@@ -1128,7 +1131,7 @@ public class Frame extends BasicFrame {
 
     /**
      * Get the last execution occurrence.
-     * 
+     *
      * @param lifeline A lifeline reference.
      * @return the last execution occurrence of lifeline or <code>null</code>.
      */
This page took 0.034012 seconds and 5 git commands to generate.