tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / core / BasicFrame.java
index 5b43af7f2f326692c30b0b04007fe295c0f0c9d6..d17bcbcb27f0b4794b71128b1518cca5f14e7aae 100755 (executable)
@@ -1,24 +1,23 @@
 /**********************************************************************
- * 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;
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IGC;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.ISDPreferences;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
@@ -28,10 +27,10 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences.SDViewPref;
  * 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
@@ -111,7 +110,7 @@ public class BasicFrame extends GraphNode {
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
-    
+
     /**
      * Creates an empty frame.
      */
@@ -124,9 +123,9 @@ public class BasicFrame extends GraphNode {
     // ------------------------------------------------------------------------
 
     /**
-     * 
+     *
      * Returns the greater event occurence known by the Frame
-     * 
+     *
      * @return the greater event occurrence
      */
     protected int getMaxEventOccurrence() {
@@ -135,7 +134,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Set the greater event occurrence created in GraphNodes included in the frame
-     * 
+     *
      * @param eventOccurrence the new greater event occurrence
      */
     protected void setMaxEventOccurrence(int eventOccurrence) {
@@ -147,7 +146,7 @@ public class BasicFrame extends GraphNode {
      * to set the lifelines drawing order. Also, calling this method two times and assigning only the last given index
      * to a lifeline will increase this lifeline draw spacing (2 times the default spacing) from the last added
      * lifeline.
-     * 
+     *
      * @return a new lifeline index
      */
     protected int getNewHorizontalIndex() {
@@ -156,7 +155,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Returns the current horizontal index
-     * 
+     *
      * @return the current horizontal index
      * @see Frame#getNewHorizontalIndex() for horizontal index description
      */
@@ -201,9 +200,8 @@ public class BasicFrame extends GraphNode {
     public int getWidth() {
         if (fHorizontalIndex == 0) {
             return 3 * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 - Metrics.FRAME_H_MARGIN - Metrics.LIFELINE_SPACING / 2;
-        } else {
-            return fHorizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
         }
+        return fHorizontalIndex * Metrics.swimmingLaneWidth() + Metrics.LIFELINE_H_MAGIN * 2 + 1 - Metrics.LIFELINE_SPACING;
     }
 
     /*
@@ -228,7 +226,7 @@ public class BasicFrame extends GraphNode {
      * Returns the graph node which contains the point given in parameter for the given graph node list and starting the
      * iteration at the given index<br>
      * WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.<br>
-     * 
+     *
      * @param x the x coordinate of the point to test
      * @param y the y coordinate of the point to test
      * @param list the list to search in
@@ -243,7 +241,7 @@ public class BasicFrame extends GraphNode {
             return null;
         }
         for (int i = fromIndex; i < list.size(); i++) {
-            GraphNode node = (GraphNode) list.get(i);
+            GraphNode node = list.get(i);
             // only lifeline list is x ordered
             // Stop browsing the list if the node is outside the visible area
             // all others nodes will be not visible
@@ -268,13 +266,13 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Draw the Frame rectangle
-     * 
+     *
      * @param context the context to draw to
      */
     protected void drawFrame(IGC context) {
-        
+
         ISDPreferences pref = SDViewPref.getInstance();
-        
+
         context.setBackground(pref.getBackGroundColor(ISDPreferences.PREF_FRAME));
         context.setForeground(pref.getForeGroundColor(ISDPreferences.PREF_FRAME));
 
@@ -324,7 +322,7 @@ public class BasicFrame extends GraphNode {
      * Draws the Frame on the given context.<br>
      * This method start width GraphNodes ordering if needed.<br>
      * After, depending on the visible area, only visible GraphNodes are drawn.<br>
-     * 
+     *
      * @param context the context to draw to
      * @param drawFrame indicate if the frame rectangle need to be redrawn
      * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode#draw(IGC)
@@ -346,7 +344,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Sets the event occurrence spacing (-1 for none)
-     * 
+     *
      * @param space A spacing to set.
      */
     public void forceEventOccurrenceSpacing(int space) {
@@ -355,7 +353,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the X coordinates of the frame visible area
-     * 
+     *
      * @return the X coordinates of the frame visible area
      */
     public int getVisibleAreaX() {
@@ -364,7 +362,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the frame visible area width
-     * 
+     *
      * @return the frame visible area width
      */
     public int getVisibleAreaWidth() {
@@ -373,7 +371,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the frame visible area height
-     * 
+     *
      * @return the frame visible area height
      */
     public int getVisibleAreaHeight() {
@@ -382,7 +380,7 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the X coordinates of the frame visible area
-     * 
+     *
      * @return the X coordinates of the frame visible area
      */
     public int getVisibleAreaY() {
@@ -391,8 +389,9 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the minimum time stored in the frame taking all GraphNodes into account
-     * 
+     *
      * @return the minimum GraphNode time
+     * @since 2.0
      */
     public ITmfTimestamp getMinTime() {
         if (fLastExternalTimePref != SDViewPref.getInstance().excludeExternalTime()) {
@@ -406,16 +405,33 @@ public class BasicFrame extends GraphNode {
         return fMinTime;
     }
 
+    /**
+     * Set the minimum timestamp of the frame.
+     *
+     * @param min
+     *            The minimum timestamp
+     * @since 2.0
+     */
     public void setMin(ITmfTimestamp min) {
         fMinTime = min;
         fCustomMinMax = true;
     }
 
+    /**
+     * Set the maximum timestamp of the frame.
+     *
+     * @param max
+     *            The maximum timestamp
+     * @since 2.0
+     */
     public void setMax(ITmfTimestamp max) {
         fMaxTime = max;
         fCustomMinMax = true;
     }
 
+    /**
+     * Reset min/max timestamp values to the default ones.
+     */
     public void resetCustomMinMax() {
         fCustomMinMax = false;
         fComputeMinMax = true;
@@ -423,8 +439,9 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Return the maximum time stored in the frame taking all GraphNodes into account
-     * 
+     *
      * @return the maximum GraphNode time
+     * @since 2.0
      */
     public ITmfTimestamp getMaxTime() {
         if (fLastExternalTimePref != SDViewPref.getInstance().excludeExternalTime()) {
@@ -439,7 +456,7 @@ public class BasicFrame extends GraphNode {
     }
 
     /**
-     * Computes the minimum and maximum time between consecutive messages within the frame. 
+     * Computes the minimum and maximum time between consecutive messages within the frame.
      */
     protected void computeMaxMinTime() {
         if (!fInitSDMin) {
@@ -452,7 +469,7 @@ public class BasicFrame extends GraphNode {
             return;
         }
         for (int i = 0; i < timeArray.size(); i++) {
-            SDTimeEvent m = (SDTimeEvent) timeArray.get(i);
+            SDTimeEvent m = timeArray.get(i);
 
             if (m.getTime().compareTo(fMaxSDTime, true) > 0) {
                 fMaxSDTime = m.getTime();
@@ -467,8 +484,9 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Returns the minimum time between consecutive messages.
-     * 
+     *
      * @return the minimum time between consecutive messages
+     * @since 2.0
      */
     public ITmfTimestamp getSDMinTime() {
         computeMaxMinTime();
@@ -477,8 +495,9 @@ public class BasicFrame extends GraphNode {
 
     /**
      * Returns the maximum time between consecutive messages.
-     * 
+     *
      * @return the maximum time between consecutive messages
+     * @since 2.0
      */
     public ITmfTimestamp getSDMaxTime() {
         computeMaxMinTime();
@@ -495,42 +514,42 @@ public class BasicFrame extends GraphNode {
             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);
+
             updateMinMax(m1, m2);
         }
     }
 
     /**
      * Updates the minimum and maximum time between consecutive message within the frame based on the given values.
-     * 
+     *
      * @param m1 A first SD time event.
      * @param m2 A second SD time event.
      */
     protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
         ITmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
         if (fComputeMinMax) {
-            fMinTime = delta.clone();
+            fMinTime = delta;
             if (fMinTime.compareTo(TmfTimestamp.ZERO, false) < 0) {
                 fMinTime = new TmfTimestamp(0, m1.getTime().getScale(), m1.getTime().getPrecision());
             }
-            fMaxTime = fMinTime.clone();
+            fMaxTime = fMinTime;
             fComputeMinMax = false;
         }
 
         if ((delta.compareTo(fMinTime, true) < 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
-            fMinTime = delta.clone();
+            fMinTime = delta;
         }
 
         if ((delta.compareTo(fMaxTime, true) > 0) && (delta.compareTo(TmfTimestamp.ZERO, false) > 0)) {
-            fMaxTime = delta.clone();
+            fMaxTime = delta;
         }
     }
 
     /**
      * Builds the time array based on the list of graph nodes.
-     * 
+     *
      * @return the time array else empty list.
      */
     protected List<SDTimeEvent> buildTimeArray() {
@@ -542,15 +561,15 @@ public class BasicFrame extends GraphNode {
         List<SDTimeEvent> timeArray = new ArrayList<SDTimeEvent>();
         while (it.hasNext()) {
             String nodeType = it.next();
-            List<GraphNode> list = (List<GraphNode>) fNodes.get(nodeType);
+            List<GraphNode> list = fNodes.get(nodeType);
             for (int i = 0; i < list.size(); i++) {
                 Object timedNode = list.get(i);
                 if ((timedNode instanceof ITimeRange) && ((ITimeRange) timedNode).hasTimeInfo()) {
-                    int event = ((GraphNode) list.get(i)).getStartOccurrence();
+                    int event = list.get(i).getStartOccurrence();
                     ITmfTimestamp time = ((ITimeRange) list.get(i)).getStartTime();
                     SDTimeEvent f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
                     timeArray.add(f);
-                    if (event != ((GraphNode) list.get(i)).getEndOccurrence()) {
+                    if (event != list.get(i).getEndOccurrence()) {
                         event = ((AsyncMessage) list.get(i)).getEndOccurrence();
                         time = ((ITimeRange) list.get(i)).getEndTime();
                         f = new SDTimeEvent(time, event, (ITimeRange) list.get(i));
This page took 0.028748 seconds and 5 git commands to generate.