Move EventsIterator to timegraph package
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 25 Apr 2013 20:49:47 +0000 (16:49 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 26 Apr 2013 21:24:53 +0000 (17:24 -0400)
Change-Id: I83df2ca0a9a5f74be8814e3c204b5a871629d500
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/12220
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Hudson CI
org.eclipse.linuxtools.lttng2.kernel.ui/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/common/EventIterator.java [deleted file]
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowEntry.java
org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesEntry.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/EventIterator.java [new file with mode: 0644]

index 0d36e378d8d6bccb95652b0cf6ab6ef851f605bb..68d4201d5ef2464d804c5f8710c1db1ae882aec4 100644 (file)
@@ -20,6 +20,5 @@ Require-Bundle: org.eclipse.ui,
 Export-Package: org.eclipse.linuxtools.internal.lttng2.kernel.ui;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.views;x-internal:=true,
- org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.controlflow;x-internal:=true,
  org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;x-internal:=true
diff --git a/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/common/EventIterator.java b/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/common/EventIterator.java
deleted file mode 100644 (file)
index 135bf26..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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:
- *   Patrick Tasse - Initial API and implementation
- *   Patrick Tasse - Fix for split events
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
-
-/**
- * An iterator for time events
- */
-public class EventIterator implements Iterator<ITimeEvent> {
-
-    private final long fStartTime;
-    private final long fEndTime;
-    private List<ITimeEvent> fEventList;
-    private List<ITimeEvent> fZoomedEventList;
-    private long fZoomedStartTime;
-    private long fZoomedEndTime;
-    private int fIndex = 0;
-    private int fZoomedIndex= 0;
-    private ITimeEvent fNext = null;
-    private ITimeEvent fSplitNext = null;
-    private ITimeEvent fZoomedNext = null;
-
-    /**
-     * Basic constructor, with start time and end times equal to the lowest and
-     * highest values possible, respectively.
-     *
-     * @param eventList
-     *            The list on which this iterator will iterate
-     * @param zoomedEventList
-     *            The "zoomed" list
-     */
-    public EventIterator(List<ITimeEvent> eventList, List<ITimeEvent> zoomedEventList) {
-        this(eventList, zoomedEventList, Long.MIN_VALUE, Long.MAX_VALUE);
-    }
-
-    /**
-     * Complete constructor, where we specify start and end times.
-     *
-     * @param eventList
-     *            The list on which this iterator will iterate
-     * @param zoomedEventList
-     *            The "zoomed" list
-     * @param startTime
-     *            The start time
-     * @param endTime
-     *            The end time
-     */
-    public EventIterator(List<ITimeEvent> eventList,
-            List<ITimeEvent> zoomedEventList, long startTime, long endTime) {
-        fEventList = eventList;
-        fZoomedEventList = zoomedEventList;
-        if (zoomedEventList != null && zoomedEventList.size() > 0) {
-            fZoomedStartTime = zoomedEventList.get(0).getTime();
-            ITimeEvent lastEvent = zoomedEventList.get(zoomedEventList.size() - 1);
-            fZoomedEndTime = lastEvent.getTime() + lastEvent.getDuration();
-        } else {
-            fZoomedStartTime = Long.MAX_VALUE;
-            fZoomedEndTime = Long.MIN_VALUE;
-        }
-        fStartTime = startTime;
-        fEndTime = endTime;
-    }
-
-    @Override
-    public boolean hasNext() {
-        if (fNext == null && fEventList != null) {
-            while (fIndex < fEventList.size()) {
-                ITimeEvent event = fEventList.get(fIndex++);
-                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime &&
-                        (event.getTime() < fZoomedStartTime || event.getTime() + event.getDuration() > fZoomedEndTime)) {
-                    // the event is visible and is not completely hidden by the zoomed events
-                    fNext = event;
-                    if (event.getTime() < fZoomedEndTime && event.getTime() + event.getDuration() > fZoomedStartTime) {
-                        // the event is partially hidden by the zoomed events and must be split
-                        fNext = null;
-                        if (event.getTime() + event.getDuration() > fZoomedEndTime && fZoomedEndTime < fEndTime) {
-                            // the end of the event is partially hidden by the zoomed events and is visible
-                            fNext = new TimeEvent(event.getEntry(), fZoomedEndTime, event.getTime() + event.getDuration() - fZoomedEndTime);
-                        }
-                        if (event.getTime() < fZoomedStartTime && fZoomedStartTime > fStartTime) {
-                            // the start of the event is partially hidden by the zoomed events and is visible
-                            fSplitNext = fNext;
-                            fNext = new TimeEvent(event.getEntry(), event.getTime(), fZoomedStartTime - event.getTime());
-                        }
-                    }
-                    if (fNext != null) {
-                        break;
-                    }
-                }
-            }
-            if (fNext == null) {
-                fEventList = null;
-            }
-        }
-
-        if (fZoomedNext == null && fZoomedEventList != null) {
-            while (fZoomedIndex < fZoomedEventList.size()) {
-                ITimeEvent event = fZoomedEventList.get(fZoomedIndex++);
-                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {
-                    // the zoomed event is visible
-                    fZoomedNext = event;
-                    break;
-                }
-            }
-            if (fZoomedNext == null) {
-                fZoomedEventList = null;
-            }
-        }
-
-        return fNext != null || fZoomedNext != null;
-    }
-
-    @Override
-    public ITimeEvent next() {
-        if (hasNext()) {
-            if (fZoomedNext != null && (fNext == null || fZoomedNext.getTime() <= fNext.getTime())) {
-                ITimeEvent event = fZoomedNext;
-                fZoomedNext = null;
-                return event;
-            }
-            ITimeEvent event = fNext;
-            fNext = fSplitNext;
-            fSplitNext = null;
-            return event;
-        }
-        throw new NoSuchElementException();
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException();
-    }
-}
index b3bc377b0802591747d285a2c625e2cf35bcca9d..69ee120fcf5f388d4a7ee44eaa3eead531ceec72 100644 (file)
@@ -16,8 +16,8 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;
 import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 
