Refactor TmfTimestamp as per the updated TMF Event Model
authorFrancois Chouinard <fchouinard@gmail.com>
Fri, 10 Feb 2012 22:23:03 +0000 (17:23 -0500)
committerFrancois Chouinard <fchouinard@gmail.com>
Fri, 10 Feb 2012 22:23:03 +0000 (17:23 -0500)
28 files changed:
org.eclipse.linuxtools.lttng.core/.options
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/LTTngCorePlugin.java
org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngTimestamp.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/SpinnerGroup.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/TmfCorePluginTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventContentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.core/.options
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/TmfCorePlugin.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfDataEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/impl/TmfUml2SDSyncLoaderSignalTest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/DrawableToolTip.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/SDWidget.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/TimeCompressionBar.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/core/BasicFrame.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/util/MinMaxDialog.java

index d9ec6c205e1f84e87e5c63c421da730b4a961cd8..eac992d7cb57c2c3adf03782ae1b81b3866868ac 100644 (file)
@@ -1,3 +1,3 @@
-org.eclipse.linuxtools.lttng/debug=false
-org.eclipse.linuxtools.lttng/info=false
-org.eclipse.linuxtools.lttng/warn=false
+org.eclipse.linuxtools.lttng.core/debug=false
+org.eclipse.linuxtools.lttng.core/info=false
+org.eclipse.linuxtools.lttng.core/warn=false
index 7c055fd351cc89268df076c63ada2d18e68a3fcb..9cc64638ff92e36728d626eae6f8ed3fc84aa30c 100644 (file)
@@ -27,7 +27,7 @@ public class LTTngCorePlugin extends Plugin {
     // ========================================================================
 
        // The plug-in ID
-       public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng"; //$NON-NLS-1$
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng.core"; //$NON-NLS-1$
 
        // The shared instance
        private static LTTngCorePlugin plugin;
index 974f4d644eaf746a0b4bbc6294d6694e21ecbe2f..90aad15736933bdee280f649acde3d269e35ec51 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.linuxtools.lttng.core.event;
 
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 
 /**
@@ -23,15 +24,12 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
  */
 public class LttngTimestamp extends TmfTimestamp {
     
-    // Required by Serializable
-       private static final long serialVersionUID = -7016853105162491273L;
-       
     /**
      * Default Constructor.<p>
      * 
      */
        public LttngTimestamp() {
-           super(Long.MIN_VALUE, (byte) -9);
+           this(Long.MIN_VALUE);
        }
        
        /**
@@ -40,7 +38,7 @@ public class LttngTimestamp extends TmfTimestamp {
      * @param newEventTime    Time as long, unit expected to be nanoseconds
      */
     public LttngTimestamp(long newEventTime) {
-        super(newEventTime, (byte) -9);
+        super(newEventTime, -9, 0);
     }
     
     /**
@@ -52,11 +50,6 @@ public class LttngTimestamp extends TmfTimestamp {
         this(oldEventTime.getValue());
     }
     
-    @Override
-    public long getValue() {
-        return fValue;
-    }
-    
     public void setValue(long newValue) {
         fValue = newValue;
     }
@@ -176,8 +169,8 @@ public class LttngTimestamp extends TmfTimestamp {
      * @throws ArithmeticException
      */
     @Override
-    public LttngTimestamp getDelta(TmfTimestamp other) throws ArithmeticException {
-        TmfTimestamp delta = super.getDelta(other);
+    public LttngTimestamp getDelta(ITmfTimestamp other) {
+        TmfTimestamp delta = (TmfTimestamp) super.getDelta(other);
         return new LttngTimestamp(delta); 
     }
 }
index 50aef6671283209d1320a83c689225d79ad4acdd..eb0686581c72d3989657a7a93af72b8b486b9718 100644 (file)
@@ -160,7 +160,7 @@ public class SpinnerGroup {
     }
 
     public TmfTimestamp getSpan() {
-        TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime, NS_SCALING_FACTOR), NS_SCALING_FACTOR, 0);
+        TmfTimestamp span = (TmfTimestamp) startTime.getDelta(endTime);
         return span;
     }
 