index a51c418148b0083e0face98055c136e07799f0b4..2e9ebbb32c0d1f1b5386bd10f6fd2c1ae5183f6d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -16,8 +16,8 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;
 import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.EventIterator;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/EventIterator.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/EventIterator.java
new file mode 100644 (file)
index 0000000..7ab57c5
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+
+/**
+ * An iterator for time events. Events from the zoomed event list override any
+ * events from the underlying event list.
+ * @since 2.0
+ */
+public class EventIterator implements Iterator<ITimeEvent> {
+
+    private final long fStartTime;
+    private final long fEndTime;
+    private List<ITimeEvent> fEventList;
+    private List<ITimeEvent> fZoomedEventList;
+    private long fZoomedStartTime;
+    private long fZoomedEndTime;
+    private int fIndex = 0;
+    private int fZoomedIndex= 0;
+    private ITimeEvent fNext = null;
+    private ITimeEvent fSplitNext = null;
+    private ITimeEvent fZoomedNext = null;
+
+    /**
+     * Basic constructor, with start time and end times equal to the lowest and
+     * highest values possible, respectively.
+     *
+     * @param eventList
+     *            The list on which this iterator will iterate
+     * @param zoomedEventList
+     *            The "zoomed" list
+     */
+    public EventIterator(List<ITimeEvent> eventList, List<ITimeEvent> zoomedEventList) {
+        this(eventList, zoomedEventList, Long.MIN_VALUE, Long.MAX_VALUE);
+    }
+
+    /**
+     * Complete constructor, where we specify start and end times.
+     *
+     * @param eventList
+     *            The list on which this iterator will iterate
+     * @param zoomedEventList
+     *            The "zoomed" list
+     * @param startTime
+     *            The start time
+     * @param endTime
+     *            The end time
+     */
+    public EventIterator(List<ITimeEvent> eventList,
+            List<ITimeEvent> zoomedEventList, long startTime, long endTime) {
+        fEventList = eventList;
+        fZoomedEventList = zoomedEventList;
+        if (zoomedEventList != null && zoomedEventList.size() > 0) {
+            fZoomedStartTime = zoomedEventList.get(0).getTime();
+            ITimeEvent lastEvent = zoomedEventList.get(zoomedEventList.size() - 1);
+            fZoomedEndTime = lastEvent.getTime() + lastEvent.getDuration();
+        } else {
+            fZoomedStartTime = Long.MAX_VALUE;
+            fZoomedEndTime = Long.MIN_VALUE;
+        }
+        fStartTime = startTime;
+        fEndTime = endTime;
+    }
+
+    @Override
+    public boolean hasNext() {
+        if (fNext == null && fEventList != null) {
+            while (fIndex < fEventList.size()) {
+                ITimeEvent event = fEventList.get(fIndex++);
+                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime &&
+                        (event.getTime() < fZoomedStartTime || event.getTime() + event.getDuration() > fZoomedEndTime)) {
+                    // the event is visible and is not completely hidden by the zoomed events
+                    fNext = event;
+                    if (event.getTime() < fZoomedEndTime && event.getTime() + event.getDuration() > fZoomedStartTime) {
+                        // the event is partially hidden by the zoomed events and must be split
+                        fNext = null;
+                        if (event.getTime() + event.getDuration() > fZoomedEndTime && fZoomedEndTime < fEndTime) {
+                            // the end of the event is partially hidden by the zoomed events and is visible
+                            fNext = new TimeEvent(event.getEntry(), fZoomedEndTime, event.getTime() + event.getDuration() - fZoomedEndTime);
+                        }
+                        if (event.getTime() < fZoomedStartTime && fZoomedStartTime > fStartTime) {
+                            // the start of the event is partially hidden by the zoomed events and is visible
+                            fSplitNext = fNext;
+                            fNext = new TimeEvent(event.getEntry(), event.getTime(), fZoomedStartTime - event.getTime());
+                        }
+                    }
+                    if (fNext != null) {
+                        break;
+                    }
+                }
+            }
+            if (fNext == null) {
+                fEventList = null;
+            }
+        }
+
+        if (fZoomedNext == null && fZoomedEventList != null) {
+            while (fZoomedIndex < fZoomedEventList.size()) {
+                ITimeEvent event = fZoomedEventList.get(fZoomedIndex++);
+                if (event.getTime() + event.getDuration() >= fStartTime && event.getTime() <= fEndTime) {
+                    // the zoomed event is visible
+                    fZoomedNext = event;
+                    break;
+                }
+            }
+            if (fZoomedNext == null) {
+                fZoomedEventList = null;
+            }
+        }
+
+        return fNext != null || fZoomedNext != null;
+    }
+
+    @Override
+    public ITimeEvent next() {
+        if (hasNext()) {
+            if (fZoomedNext != null && (fNext == null || fZoomedNext.getTime() <= fNext.getTime())) {
+                ITimeEvent event = fZoomedNext;
+                fZoomedNext = null;
+                return event;
+            }
+            ITimeEvent event = fNext;
+            fNext = fSplitNext;
+            fSplitNext = null;
+            return event;
+        }
+        throw new NoSuchElementException();
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}
This page took 0.030134 seconds and 5 git commands to generate.