@@ -171,7 +171,7 @@ public class SpinnerGroup {
 
     public void setStartTime(TmfTimestamp ts) {
        try {
-               startTime = ts.synchronize(0, NS_SCALING_FACTOR);
+               startTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
                startSeconds = (int) (startTime.getValue() / NS_PER_SECOND);
                startNanosec = (int) (startTime.getValue() % NS_PER_SECOND);
        }
@@ -181,7 +181,7 @@ public class SpinnerGroup {
 
     public void setEndTime(TmfTimestamp ts) {
        try {
-               endTime = ts.synchronize(0, NS_SCALING_FACTOR);
+           endTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
                endSeconds = (int) (endTime.getValue() / NS_PER_SECOND);
                endNanosec = (int) (endTime.getValue() % NS_PER_SECOND);
        }
@@ -191,7 +191,7 @@ public class SpinnerGroup {
 
     public void setCurrentTime(TmfTimestamp ts) {
        try {
-               currentTime = ts.synchronize(0, NS_SCALING_FACTOR);
+           currentTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
                currentSeconds = (int) (currentTime.getValue() / NS_PER_SECOND);
                currentNanosec = (int) (currentTime.getValue() % NS_PER_SECOND);
        }
index 09b031c276921caf7bef03f4e62bef621d7768ba..87e20b2b7d655379daf7fc6be035859d042535c6 100644 (file)
@@ -68,7 +68,7 @@ public class TimeFrameView extends TmfView {
 
     private TmfTimeRange fTraceTimeRange = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
     private TmfTimeRange fTraceSpan = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
-    private byte fScale = 0;
+    private int fScale = 0;
 
     // Labels
     private static final String START_TIME_LABEL = Messages.TimeFrameView_WindowStartTime;
@@ -172,7 +172,7 @@ public class TimeFrameView extends TmfView {
             long span = timeRange.getValue();
             TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0);
             if (ts.compareTo(fTraceEndTime, false) > 0) {
-                ts = fTraceEndTime.synchronize(fTraceEndTime.getValue(), startTime.getScale());
+                ts = fTraceEndTime.clone();
             }
             endTime = ts;
             trangeUpdated = true;
@@ -180,8 +180,8 @@ public class TimeFrameView extends TmfView {
 
         // Compute the new time range
         TmfTimeRange subrange = new TmfTimeRange(startTime, endTime);
-        byte scale = startTime.getScale();
-        TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime, scale), scale, 0);
+        int scale = startTime.getScale();
+        TmfTimestamp interval = (TmfTimestamp) startTime.getDelta(endTime);
 
         // Update the spinner groups
         fStartGroup.setContent(fTraceTimeRange, startTime);
@@ -250,9 +250,9 @@ public class TimeFrameView extends TmfView {
             return;
 
         // Determine the new relative position
-        byte scale = range.getEndTime().getScale();
-        long total = range.getStartTime().getAdjustment(range.getEndTime(), scale);
-        long relative = range.getStartTime().getAdjustment(timestamp, scale);
+        int scale = range.getEndTime().getScale();
+        long total = range.getStartTime().getDelta(range.getEndTime()).getValue();
+        long relative = range.getStartTime().getDelta(timestamp).getValue();
 
         // Set the slider value
         final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0;
@@ -307,7 +307,7 @@ public class TimeFrameView extends TmfView {
 
         fCurrentTime = fTraceStartTime;
 
-        TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+        TmfTimestamp delta = (TmfTimestamp) fTraceStartTime.getDelta(fTraceEndTime);
         fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
         // fRangeGroup.setContent(fTraceSpan, delta);
         TmfTimestamp start = new TmfTimestamp(1, (byte) -1, 0);
@@ -332,7 +332,7 @@ public class TimeFrameView extends TmfView {
         fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
         fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime());
 
-        TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+        TmfTimestamp delta = (TmfTimestamp) fTraceStartTime.getDelta(fTraceEndTime);
         fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
         fRangeGroup.setContent(fTraceSpan, delta);
     }
@@ -345,8 +345,8 @@ public class TimeFrameView extends TmfView {
         if (signal.getSource() != this) {
             // Update the time frame
             TmfTimeRange selTimeRange = signal.getCurrentRange();
-            TmfTimestamp selStart = selTimeRange.getStartTime().synchronize(0, fScale);
-            TmfTimestamp selEnd = selTimeRange.getEndTime().synchronize(0, fScale);
+            TmfTimestamp selStart = (TmfTimestamp) selTimeRange.getStartTime().normalize(0, fScale);
+            TmfTimestamp selEnd   = (TmfTimestamp) selTimeRange.getEndTime().normalize(0, fScale);
 
             fupdateExternalListeners = false;
             // Update the widgets and prevent broadcast notifications to
@@ -355,7 +355,7 @@ public class TimeFrameView extends TmfView {
                 fStartGroup.setContent(fTraceTimeRange, selStart);
                 fEndGroup.setContent(fTraceTimeRange, selEnd);
 
-                TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment(selEnd, fScale), fScale, 0);
+                TmfTimestamp delta = (TmfTimestamp) selStart.getDelta(selEnd);
 
                 fRangeGroup.setContent(fTraceSpan, delta);
             }
@@ -374,7 +374,7 @@ public class TimeFrameView extends TmfView {
         if (signal.getSource() != this) {
             // prevent loop to external notifications
             fupdateExternalListeners = false;
-            fCurrentTime = signal.getCurrentTime().synchronize(0, fStartGroup.getCurrentTime().getScale());
+            fCurrentTime = (TmfTimestamp) signal.getCurrentTime().normalize(0, fStartGroup.getCurrentTime().getScale());
             if (fStartGroup.getCurrentTime().compareTo(fCurrentTime, false) > 0) {
                 fStartGroup.setContent(new TmfTimeRange(fCurrentTime, fEndGroup.getCurrentTime()), fCurrentTime);
             }
index fe5e6337f8656e1bf84f7048172d64c8cb88a821..fe075851593c5af7329d1079ee92169f2b4c3f32 100644 (file)
@@ -57,7 +57,7 @@ public class TmfCorePluginTest extends TestCase {
        // ------------------------------------------------------------------------
 
        public void testTmfCorePluginId() throws Exception {
-               assertEquals("Plugin ID", "org.eclipse.linuxtools.tmf", TmfCorePlugin.PLUGIN_ID);
+               assertEquals("Plugin ID", "org.eclipse.linuxtools.tmf.core", TmfCorePlugin.PLUGIN_ID);
        }
 
        public void testGetDefault() throws Exception {
index 9f90e1638f36083fd26a8246036cb2a09e815dbd..5ec2a28a0e9ed9b18a172a1dbbc50214ce0591fa 100644 (file)
@@ -199,7 +199,7 @@ public class TmfEventContentTest extends TestCase {
        }
 
        public void testToString2() {
-               String expected = "[TmfEventContent(1,-10,true,some string,[TmfTimestamp(1,2,3)])]";
+               String expected = "[TmfEventContent(1,-10,true,some string,TmfTimestamp [fValue=1, fScale=2, fPrecision=3])]";
                TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent0);
                assertEquals("toString", expected, content.toString());
        }
index 5f7d6307b4edf4e24d40b9999e3a77b6bef95f25..5733064efe3cc42e6534a991c97999528539d699 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.tmf.core.tests.event;
 
 import junit.framework.TestCase;
 
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
 
 /**
@@ -30,8 +31,8 @@ public class TmfTimestampTest extends TestCase {
 
        private final TmfTimestamp ts0 = new TmfTimestamp();
        private final TmfTimestamp ts1 = new TmfTimestamp(12345);
-       private final TmfTimestamp ts2 = new TmfTimestamp(12345, (byte) -1);
-       private final TmfTimestamp ts3 = new TmfTimestamp(12345, (byte)  2, 5);
+       private final TmfTimestamp ts2 = new TmfTimestamp(12345, -1);
+       private final TmfTimestamp ts3 = new TmfTimestamp(12345,  2, 5);
 
        private final TmfTimestamp ts0copy = new TmfTimestamp();
        private final TmfTimestamp ts1copy = new TmfTimestamp(12345);
@@ -92,7 +93,7 @@ public class TmfTimestampTest extends TestCase {
        }
 
        public void testCopyConstructor() throws Exception {
-               TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
+               TmfTimestamp ts0 = new TmfTimestamp(12345, 2, 5);
                TmfTimestamp ts = new TmfTimestamp(ts0);
                assertEquals("getValue", 12345, ts.getValue());
                assertEquals("getscale", 2, ts.getScale());
@@ -173,10 +174,10 @@ public class TmfTimestampTest extends TestCase {
        // ------------------------------------------------------------------------
 
        public void testToString() throws Exception {
-               assertEquals("toString", "[TmfTimestamp(0,0,0)]",      ts0.toString());
-               assertEquals("toString", "[TmfTimestamp(12345,0,0)]",  ts1.toString());
-               assertEquals("toString", "[TmfTimestamp(12345,-1,0)]", ts2.toString());
-               assertEquals("toString", "[TmfTimestamp(12345,2,5)]",  ts3.toString());
+               assertEquals("toString", "TmfTimestamp [fValue=0, fScale=0, fPrecision=0]",      ts0.toString());
+               assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=0, fPrecision=0]",  ts1.toString());
+               assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=-1, fPrecision=0]", ts2.toString());
+               assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=2, fPrecision=5]",  ts3.toString());
        }
 
        // ------------------------------------------------------------------------
@@ -206,104 +207,78 @@ public class TmfTimestampTest extends TestCase {
        }
 
        // ------------------------------------------------------------------------
-       // synchronize
+       // normalize
        // ------------------------------------------------------------------------
 
-       public void testSynchronizeOffset() throws Exception {
+       public void testNormalizeOffset() throws Exception {
 
-               TmfTimestamp ts = ts0.synchronize(0, (byte) 0);
+               ITmfTimestamp ts = ts0.normalize(0, 0);
                assertEquals("getValue",     0, ts.getValue());
                assertEquals("getscale",     0, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(12345, (byte) 0);
+               ts = ts0.normalize(12345, 0);
                assertEquals("getValue", 12345, ts.getValue());
                assertEquals("getscale",     0, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(10, (byte) 0);
+               ts = ts0.normalize(10, 0);
                assertEquals("getValue",    10, ts.getValue());
                assertEquals("getscale",     0, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(-10, (byte) 0);
+               ts = ts0.normalize(-10, 0);
                assertEquals("getValue",   -10, ts.getValue());
                assertEquals("getscale",     0, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
        }
 
-       public void testSynchronizeScale() throws Exception {
+       public void testNormalizeScale() throws Exception {
 
-               TmfTimestamp ts = ts0.synchronize(0, (byte) 10);
+               ITmfTimestamp ts = ts0.normalize(0, 10);
                assertEquals("getValue",     0, ts.getValue());
                assertEquals("getscale",    10, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(0, (byte) -10);
+               ts = ts0.normalize(0, -10);
                assertEquals("getValue",     0, ts.getValue());
                assertEquals("getscale",   -10, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
        }
 
-       public void testSynchronizeOffsetAndScale() throws Exception {
-               byte SCALE = 12;
+       public void testNormalizeOffsetAndScale() throws Exception {
+               int SCALE = 12;
 
-               TmfTimestamp ts = ts0.synchronize(0, SCALE);
+               ITmfTimestamp ts = ts0.normalize(0, SCALE);
                assertEquals("getValue",     0, ts.getValue());
                assertEquals("getscale", SCALE, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(12345, SCALE);
+               ts = ts0.normalize(12345, SCALE);
                assertEquals("getValue", 12345, ts.getValue());
                assertEquals("getscale", SCALE, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(10, SCALE);
+               ts = ts0.normalize(10, SCALE);
                assertEquals("getValue",    10, ts.getValue());
                assertEquals("getscale", SCALE, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
 
-               ts = ts0.synchronize(-10, SCALE);
+               ts = ts0.normalize(-10, SCALE);
                assertEquals("getValue",   -10, ts.getValue());
                assertEquals("getscale", SCALE, ts.getScale());
                assertEquals("getPrecision", 0, ts.getPrecision());
        }       
        
        // ------------------------------------------------------------------------
-       // getAdjustment
-       // ------------------------------------------------------------------------
-
-       public void testGetAdjustmentSameScale() throws Exception {
-               long delta = ts0.getAdjustment(ts0 , ts0.getScale());
-               assertEquals("delta", 0, delta);
-
-               delta = ts1.getAdjustment(ts1, ts1.getScale());
-               assertEquals("delta", 0, delta);
-
-               delta = ts0.getAdjustment(ts1, ts1.getScale());
-               assertEquals("delta", 12345, delta);
-
-               delta = ts1.getAdjustment(ts0, ts0.getScale());
-               assertEquals("delta", -12345, delta);
-       }
-
-       public void testGetAdjustmentDifferentScales() throws Exception {
-               long delta = ts0.getAdjustment(ts2, ts2.getScale());
-               assertEquals("delta", 12345, delta);
-
-               delta = ts2.getAdjustment(ts0, ts0.getScale());
-               assertEquals("delta", -1234, delta);
-       }
-
-       // ------------------------------------------------------------------------
-       // CompareTo
+       // compareTo
        // ------------------------------------------------------------------------
 
        public void testCompareToSameScale() throws Exception {
-               TmfTimestamp ts1 = new TmfTimestamp(900,  (byte) 0, 50);
-               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
-               TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
-               TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+               TmfTimestamp ts1 = new TmfTimestamp(900,  0, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000, 0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(1100, 0, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1000, 0, 75);
 
                assertTrue(ts1.compareTo(ts1, false) == 0);
 
@@ -321,10 +296,10 @@ public class TmfTimestampTest extends TestCase {
        }
 
        public void testCompareToDifferentScale() throws Exception {
-               TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
-               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
-               TmfTimestamp ts3 = new TmfTimestamp(110,  (byte) 1, 50);
-               TmfTimestamp ts4 = new TmfTimestamp(1,    (byte) 3, 75);
+               TmfTimestamp ts1 = new TmfTimestamp(9000, -1, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000,  0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(110,   1, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1,     3, 75);
 
                assertTrue("CompareTo", ts1.compareTo(ts1, false) == 0);
 
@@ -342,10 +317,10 @@ public class TmfTimestampTest extends TestCase {
        }
 
        public void testCompareToWithinPrecision() throws Exception {
-               TmfTimestamp ts1 = new TmfTimestamp(900,  (byte) 0, 50);
-               TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
-               TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
-               TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+               TmfTimestamp ts1 = new TmfTimestamp(900,  0, 50);
+               TmfTimestamp ts2 = new TmfTimestamp(1000, 0, 50);
+               TmfTimestamp ts3 = new TmfTimestamp(1100, 0, 50);
+               TmfTimestamp ts4 = new TmfTimestamp(1000, 0, 75);
 
                assertTrue("CompareTo", ts1.compareTo(ts1, true) == 0);
 
@@ -363,10 +338,10 @@ public class TmfTimestampTest extends TestCase {
        }
 
        public void testCompareToLargeScale() throws Exception {
-               TmfTimestamp ts1 = new TmfTimestamp(-1,    (byte) 100);
-               TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
-               TmfTimestamp ts3 = new TmfTimestamp(1,     (byte) 100);
-               TmfTimestamp ts4 = new TmfTimestamp(1000,  (byte) -100);
+               TmfTimestamp ts1 = new TmfTimestamp(-1,     100);
+               TmfTimestamp ts2 = new TmfTimestamp(-1000, -100);
+               TmfTimestamp ts3 = new TmfTimestamp(1,      100);
+               TmfTimestamp ts4 = new TmfTimestamp(1000,  -100);
 
                assertTrue("CompareTo", ts1.compareTo(ts2, false) < 0);
                assertTrue("CompareTo", ts1.compareTo(ts3, false) < 0);
@@ -386,12 +361,12 @@ public class TmfTimestampTest extends TestCase {
        }
 
        public void testCompareToBigRanges() throws Exception {
-               TmfTimestamp ts0a = new TmfTimestamp( 0, Byte.MAX_VALUE);
-               TmfTimestamp ts0b = new TmfTimestamp( 0, Byte.MIN_VALUE);
-               TmfTimestamp ts1  = new TmfTimestamp(-1, Byte.MAX_VALUE);
-               TmfTimestamp ts2  = new TmfTimestamp(-1, Byte.MIN_VALUE);
-               TmfTimestamp ts3  = new TmfTimestamp( 1, Byte.MAX_VALUE);
-               TmfTimestamp ts4  = new TmfTimestamp( 1, Byte.MIN_VALUE);
+               TmfTimestamp ts0a = new TmfTimestamp( 0, Integer.MAX_VALUE);
+               TmfTimestamp ts0b = new TmfTimestamp( 0, Integer.MIN_VALUE);
+               TmfTimestamp ts1  = new TmfTimestamp(-1, Integer.MAX_VALUE);
+               TmfTimestamp ts2  = new TmfTimestamp(-1, Integer.MIN_VALUE);
+               TmfTimestamp ts3  = new TmfTimestamp( 1, Integer.MAX_VALUE);
+               TmfTimestamp ts4  = new TmfTimestamp( 1, Integer.MIN_VALUE);
 
                assertEquals("CompareTo",  1, ts0a.compareTo(TmfTimestamp.BigBang,   false));
                assertEquals("CompareTo", -1, ts0a.compareTo(TmfTimestamp.BigCrunch, false));
@@ -424,70 +399,67 @@ public class TmfTimestampTest extends TestCase {
        
        public void testDelta() throws Exception {
            // Delta for same scale and precision (delta > 0)
-           TmfTimestamp ts0 = new TmfTimestamp(10, (byte)9);
-           TmfTimestamp ts1 = new TmfTimestamp(5,  (byte)9);
-           TmfTimestamp exp = new TmfTimestamp(5,  (byte)9);
+           TmfTimestamp ts0 = new TmfTimestamp(10, 9);
+           TmfTimestamp ts1 = new TmfTimestamp(5,  9);
+           TmfTimestamp exp = new TmfTimestamp(5,  9);
            
-           TmfTimestamp delta = ts0.getDelta(ts1);
+           ITmfTimestamp delta = ts0.getDelta(ts1);
            assertEquals("getDelta", 0, delta.compareTo(exp, false));
            
            // Delta for same scale and precision (delta < 0)
-           ts0 = new TmfTimestamp(5,  (byte)9);
-           ts1 = new TmfTimestamp(10, (byte)9);
-           exp = new TmfTimestamp(-5, (byte)9);
+           ts0 = new TmfTimestamp( 5, 9);
+           ts1 = new TmfTimestamp(10, 9);
+           exp = new TmfTimestamp(-5, 9);
 
            delta = ts0.getDelta(ts1);
            assertEquals("getDelta", 0, delta.compareTo(exp, false));
            
            // Delta for different scale and same precision (delta > 0)
-        ts0 = new TmfTimestamp(5,  (byte)9);
-        ts1 = new TmfTimestamp(10, (byte)8);
-        exp = new TmfTimestamp(4,  (byte)9);
+        ts0 = new TmfTimestamp( 5, 9);
+        ts1 = new TmfTimestamp(10, 8);
+        exp = new TmfTimestamp( 4, 9);
 
         delta = ts0.getDelta(ts1);
         assertEquals("getDelta", 0, delta.compareTo(exp, false));
 
         // Delta for different scale and same precision (delta > 0)
-        ts0 = new TmfTimestamp(5,  (byte)9);
-        ts1 = new TmfTimestamp(10, (byte)7);
-        exp = new TmfTimestamp(5,  (byte)9);
+        ts0 = new TmfTimestamp( 5, 9);
+        ts1 = new TmfTimestamp(10, 7);
+        exp = new TmfTimestamp( 5, 9);
 
         delta = ts0.getDelta(ts1);
         assertEquals("getDelta", 0, delta.compareTo(exp, false));
 
         // Delta for different scale and same precision
-        ts0 = new TmfTimestamp(10, (byte)9);
-        ts1 = new TmfTimestamp(5,  (byte)8);
-        exp = new TmfTimestamp(10, (byte)9);
+        ts0 = new TmfTimestamp(10, 9);
+        ts1 = new TmfTimestamp( 5, 8);
+        exp = new TmfTimestamp(10, 9);
 
         delta = ts0.getDelta(ts1);
         assertEquals("getDelta", 0, delta.compareTo(exp, false));
 
         // Delta for same scale and different precision
-        ts0 = new TmfTimestamp(10, (byte)9,1);
-        ts1 = new TmfTimestamp(5,  (byte)9, 2);
-        exp = new TmfTimestamp(5,  (byte)9, 2);
+        ts0 = new TmfTimestamp(10, 9, 1);
+        ts1 = new TmfTimestamp( 5, 9, 2);
+        exp = new TmfTimestamp( 5, 9, 3);
 
         delta = ts0.getDelta(ts1);
         assertEquals("getDelta", 0, delta.compareTo(exp, true));
-        assertEquals("precision", 2, delta.getPrecision());
+        assertEquals("precision", 3, delta.getPrecision());
         
         // Delta for same scale and different precision
-        ts0 = new TmfTimestamp(5,  (byte)9, 2);
-        ts1 = new TmfTimestamp(10, (byte)9, 1);
-        exp = new TmfTimestamp(-5, (byte)9, 2);
+        ts0 = new TmfTimestamp( 5, 9, 2);
+        ts1 = new TmfTimestamp(10, 9, 1);
+        exp = new TmfTimestamp(-5, 9, 3);
 
         delta = ts0.getDelta(ts1);
-        assertEquals("getDelta", 0, delta.compareTo(exp, true));
-        assertEquals("precision", 2, delta.getPrecision());
+        assertEquals("getDelta",  0, delta.compareTo(exp, true));
+        assertEquals("precision", 3, delta.getPrecision());
 
         // Delta for different scale and different precision
-        ts0 = new TmfTimestamp(5,  (byte)9, 2);
-        ts1 = new TmfTimestamp(10, (byte)8, 1);
-        exp = new TmfTimestamp(4,  (byte)9, 2);
-        assertEquals("precision", 2, delta.getPrecision());
-        assertEquals("precision", 2, delta.getPrecision());
-
+        ts0 = new TmfTimestamp( 5, 9, 2);
+        ts1 = new TmfTimestamp(10, 8, 1);
+        exp = new TmfTimestamp( 4, 9, 3);
         delta = ts0.getDelta(ts1);
         assertEquals("getDelta", 0, delta.compareTo(exp, true));
         assertEquals("precision", 2, delta.getPrecision());
index dcc5d6bca43f2b897fc11f35919ea96095905a15..01a1ccb4e0e0f4d17231b3cf375293f79250baae 100644 (file)
@@ -1,8 +1,8 @@
-org.eclipse.linuxtools.tmf/error=false
-org.eclipse.linuxtools.tmf/warning=false
-org.eclipse.linuxtools.tmf/info=false
+org.eclipse.linuxtools.tmf.core/error=false
+org.eclipse.linuxtools.tmf.core/warning=false
+org.eclipse.linuxtools.tmf.core/info=false
 
-org.eclipse.linuxtools.tmf/component=false
-org.eclipse.linuxtools.tmf/request=false
-org.eclipse.linuxtools.tmf/signal=false
-org.eclipse.linuxtools.tmf/event=false
+org.eclipse.linuxtools.tmf.core/component=false
+org.eclipse.linuxtools.tmf.core/request=false
+org.eclipse.linuxtools.tmf.core/signal=false
+org.eclipse.linuxtools.tmf.core/event=false
index 239b427776f42c46bd2b4bbc39e636c6f0af6329..0b484f87ac2e3dbfb255801a9befeb3e1cb9eb64 100644 (file)
@@ -28,7 +28,7 @@ public class TmfCorePlugin extends Plugin {
        // ------------------------------------------------------------------------
 
        // The plug-in ID
-       public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf"; //$NON-NLS-1$
+       public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
 
        // The shared instance
        private static TmfCorePlugin fPlugin;
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataEvent.java
new file mode 100644 (file)
index 0000000..0ea6ff7
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * <b><u>ITmfDataEvent</u></b>
+ * <p>
+ * The basic event structure in the TMF. In its canonical form, an event has:
+ * <ul>
+ * <li> a parent trace
+ * <li> a rank (order within the trace)
+ * <li> a source (reporting component)
+ * <li> a type
+ * <li> a content
+ * </ul>
+ * For convenience, a free-form reference field is also provided. It could be
+ * used as e.g. a location marker (filename:lineno) to indicate where the event
+ * was generated.
+ */
+public interface ITmfDataEvent {
+
+    /**
+     * @return the trace that 'owns' the event
+     */
+    public ITmfTrace<?> getTrace();
+
+    /**
+     * @return the event rank within the parent trace
+     */
+    public long getRank();
+
+    /**
+     * @return the event source
+     */
+    public String getSource();
+
+    /**
+     * @return the event type
+     */
+    public ITmfEventType getType();
+
+    /**
+     * @return the event content
+     */
+    public ITmfEventContent getContent();
+
+    /**
+     * @return the event reference
+     */
+    public String getReference();
+
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java
new file mode 100644 (file)
index 0000000..6c9e931
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEvent</u></b>
+ * <p>
+ * The ITmfEvent is essentially an ITmfDataEvent with a timestamp.
+*/
+public interface ITmfEvent extends ITmfDataEvent {
+
+    /**
+     * @return the event timestamp
+     */
+    public ITmfTimestamp getTimestamp();
+
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java
new file mode 100644 (file)
index 0000000..2b4240d
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventContent</u></b>
+ * <p>
+ */
+public interface ITmfEventContent extends Cloneable {
+
+    /**
+     * @return the raw event content
+     */
+    public Object getRawContent();
+
+    /**
+     * @return the formatted event content (string'ified)
+     */
+    public String getFmtContent();
+
+    /**
+     * @return the event type
+     */
+    public ITmfEventType getType();
+
+    /**
+     * @return the list of event fields
+     */
+    public ITmfEventField[] getFields();
+
+    /**
+     * @param name the field name
+     * @return the corresponding field
+     */
+    public ITmfEventField getField(String name) throws TmfNoSuchFieldException;
+
+    /**
+     * @return a clone of the event content
+     */
+    public ITmfEventContent clone();
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
new file mode 100644 (file)
index 0000000..edfc307
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventField</u></b>
+ * <p>
+ */
+public interface ITmfEventField {
+
+    /**
+     * @return the field name
+     */
+    public String getName();
+
+    /**
+     * @return the field value
+     */
+    public Object getValue();
+
+    /**
+     * @return the list of subfields (if any)
+     */
+    public ITmfEventField[] getSubFields();
+
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java
new file mode 100644 (file)
index 0000000..28a1d39
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventType</u></b>
+ * <p>
+ */
+public interface ITmfEventType extends Cloneable {
+
+    /**
+     * @return the event type context
+     */
+    public String getContext();
+
+    /**
+     * @return the event type name
+     */
+    public String getName();
+
+    /**
+     * @return the event fields
+     */
+    public ITmfEventField[] getFields();
+
+    /**
+     * @return a clone of the event content
+     */
+    public ITmfEventType clone();
+
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfTimestamp.java
new file mode 100644 (file)
index 0000000..853f254
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfTimestamp</u></b>
+ * <p>
+ */
+public interface ITmfTimestamp {
+
+    /**
+     * @return the timestamp value (magnitude)
+     */
+    public long getValue();
+
+    /**
+     * @return the timestamp scale (exponent)
+     */
+    public int getScale();
+
+    /**
+     * @return the timestamp precision (measurement tolerance)
+     */
+    public int getPrecision();
+
+    /**
+     * Normalize (adjust scale and offset) of the timerstamp
+     * 
+     * @param offset the offset to apply to the timestamp value (after scaling)
+     * @param scale the new timestamp scale
+     * @return a new 'adjusted' ITmfTimestamp
+     */
+    public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException;
+
+    /**
+     * Compares [this] and [ts] within timestamp precision
+     * 
+     * @param ts the other timestamp
+     * @param withinPrecision consider the precision when testing for equality
+     * @return -1, 0 or 1 (less than, equals, greater than)
+     */
+    public int compareTo(ITmfTimestamp ts, boolean withinPrecision);
+
+    /**
+     * Returns the difference between [this] and [ts] as a timestamp 
+     * 
+     * @param ts the other timestamp
+     * @return the time difference (this - other) as an ITmfTimestamp
+     */
+    public ITmfTimestamp getDelta(ITmfTimestamp ts);
+
+}
index c3e0262719ed03ead53023cbc743d3784102760e..05578c3b4743dc5e4f5c74cdec0470de00d4758f 100644 (file)
@@ -18,21 +18,11 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 /**
  * <b><u>TmfDataEvent</u></b>
  * <p>
- * The basic event structure in the TMF. In its canonical form, an event has:
- * <ul>
- * <li> a parent trace
- * <li> a rank (order within the trace)
- * <li> a source (reporting component)
- * <li> a type
- * <li> a content
- * </ul>
- * For convenience, a free-form reference field is also provided. It could be
- * used as e.g. a location marker (filename:lineno) to indicate where the event
- * was generated.
+ * A basic implementation of ITmfDataEvent.
  * 
  * Notice that for performance reasons TmfDataEvent is NOT immutable. If a copy
- * of an event is needed, use the copy constructor (shallow copy) or the
- * clone() method (deep copy).
+ * of an event is needed, use the copy constructor (shallow copy) or the clone()
+ * method (deep copy).
  */
 public class TmfDataEvent implements Cloneable {
 
@@ -233,8 +223,8 @@ public class TmfDataEvent implements Cloneable {
     @Override
     @SuppressWarnings("nls")
     public String toString() {
-        return "TmfDataEvent [fTrace=" + fTrace + ", fRank=" + fRank 
-                + ", fSource=" + fSource + ", fType=" + fType + ", fContent=" 
+        return "TmfDataEvent [fTrace=" + fTrace + ", fRank=" + fRank
+                + ", fSource=" + fSource + ", fType=" + fType + ", fContent="
                 + fContent + ", fReference=" + fReference + "]";
     }
 
index d0e9f8bf0377871fea9dac4a2eeac9390058a1a8..c8ddeb54174614054a12f5961772fbf47bf378da 100644 (file)
@@ -60,7 +60,8 @@ public class TmfEvent extends TmfDataEvent implements Cloneable {
      * @param reference the event reference
      */
     public TmfEvent(ITmfTrace<?> trace, long rank, TmfTimestamp timestamp, String source,
-                    TmfEventType type, String reference) {
+                    TmfEventType type, String reference)
+    {
         super(trace, rank, source, type, null, reference);
         fTimestamp = timestamp;
     }
@@ -69,7 +70,8 @@ public class TmfEvent extends TmfDataEvent implements Cloneable {
      * Constructor - no rank
      */
     public TmfEvent(ITmfTrace<?> parentTrace, TmfTimestamp timestamp, String source,
-                    TmfEventType type, String reference) {
+                    TmfEventType type, String reference)
+    {
         this(parentTrace, -1, timestamp, source, type, reference);
     }
 
index 4ecf90369e59793484a3d7ef64f901823b88a3e0..db2e216263ffdfea1e579df0212d8854f206f8af 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,6 +9,7 @@
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *   Thomas Gatterweh  - Updated scaling / synchronization
+ *   Francois Chouinard - Refactoring to align with TMF Event Model 1.0
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.event;
@@ -16,86 +17,65 @@ package org.eclipse.linuxtools.tmf.core.event;
 /**
  * <b><u>TmfTimestamp</u></b>
  * <p>
- * The fundamental time reference in the TMF.
- * <p>
- * It provides a generic timestamp implementation in its most basic form:
- * <ul>
- * <li>timestamp = [value] * 10**[scale] +/- [precision]
- * </ul>
- * Where:
- * <ul>
- * <li>[value] is an unstructured integer value
- * <li>[scale] is the magnitude of the value wrt some application-specific
- * base unit (e.g. the second)
- * <li>[precision] indicates the error on the value (useful for comparing
- * timestamps in different scales). Default: 0.
- * </ul>
- * In short:
- * <ul>
- * </ul>
- * To allow synchronization of timestamps from different reference clocks,
- * there is a possibility to "adjust" the timestamp by changing its scale
- * (traces of different time scale) and/or by adding an offset to its value
- * (clock drift between traces).
- * <p>
- * Notice that the adjusted timestamp value could be negative e.g. for events
- * that occurred before t0 wrt the reference clock.
+ * A generic implementation of ITmfTimestamp.
  */
-public class TmfTimestamp implements Cloneable, Comparable<TmfTimestamp> {
-
-       // ------------------------------------------------------------------------
-    // Attributes
-       // ------------------------------------------------------------------------
+public class TmfTimestamp implements ITmfTimestamp, Cloneable, Comparable<TmfTimestamp> {
 
-    protected long fValue;             // The timestamp raw value
-    protected byte fScale;             // The time scale
-    protected long fPrecision;         // The value precision (tolerance)
-
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
     // Constants
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
 
     // The beginning and end of time
-    public static final TmfTimestamp BigBang   = new TmfTimestamp(Long.MIN_VALUE, Byte.MAX_VALUE, 0);
-    public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Byte.MAX_VALUE, 0);
-    public static final TmfTimestamp Zero      = new TmfTimestamp(0, (byte) 0, 0);
+    public static final TmfTimestamp BigBang   = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE, 0);
+    public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE, 0);
+    public static final TmfTimestamp Zero      = new TmfTimestamp(0, 0, 0);
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
 
-       // ------------------------------------------------------------------------
+    protected long fValue;      // The timestamp raw value
+    protected int fScale;       // The time scale
+    protected int fPrecision;   // The value precision (tolerance)
+
+    // ------------------------------------------------------------------------
     // Constructors
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
 
     /**
      * Default constructor
      */
     public TmfTimestamp() {
-        this(0, (byte) 0, 0);
+        this(0, 0, 0);
     }
 
     /**
-     * Simple constructor with value only
+     * Simple constructor (scale = precision = 0)
+     *
+     * @param value the timestamp value
      */
     public TmfTimestamp(long value) {
-        this(value, (byte) 0, 0);
+        this(value, 0, 0);
     }
 
     /**
-     * Simple constructor with value and scale
+     * Simple constructor (precision = 0)
      * 
-     * @param value
-     * @param scale
+     * @param value the timestamp value
+     * @param scale the timestamp scale
      */
-    public TmfTimestamp(long value, byte scale) {
+    public TmfTimestamp(long value, int scale) {
         this(value, scale, 0);
     }
 
     /**
-     * Constructor with value, scale and precision
+     * Full constructor
      * 
-     * @param value
-     * @param scale
-     * @param precision
+     * @param value the timestamp value
+     * @param scale the timestamp scale
+     * @param precision the timestamp precision
      */
-    public TmfTimestamp(long value, byte scale, long precision) {
+    public TmfTimestamp(long value, int scale, int precision) {
         fValue = value;
         fScale = scale;
         fPrecision = Math.abs(precision);
@@ -104,294 +84,189 @@ public class TmfTimestamp implements Cloneable, Comparable<TmfTimestamp> {
     /**
      * Copy constructor
      * 
-     * @param other
+     * @param timestamp the timestamp to copy
      */
-    public TmfTimestamp(TmfTimestamp other) {
-       if (other == null)
-               throw new IllegalArgumentException();
-        fValue = other.fValue;
-        fScale = other.fScale;
-        fPrecision = other.fPrecision;
+    public TmfTimestamp(TmfTimestamp timestamp) {
+        if (timestamp == null)
+            throw new IllegalArgumentException();
+        fValue = timestamp.fValue;
+        fScale = timestamp.fScale;
+        fPrecision = timestamp.fPrecision;
     }
 
-       // ------------------------------------------------------------------------
-    // Accessors
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // ITmfTimestamp
+    // ------------------------------------------------------------------------
 
-    /**
-     * @return the timestamp value
-     */
     public long getValue() {
         return fValue;
     }
 
-    /**
-     * @return the timestamp scale
-     */
-    public byte getScale() {
+    public int getScale() {
         return fScale;
     }
 
-    /**
-     * @return the timestamp value precision
-     */
-    public long getPrecision() {
+    public int getPrecision() {
         return fPrecision;
     }
 
-       // ------------------------------------------------------------------------
-    // Operators
-       // ------------------------------------------------------------------------
+    private static final long scalingFactors[] = new long[] {
+        1L,
+        10L,
+        100L,
+        1000L,
+        10000L,
+        100000L,
+        1000000L,
+        10000000L,
+        100000000L,
+        1000000000L,
+        10000000000L,
+        100000000000L,
+        1000000000000L,
+        10000000000000L,
+        100000000000000L,
+        1000000000000000L,
+        10000000000000000L,
+        100000000000000000L,
+        1000000000000000000L,
+    };
 
-    /**
-     * Return a shifted and scaled timestamp.
-     * 
-     * Limitation: The scaling is limited to MAX_SCALING orders of magnitude.
-     * The main reason is that the 64 bits value starts to lose any significance
-     * meaning beyond that scale difference and it's not even worth the trouble
-     * to switch to BigDecimal arithmetics.
-     * 
-     * @param offset the shift value (in the same scale as newScale)
-     * @param newScale the new timestamp scale
-     * @return the synchronized timestamp in the new scale
-     * @throws ArithmeticException
-     */
-    public TmfTimestamp synchronize(long offset, byte newScale) throws ArithmeticException {
+    public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException {
 
-        long newValue = fValue;
-        long newPrecision = fPrecision;
+        long value = fValue;
+        int precision = fPrecision;
 
-        // Handle the easy case
-        if (fScale == newScale && offset == 0)
-               return this;
-        
-        // Determine the scaling factor
-        if (fScale != newScale) {
-            int scaleDiff = Math.abs(fScale - newScale);
-            // Let's try to be realistic...
+        // Handle the trivial case
+        if (fScale == scale && offset == 0)
+            return new TmfTimestamp(this);
+
+        // First, scale the timestamp
+        if (fScale != scale) {
+            int scaleDiff = Math.abs(fScale - scale);
             if (scaleDiff >= scalingFactors.length) {
                 throw new ArithmeticException("Scaling exception"); //$NON-NLS-1$
             }
-            // Adjust the timestamp
+
             long scalingFactor = scalingFactors[scaleDiff];
-            if (newScale < fScale) {
-                newValue *= scalingFactor;
-                newPrecision *= scalingFactor;
+            if (scale < fScale) {
+                value *= scalingFactor;
+                precision *= scalingFactor;
             } else {
-                newValue /= scalingFactor;
-                newPrecision /= scalingFactor;
+                value /= scalingFactor;
+                precision /= scalingFactor;
             }
         }
 
+        // Then, apply the offset
         if (offset < 0) {
-               newValue = (newValue < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : newValue + offset;
+            value = (value < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : value + offset;
         } else {
-               newValue = (newValue > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : newValue + offset;
+            value = (value > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : value + offset;
         }
 
-        return new TmfTimestamp(newValue, newScale, newPrecision);
+        return new TmfTimestamp(value, scale, precision);
     }
 
-    private static final long scalingFactors[] = new long[] {
-       1L,
-       10L,
-       100L,
-       1000L,
-       10000L,
-       100000L,
-       1000000L,
-       10000000L,
-       100000000L,
-       1000000000L,
-       10000000000L,
-       100000000000L,
-       1000000000000L,
-       10000000000000L,
-       100000000000000L,
-       1000000000000000L,
-       10000000000000000L,
-       100000000000000000L,
-       1000000000000000000L,
-    };
+    public int compareTo(ITmfTimestamp ts, boolean withinPrecision) {
 
-    private static final long scalingLimits[] = new long[] {
-       Long.MAX_VALUE / 1L,
-       Long.MAX_VALUE / 10L,
-       Long.MAX_VALUE / 100L,
-       Long.MAX_VALUE / 1000L,
-       Long.MAX_VALUE / 10000L,
-       Long.MAX_VALUE / 100000L,
-       Long.MAX_VALUE / 1000000L,
-       Long.MAX_VALUE / 10000000L,
-       Long.MAX_VALUE / 100000000L,
-       Long.MAX_VALUE / 1000000000L,
-       Long.MAX_VALUE / 10000000000L,
-       Long.MAX_VALUE / 100000000000L,
-       Long.MAX_VALUE / 1000000000000L,
-       Long.MAX_VALUE / 10000000000000L,
-       Long.MAX_VALUE / 100000000000000L,
-       Long.MAX_VALUE / 1000000000000000L,
-       Long.MAX_VALUE / 10000000000000000L,
-       Long.MAX_VALUE / 100000000000000000L,
-       Long.MAX_VALUE / 1000000000000000000L,
-    };
-
-    public static long getScalingFactor(byte scale)
-    {
-       return scalingFactors[scale];
-    }
-    
-    /**
-     * Compute the adjustment, in the reference scale, needed to synchronize
-     * this timestamp with a reference timestamp.
-     * 
-     * @param reference the reference timestamp to synchronize with
-     * @param scale the scale of the adjustment
-     * @return the adjustment term in the reference time scale
-     * @throws ArithmeticException
-     */
-    public long getAdjustment(TmfTimestamp reference, byte scale) throws ArithmeticException {
-        TmfTimestamp ts1 = synchronize(0, scale);
-        TmfTimestamp ts2 = reference.synchronize(0, scale);
-        return ts2.fValue - ts1.fValue;
+        // Check the corner cases (we can't use equals() because it uses compareTo()...)
+        if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale()))
+            return 0;
+        if ((fValue == BigBang.fValue && fScale == BigBang.fScale) || (ts.getValue() == BigCrunch.fValue && ts.getScale() == BigCrunch.fScale))
+            return -1;
+        if ((fValue == BigCrunch.fValue && fScale == BigCrunch.fScale) || (ts.getValue() == BigBang.fValue && ts.getScale() == BigBang.fScale))
+            return 1;
+        
+        try {
+            ITmfTimestamp nts = ts.normalize(0, fScale);
+            long delta = fValue - nts.getValue();
+            if ((delta == 0) || (withinPrecision && (Math.abs(delta) <= (fPrecision + nts.getPrecision())))) {
+                return 0;
+            }
+            return (delta > 0) ? 1 : -1;
+        }
+        catch (ArithmeticException e) {
+            // Scaling error. We can figure it out nonetheless.
+
+            // First, look at the sign of the mantissa
+            long value = ts.getValue();
+            if (fValue == 0 && value == 0)
+                return 0;
+            if (fValue  < 0 && value >= 0)
+                return -1;
+            if (fValue >= 0 && value  < 0)
+                return 1;
+
+            // Otherwise, just compare the scales
+            int scale = ts.getScale();
+            return (fScale > scale) ? (fValue > 0) ? 1 : -1 : (fValue > 0) ? -1 : 1;  
+        }
     }
 
-    /**
-     * Compute the delta between two timestamps (adjusted to scale of current timestamp).
-     * 
-     * @param reference the reference timestamp to synchronize with
-     * @return the delta timestamp 
-     * @throws ArithmeticException
-     */
-    public TmfTimestamp getDelta(TmfTimestamp other) throws ArithmeticException {
-        TmfTimestamp newSecond = other;
-        if ((fScale != other.fScale) || (fPrecision != other.fPrecision)) {
-            newSecond = other.synchronize(0, fScale);
-        }
-        return new TmfTimestamp(fValue - newSecond.fValue,
-                                fScale, 
-                                newSecond.fPrecision > fPrecision ? newSecond.fPrecision : fPrecision);
+    @Override
+    public ITmfTimestamp getDelta(ITmfTimestamp ts) {
+        ITmfTimestamp nts = ts.normalize(0, fScale);
+        long value = fValue - nts.getValue();
+        return new TmfTimestamp(value, fScale, fPrecision + nts.getPrecision());
     }
 
-    /**
-     * Compare with another timestamp
-     * 
-     * @param other the other timestamp
-     * @param withinPrecision indicates if precision is to be take into consideration
-     * @return -1: this timestamp is lower (i.e. anterior)
-     *          0: timestamps are equal (within precision if requested)
-     *          1: this timestamp is higher (i.e. posterior)
-     */
-    public int compareTo(final TmfTimestamp other, boolean withinPrecision) {
-
-               // If values have the same time scale, perform the comparison
-               if (fScale == other.fScale) {
-                       if (withinPrecision)
-                               return compareWithinPrecision(this.fValue, this.fPrecision, other.fValue, other.fPrecision);
-                       else
-                               return compareNoPrecision(this.fValue, other.fValue);
-               }
-
-               // If values have different time scales, adjust to the finest one and
-               // then compare. If the scaling difference is too large, revert to
-               // some heuristics. Hopefully, nobody will try to compare galactic and
-               // quantic clock events...
-               int scaleDiff = Math.abs(fScale - other.fScale);
-               long factor, limit;
-               if (scaleDiff < scalingFactors.length) {
-                       factor = scalingFactors[scaleDiff];
-                       limit = scalingLimits[scaleDiff];
-               } else {
-                       factor = 0;
-                       limit = 0; // !!! 0 can always be scaled!!!
-               }
-
-               if (fScale < other.fScale) {
-                       // this has finer scale, so other should be scaled
-                       if (withinPrecision)
-                               if (other.fValue > limit || other.fValue < -limit
-                                               || other.fPrecision > limit
-                                               || other.fPrecision < -limit)
-                                       return other.fValue > 0 ? -1 : +1; // other exceeds scaling limit
-                               else
-                                       return compareWithinPrecision(this.fValue, this.fPrecision,
-                                                       other.fValue * factor, other.fPrecision * factor);
-                       else if (other.fValue > limit || other.fValue < -limit)
-                               return other.fValue > 0 ? -1 : +1; // other exceeds scaling limit
-                       else
-                               return compareNoPrecision(this.fValue, other.fValue * factor);
-               } else {
-                       // other has finer scale, so this should be scaled
-                       if (withinPrecision)
-                               if (this.fValue > limit || this.fValue < -limit
-                                               || this.fPrecision > limit || this.fPrecision < -limit)
-                                       return this.fValue > 0 ? +1 : -1; // we exceed scaling limit
-                               else
-                                       return compareWithinPrecision(this.fValue * factor,
-                                                       this.fPrecision * factor, other.fValue,
-                                                       other.fPrecision);
-                       else if (this.fValue > limit || this.fValue < -limit)
-                               return this.fValue > 0 ? +1 : -1; // we exceed scaling limit
-                       else
-                               return compareNoPrecision(this.fValue * factor, other.fValue);
-               }
+    // ------------------------------------------------------------------------
+    // Cloneable
+    // ------------------------------------------------------------------------
+
+    @Override
+    public TmfTimestamp clone() {
+        TmfTimestamp clone = null;
+        try {
+            clone = (TmfTimestamp) super.clone();
+            clone.fValue = fValue;
+            clone.fScale = fScale;
+            clone.fPrecision = fPrecision;
+        } catch (CloneNotSupportedException e) {
+        }
+        return clone;
     }
 
-       private static int compareNoPrecision(long thisValue, long otherValue) {
-               return (thisValue == otherValue) ? 0 : (thisValue < otherValue) ? -1 : 1;
-       }
+    // ------------------------------------------------------------------------
+    // Comparable
+    // ------------------------------------------------------------------------
 
-       private static int compareWithinPrecision(long thisValue, long thisPrecision, long otherValue, long otherPrecision) {
-               if ((thisValue + thisPrecision) < (otherValue - otherPrecision))
-                       return -1;
-               if ((thisValue - thisPrecision) > (otherValue + otherPrecision))
-                       return 1;
-               return 0;
-       }
+    @Override
+    public int compareTo(TmfTimestamp o) {
+        return compareTo(o, false);
+    }
 
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
     // Object
-       // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
 
     @Override
     public int hashCode() {
-               int result = 17;
-               result = 37 * result + (int) (fValue ^ (fValue >>> 32));
-               result = 37 * result + fScale;
-               result = 37 * result + (int) (fPrecision ^ (fPrecision >>> 32));
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (fValue ^ (fValue >>> 32));
+        result = prime * result + fScale;
+        result = prime * result + fPrecision;
         return result;
     }
 
-       @Override
+    @Override
     public boolean equals(Object other) {
+        if (this == other)
+            return true;
+        if (other == null)
+            return false;
         if (!(other instanceof TmfTimestamp))
-               return false;
-        TmfTimestamp o = (TmfTimestamp) other;
-        return compareTo(o, false) == 0;
+            return false;
+        TmfTimestamp ts = (TmfTimestamp) other;
+        return compareTo(ts, false) == 0;
     }
 
     @Override
     @SuppressWarnings("nls")
     public String toString() {
-       return "[TmfTimestamp(" + fValue + "," + fScale + "," + fPrecision + ")]";
-    }
-
-    @Override
-    public TmfTimestamp clone() {
-       TmfTimestamp clone = null;
-               try {
-                       clone = (TmfTimestamp) super.clone();
-               clone.fValue = fValue;
-               clone.fScale = fScale;
-               clone.fPrecision = fPrecision;
-               } catch (CloneNotSupportedException e) {
-               }
-               return clone;
+        return "TmfTimestamp [fValue=" + fValue + ", fScale=" + fScale + ", fPrecision=" + fPrecision + "]";
     }
 
-       @Override
-       public int compareTo(TmfTimestamp o) {
-               return compareTo(o, false);
-       }
-
 }
index 94c19987b7909f39c6113e4d8d2e8f90dd67eeaa..437c3ebd57f1cfd624dd8993cdc96ceaf0c85250 100644 (file)
@@ -68,7 +68,7 @@ public class TmfUml2SDSyncLoaderSignalTest extends TestCase {
         
         TmfTimeRange range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
         // Get range window for tests below
-        TmfTimestamp rangeWindow =  range.getEndTime().getDelta(range.getStartTime());
+        TmfTimestamp rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
         TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
 
         fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, currentTime));
index 4cce2bf60618b5385746ad43355947e735443935..74c321b61de30df370dba6b8bcde3e986e45ca85 100644 (file)
@@ -40,7 +40,7 @@ public class TimeChartEvent implements ITimeEvent {
 \r
     public TimeChartEvent(TimeChartAnalysisEntry parentEntry, TmfEvent event, long rank, TimeChartDecorationProvider decorationProvider) {\r
         fParentEntry = parentEntry;\r
-        fTime = event.getTimestamp().synchronize((long) 0, TIMESTAMP_SCALE).getValue();\r
+        fTime = event.getTimestamp().normalize(0, TIMESTAMP_SCALE).getValue();\r
         fDuration = 0;\r
         fFirstRank = fLastRank = rank;\r
         fRankRangeList = new RankRangeList(rank);\r
index 16c67359b89cca5b25ed525339e7e09f8a959215..6bf91252044d596b6e38e0efb6575dcbc12f102c 100644 (file)
@@ -63,13 +63,13 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
 \r
     public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$\r
 \r
-    private static final byte TIMESTAMP_SCALE = -9;\r
+    private static final int TIMESTAMP_SCALE = -9;\r
 \r
     private final int fDisplayWidth;\r
     private Composite fComposite;\r
     private ITimeAnalysisViewer fViewer;\r
     private final ArrayList<TimeChartAnalysisEntry> fTimeAnalysisEntries = new ArrayList<TimeChartAnalysisEntry>();\r
-    private final Map<ITmfTrace, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace, TimeChartDecorationProvider>();\r
+    private final Map<ITmfTrace<?>, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace<?>, TimeChartDecorationProvider>();\r
     private ArrayList<DecorateThread> fDecorateThreads;\r
     private long fStartTime = 0;\r
     private long fStopTime = Long.MAX_VALUE;\r
@@ -102,7 +102,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
         for (IEditorReference editorReference : editorReferences) {\r
             IEditorPart editor = editorReference.getEditor(false);\r
             if (editor instanceof ITmfTraceEditor) {\r
-                ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();\r
+                ITmfTrace<?> trace = ((ITmfTraceEditor) editor).getTrace();\r
                 if (trace != null) {\r
                     IResource resource = ((ITmfTraceEditor) editor).getResource();\r
                     TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);\r
@@ -152,7 +152,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     }\r
 \r
     private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, long stopRank, long startTime, long stopTime) {\r
-        ITmfTrace trace = timeAnalysisEntry.getTrace();\r
+        ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
         TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
         if (decorationProvider == null) {\r
             return; // the trace has been closed\r
@@ -427,7 +427,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
         public void decorateEvent(TimeChartEvent timeChartEvent) {\r
             // TODO possible concurrency problem here with ItemizeJob\r
             TimeChartAnalysisEntry timeAnalysisEntry = (TimeChartAnalysisEntry) timeChartEvent.getEntry();\r
-            ITmfTrace trace = timeAnalysisEntry.getTrace();\r
+            ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
             int priority = ColorSettingsManager.PRIORITY_NONE;\r
             boolean isBookmarked = false;\r
             boolean isVisible = false;\r
@@ -451,7 +451,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
                         if (event == null) {\r
                             break;\r
                         }\r
-                        long eventTime = event.getTimestamp().synchronize(0, (byte) -9).getValue();\r
+                        long eventTime = event.getTimestamp().normalize(0, -9).getValue();\r
                         if (eventTime >= timeChartEvent.getTime() && eventTime <= timeChartEvent.getTime() + timeChartEvent.getDuration()) {\r
                             priority = Math.min(priority, ColorSettingsManager.getColorSettingPriority(event));\r
                         }\r
@@ -522,14 +522,14 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     }\r
 \r
     @Override\r
-    public void filterApplied(ITmfFilter filter, ITmfTrace trace) {\r
+    public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
         TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
         decorationProvider.filterApplied(filter);\r
         redecorate();\r
     }\r
 \r
     @Override\r
-    public void searchApplied(ITmfFilter filter, ITmfTrace trace) {\r
+    public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
         TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
         decorationProvider.searchApplied(filter);\r
         redecorate();\r
@@ -543,7 +543,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     public void traceOpened(TmfTraceOpenedSignal signal) {\r
         if (fTimeAnalysisEntries == null)\r
             return;\r
-        final ITmfTrace trace = signal.getTrace();\r
+        final ITmfTrace<?> trace = signal.getTrace();\r
         final IResource resource = signal.getResource();\r
         final ITmfEventsFilterProvider eventsFilterProvider = signal.getEventsFilterProvider();\r
         TimeChartAnalysisEntry timeAnalysisEntry = null;\r
@@ -570,7 +570,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     public void traceClosed(TmfTraceClosedSignal signal) {\r
         if (fTimeAnalysisEntries == null)\r
             return;\r
-        final ITmfTrace trace = signal.getTrace();\r
+        final ITmfTrace<?> trace = signal.getTrace();\r
         for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
             if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
                 fTimeAnalysisEntries.remove(i);\r
@@ -584,7 +584,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     @TmfSignalHandler\r
     public void traceSelected(TmfTraceSelectedSignal signal) {\r
         if (signal.getSource() != this && fTimeAnalysisEntries != null) {\r
-            ITmfTrace trace = signal.getTrace();\r
+            ITmfTrace<?> trace = signal.getTrace();\r
             for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
                 if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
                     fViewer.setSelectedTrace(fTimeAnalysisEntries.get(i));\r
@@ -598,7 +598,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
     public void traceUpdated(TmfTraceUpdatedSignal signal) {\r
         if (fTimeAnalysisEntries == null)\r
             return;\r
-        final ITmfTrace trace = signal.getTrace();\r
+        final ITmfTrace<?> trace = signal.getTrace();\r
         for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
             TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i);\r
             if (timeAnalysisEntry.getTrace().equals(trace)) {\r
@@ -610,7 +610,7 @@ public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionList
 \r
     @TmfSignalHandler\r
     public void currentTimeUpdated(TmfTimeSynchSignal signal) {\r
-        long time = signal.getCurrentTime().synchronize(0, TIMESTAMP_SCALE).getValue();\r
+        long time = signal.getCurrentTime().normalize(0, TIMESTAMP_SCALE).getValue();\r
         fViewer.setSelectedTime(time, true, this);\r
     }\r
 \r
index 1a5f92217b8f7cfbc936cc2d423be84bd20519fb..a9dfead06eb473a7721446e590cf9f6524bc2e48 100755 (executable)
@@ -125,11 +125,11 @@ public class DrawableToolTip implements PaintListener {
         int step = SCALE_LENGTH / 10;
 
         // double gr = (max - min) / 10;
-        TmfTimestamp minMaxdelta = minMaxRange.getEndTime().getDelta(minMaxRange.getStartTime());
+        TmfTimestamp minMaxdelta = (TmfTimestamp) minMaxRange.getEndTime().getDelta(minMaxRange.getStartTime());
         double gr = (minMaxdelta.getValue()) / (double) 10;
 
         // double delta = currentValue-min;
-        TmfTimestamp delta = currentValue.getDelta(minMaxRange.getStartTime());
+        TmfTimestamp delta = (TmfTimestamp) currentValue.getDelta(minMaxRange.getStartTime());
         long absDelta = Math.abs(delta.getValue());
         
         int colIndex = 0;
index efaf6ae801d1703996b1a9d4ce4519a09672ffdc..e05f59f8ceded4088218c55d8899e9e82a202dbc 100755 (executable)
@@ -593,7 +593,7 @@ public class SDWidget extends ScrollView implements SelectionListener, IProperty
             //double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
             TmfTimestamp firstTime = ((ITimeRange) currentGraphNode).getEndTime();
             TmfTimestamp lastTime = ((ITimeRange) toolTipNode).getEndTime();
-            TmfTimestamp delta = lastTime.getDelta(firstTime);
+            TmfTimestamp delta = (TmfTimestamp) lastTime.getDelta(firstTime);
             postfix += delta.toString();
         } else {
             if ((toolTipNode instanceof ITimeRange) && ((ITimeRange) toolTipNode).hasTimeInfo()) {
index 6ee571ab3b00fb44998497bc04427a898a942f93..8fc1cc68d33eb4299e53f79296cd79fc8c227a80 100755 (executable)
@@ -330,10 +330,10 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
 
             min = frame.getMinTime();
             max = frame.getMaxTime();
-            TmfTimestamp minMaxdelta = max.getDelta(min);
+            TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
             double gr = (minMaxdelta.getValue()) / (double) 10;
 
-            TmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
+            TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
             long absDelta = Math.abs(delta.getValue());
             
             ColorImpl color;
@@ -490,7 +490,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
                 int m1Y = Math.round(y1 * zoomValue);
                 int m2Y = Math.round(y2 * zoomValue);
                 if ((m1Y < e.y) && (m2Y >= e.y)) {
-                    TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+                    TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
                     tooltip.showToolTip(delta, min, max);
                 }
             }
@@ -579,10 +579,10 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
             }
         }
 
-        TmfTimestamp minMaxdelta = max.getDelta(min);
+        TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
         double gr = (minMaxdelta.getValue()) / (double) 10;
 
-        TmfTimestamp delta = time2.getDelta(time1).getDelta(min);
+        TmfTimestamp delta = (TmfTimestamp) time2.getDelta(time1).getDelta(min);
         long absDelta = Math.abs(delta.getValue());
 
         int colIndex = 0;
@@ -799,10 +799,10 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
                     done = true;
                     prevNodeY = m1Y;
                     nextNodeY = m2Y;
-                    TmfTimestamp minMaxdelta = max.getDelta(min);
+                    TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
                     double gr = (minMaxdelta.getValue()) / (double) 10;
 
-                    TmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
+                    TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
                     long absDelta = Math.abs(delta.getValue());
 
                     int colIndex = 0;
@@ -910,7 +910,7 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener {
                 int m1Y = Math.round(y1 * zoomValue);
                 int m2Y = Math.round(y2 * zoomValue);
                 if ((m1Y < prevNodeY + 1) && (m2Y >= prevNodeY + 1)) {
-                    TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+                    TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
                     tooltip.showToolTip(delta, min, max);
                     tooltip.hideToolTip();
                 }
index ecb9322a46225b33eeaa73ed5ddb3aca76b8be0b..c65a7e60af0a7a604ebb7049320f7b357e1a9fef 100755 (executable)
@@ -453,7 +453,7 @@ public class BasicFrame extends GraphNode {
     }
 
     protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
-        TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+        TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
         if (computeMinMax) {
             minTime = delta.clone();
             if (minTime.compareTo(TmfTimestamp.Zero, false) < 0) {
index c9467ff89bc36059090e97c9ee612372912f96a2..422482eb71fa8f0f17c00f366874d8c8527ab295 100644 (file)
@@ -324,7 +324,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
         try {
             if ((signal.getSource() != this) && (fFrame != null) && !fIsSignalSent) {
                 TmfTimeRange newTimeRange = signal.getCurrentRange();
-                TmfTimestamp delta = newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
+                TmfTimestamp delta = (TmfTimestamp) newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
                 fInitialWindow = delta.getValue();
 
                 fIsSelect = false;
index b7e850ba49bb7c6873d5c51360e650c40bf6c575..812fa2f1a0f6de4dd9b349922460675d861d91b5 100755 (executable)
@@ -121,13 +121,13 @@ public class MinMaxDialog extends Dialog {
         // double max=0;
         long min = 0;
         long max = 0;
-        byte scale = 0;
-        long precision = 0;
+        int scale = 0;
+        int precision = 0;
         try {
             min = Long.parseLong(minText.getText());
             max = Long.parseLong(maxText.getText());
-            scale = Byte.parseByte(scaleText.getText());
-            precision = Long.parseLong(precisionText.getText());
+            scale = Integer.parseInt(scaleText.getText());
+            precision = Integer.parseInt(precisionText.getText());
 
             sdWidget.getFrame().setMax(new TmfTimestamp(max, scale, precision));
             sdWidget.getFrame().setMin(new TmfTimestamp(min, scale, precision));
This page took 0.07988 seconds and 5 git commands to generate.