charts: Move a few classes from .ui to .core
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 30 Jan 2017 16:14:01 +0000 (11:14 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 31 Jan 2017 14:09:24 +0000 (09:09 -0500)
Some interfaces for the consumers and aggregators that were previously in
the .ui package can be moved to core as they do not depend on anything ui.
The data can be consumed in the core plugin and only displayed in the
.ui.

Change-Id: I50e2f73407bc912a6236df04012d7f9468945ea5
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/89881
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
17 files changed:
tmf/org.eclipse.tracecompass.tmf.chart.core/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/IConsumerAggregator.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/package-info.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IChartConsumer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IDataConsumer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/ISeriesConsumer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/NumericalConsumer.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/package-info.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.chart.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/aggregator/IConsumerAggregator.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/aggregator/NumericalConsumerAggregator.java
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IChartConsumer.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IDataConsumer.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/ISeriesConsumer.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/NumericalConsumer.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/package-info.java [deleted file]
tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/data/package-info.java [new file with mode: 0644]

index 090207bef9ab7d24b39546cdb4e4b2f7e7ea61fa..ed20b3f8c2ab3a3f81974bbf7e5971462abcea4c 100644 (file)
@@ -10,10 +10,12 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.common.core
-Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.chart.core.descriptor;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
- org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
+Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.chart.core.chart;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
+ org.eclipse.tracecompass.internal.provisional.tmf.chart.core.descriptor;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
  org.eclipse.tracecompass.internal.provisional.tmf.chart.core.model;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
  org.eclipse.tracecompass.internal.provisional.tmf.chart.core.resolver;x-friends:="org.eclipse.tracecompass.tmf.chart.ui",
  org.eclipse.tracecompass.internal.tmf.chart.core;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.chart.core.chart;x-internal:=true
+ org.eclipse.tracecompass.internal.tmf.chart.core.aggregator;x-friends:="org.eclipse.tracecompass.tmf.chart.ui,org.eclipse.tracecompass.tmf.chart.core.tests",
+ org.eclipse.tracecompass.internal.tmf.chart.core.chart;x-internal:=true,
+ org.eclipse.tracecompass.internal.tmf.chart.core.consumer;x-friends:="org.eclipse.tracecompass.tmf.chart.ui,org.eclipse.tracecompass.tmf.chart.core.tests"
 Import-Package: com.google.common.collect
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/IConsumerAggregator.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/IConsumerAggregator.java
new file mode 100644 (file)
index 0000000..43d0436
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.chart.core.aggregator;
+
+import java.util.function.Consumer;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.tmf.chart.core.consumer.IDataConsumer;
+import org.eclipse.tracecompass.internal.tmf.chart.core.consumer.NumericalConsumer;
+
+/**
+ * This interface is used for performing operations on multiple
+ * {@link IDataConsumer}. As of right now, it is used for computing total range
+ * of multiple {@link NumericalConsumer}. Normally, it should process the data
+ * consumers only when they are done processing individual object from the
+ * stream of data.
+ *
+ * @author Gabriel-Andrew Pollo-Guilbert
+ */
+public interface IConsumerAggregator extends Consumer<@NonNull IDataConsumer> {
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/package-info.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/aggregator/package-info.java
new file mode 100644 (file)
index 0000000..49fc8a6
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.tmf.chart.core.aggregator;
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IChartConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IChartConsumer.java
new file mode 100644 (file)
index 0000000..7427b50
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.chart.core.consumer;
+
+import java.util.function.Consumer;
+
+/**
+ * This interface is the entry point for consuming data in the chart plugin.
+ * Each chart type should implement this interface. When an object needs to be
+ * consumed, it is first sent to this consumer which passes the object all its
+ * {@link ISeriesConsumer}. When all the data has been consumed,
+ * {@link #finish()} is called.
+ * <p>
+ * Consider a XY chart with <i>n</i> series where both axes are numerical. Thus,
+ * the implemented class should have <i>n</i> {@link ISeriesConsumer}. This
+ * consumer first receives an object from the stream of data and passes it to
+ * all its series consumer. Since both axes are numerical, the series consumer
+ * test and send the object to their X and Y {@link IDataConsumer}. This last
+ * consumer contains the final series that can be plotted. When all the data has
+ * been processed, the {@link #finish()} method is called. In the case of an XY
+ * chart with numerical axes, it is used for computing the total range of the
+ * all the series.
+ *
+ * @see ISeriesConsumer
+ * @see IDataConsumer
+ *
+ * @author Gabriel-Andrew Pollo-Guilbert
+ */
+public interface IChartConsumer extends Consumer<Object> {
+
+    /**
+     * This method is called when all the data has been processed. It can be
+     * used by the implemented chart consumer or not.
+     */
+    void finish();
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IDataConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/IDataConsumer.java
new file mode 100644 (file)
index 0000000..32195de
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.chart.core.consumer;
+
+import java.util.function.Consumer;
+
+/**
+ * This interface consumes any data that comes from a {@link ISeriesConsumer}.
+ * <p>
+ * For example, it can be though of an axis consumer in XY charts since there
+ * should be one for the X and Y axis.
+ *
+ * @author Gabriel-Andrew Pollo-Guilbert
+ */
+public interface IDataConsumer extends Consumer<Object> {
+
+    /**
+     * This method maps and tests if a value is valid for the chart. It should
+     * always be called before {@link #accept(Object)}.
+     *
+     * @param obj
+     *            The object to map the value from
+     * @return {@code true} if the mapped value is valid, else {@code false}
+     */
+    boolean test(Object obj);
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/ISeriesConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/ISeriesConsumer.java
new file mode 100644 (file)
index 0000000..d0a3090
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.chart.core.consumer;
+
+import java.util.function.Consumer;
+
+/**
+ * This interface consumes any data that comes from a {@link IChartConsumer}.
+ * Every object that it receives is sent to its own {@link IDataConsumer}. The
+ * main benefit of this consumer is that it can easily reject (x, y) couple that
+ * are invalid for plotting. An object can be tested with
+ * {@link IDataConsumer#test(Object)} before being consumed into an (x, y)
+ * couple.
+ * <p>
+ * For example, a XY chart should have a series consumer for each of the plotted
+ * series. There would have two consumer in a XY chart that plot the following
+ * series: "start VS name" and "end VS name".
+ *
+ * @see IChartConsumer
+ * @see IDataConsumer
+ *
+ * @author Gabriel-Andrew Pollo-Guilbert
+ */
+public interface ISeriesConsumer extends Consumer<Object> {
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/NumericalConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/NumericalConsumer.java
new file mode 100644 (file)
index 0000000..b8243b3
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.chart.core.consumer;
+
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.internal.provisional.tmf.chart.core.resolver.INumericalResolver;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * This class processes numerical values in order to create valid data for a XY
+ * chart. It takes a {@link INumericalResolver} for mapping values and a
+ * {@link Predicate} for testing them.
+ * <p>
+ * It also computes the minimum and maximum values of all the numbers it has
+ * consumed.
+ *
+ * @author Gabriel-Andrew Pollo-Guilbert
+ */
+public class NumericalConsumer implements IDataConsumer {
+
+    // ------------------------------------------------------------------------
+    // Members
+    // ------------------------------------------------------------------------
+
+    private final INumericalResolver<Object, Number> fResolver;
+    private final Predicate<@Nullable Number> fPredicate;
+    private final List<Number> fData = new ArrayList<>();
+    private Number fMin;
+    private Number fMax;
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Constructor with a default non null predicate.
+     *
+     * @param resolver
+     *            The resolver that maps values
+     */
+    public NumericalConsumer(INumericalResolver<Object, Number> resolver) {
+        fResolver = resolver;
+        fPredicate = Objects::nonNull;
+        fMin = fResolver.getMaxValue();
+        fMax = fResolver.getMinValue();
+    }
+
+    /**
+     * Overloaded constructor with a predicate.
+     *
+     * @param resolver
+     *            The resolver that maps values
+     * @param predicate
+     *            The predicate for testing values
+     */
+    public NumericalConsumer(INumericalResolver<Object, Number> resolver, Predicate<@Nullable Number> predicate) {
+        fResolver = resolver;
+        fPredicate = predicate;
+        fMin = fResolver.getMaxValue();
+        fMax = fResolver.getMinValue();
+    }
+
+    // ------------------------------------------------------------------------
+    // Overriden methods
+    // ------------------------------------------------------------------------
+
+    @Override
+    public boolean test(Object obj) {
+        Number number = fResolver.getMapper().apply(obj);
+        return fPredicate.test(number);
+    }
+
+    @Override
+    public void accept(Object obj) {
+        Number number = checkNotNull(fResolver.getMapper().apply(obj));
+
+        /* Update the minimum value */
+        if (fResolver.getComparator().compare(number, fMin) < 0) {
+            fMin = number;
+        }
+
+        /* Update the maximum value */
+        if (fResolver.getComparator().compare(number, fMax) > 0) {
+            fMax = number;
+        }
+
+        fData.add(number);
+    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Accessor that returns the generated list of number.
+     *
+     * @return The list of number
+     */
+    public List<Number> getData() {
+        return ImmutableList.copyOf(fData);
+    }
+
+    /**
+     * Accessor that returns the minimum numerical value that has been consumed.
+     *
+     * @return The minimum value
+     */
+    public Number getMin() {
+        return fMin;
+    }
+
+    /**
+     * Accessor that returns the maximum numerical value that has been consumed.
+     *
+     * @return The maximum value
+     */
+    public Number getMax() {
+        return fMax;
+    }
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/package-info.java b/tmf/org.eclipse.tracecompass.tmf.chart.core/src/org/eclipse/tracecompass/internal/tmf/chart/core/consumer/package-info.java
new file mode 100644 (file)
index 0000000..301a0ad
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.tmf.chart.core.consumer;
index c84b53819d9cb430e767deb4a1964ad64180c393..887fed290fbff346c4c42300b8377033b2dba329 100644 (file)
@@ -16,8 +16,6 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.tmf.core
 Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.chart.ui.chart;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.chart.ui;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.chart.ui.aggregator;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.chart.ui.data;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.chart.ui.format;x-internal:=true
 Import-Package: com.google.common.collect
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/aggregator/IConsumerAggregator.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/aggregator/IConsumerAggregator.java
deleted file mode 100644 (file)
index d66d379..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.chart.ui.aggregator;
-
-import java.util.function.Consumer;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.tmf.chart.ui.consumer.IDataConsumer;
-import org.eclipse.tracecompass.internal.tmf.chart.ui.consumer.NumericalConsumer;
-
-/**
- * This interface is used for performing operations on multiple
- * {@link IDataConsumer}. As of right now, it is used for computing total range
- * of multiple {@link NumericalConsumer}. Normally, it should process the data
- * consumers only when they are done processing individual object from the
- * stream of data.
- *
- * FIXME: Find a better name. It consumes consumer, but it kind of seems
- * confusing calling it IConsumerConsumer.
- *
- * @author Gabriel-Andrew Pollo-Guilbert
- */
-public interface IConsumerAggregator extends Consumer<@NonNull IDataConsumer> {
-
-}
index fab063a3ea6ec28b46bc22d9db64fbd39655851a..d09a36fe7d6baa3a53c7de61f19fd5e92a28da4f 100644 (file)
@@ -12,8 +12,9 @@ package org.eclipse.tracecompass.internal.tmf.chart.ui.aggregator;
 import java.math.BigDecimal;
 
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.tmf.chart.ui.consumer.IDataConsumer;
-import org.eclipse.tracecompass.internal.tmf.chart.ui.consumer.NumericalConsumer;
+import org.eclipse.tracecompass.internal.tmf.chart.core.aggregator.IConsumerAggregator;
+import org.eclipse.tracecompass.internal.tmf.chart.core.consumer.IDataConsumer;
+import org.eclipse.tracecompass.internal.tmf.chart.core.consumer.NumericalConsumer;
 import org.eclipse.tracecompass.internal.tmf.chart.ui.data.ChartRange;
 import org.eclipse.tracecompass.internal.tmf.chart.ui.data.ChartRangeMap;
 
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IChartConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IChartConsumer.java
deleted file mode 100644 (file)
index 95b7897..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;
-
-import java.util.function.Consumer;
-
-/**
- * This interface is the entry point for consuming data in the chart plugin.
- * Each chart type should implement this interface. When an object needs to be
- * consumed, it is first sent to this consumer which passes the object all its
- * {@link ISeriesConsumer}. When all the data has been consumed,
- * {@link #finish()} is called.
- * <p>
- * Consider a XY chart with <i>n</i> series where both axes are numerical. Thus,
- * the implemented class should have <i>n</i> {@link ISeriesConsumer}. This
- * consumer first receives an object from the stream of data and passes it to
- * all its series consumer. Since both axes are numerical, the series consumer
- * test and send the object to their X and Y {@link IDataConsumer}. This last
- * consumer contains the final series that can be plotted. When all the data has
- * been processed, the {@link #finish()} method is called. In the case of an XY
- * chart with numerical axes, it is used for computing the total range of the
- * all the series.
- *
- * @see ISeriesConsumer
- * @see IDataConsumer
- *
- * @author Gabriel-Andrew Pollo-Guilbert
- */
-public interface IChartConsumer extends Consumer<Object> {
-
-    /**
-     * This method is called when all the data has been processed. It can be
-     * used by the implemented chart consumer or not.
-     */
-    void finish();
-
-}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IDataConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/IDataConsumer.java
deleted file mode 100644 (file)
index d3c79c3..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;
-
-import java.util.function.Consumer;
-
-/**
- * This interface consumes any data that comes from a {@link ISeriesConsumer}.
- * <p>
- * For example, it can be though of an axis consumer in XY charts since there
- * should be one for the X and Y axis.
- *
- * @author Gabriel-Andrew Pollo-Guilbert
- */
-public interface IDataConsumer extends Consumer<Object> {
-
-    /**
-     * This method maps and tests if a value is valid for the chart. It should
-     * always be called before {@link #accept(Object)}.
-     *
-     * @param obj
-     *            The object to map the value from
-     * @return {@code true} if the mapped value is valid, else {@code false}
-     */
-    boolean test(Object obj);
-
-}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/ISeriesConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/ISeriesConsumer.java
deleted file mode 100644 (file)
index 8e57255..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;
-
-import java.util.function.Consumer;
-
-/**
- * This interface consumes any data that comes from a {@link IChartConsumer}.
- * Every object that it receives is sent to its own {@link IDataConsumer}. The
- * main benefit of this consumer is that it can easily reject (x, y) couple that
- * are invalid for plotting. An object can be tested with
- * {@link IDataConsumer#test(Object)} before being consumed into an (x, y)
- * couple.
- * <p>
- * For example, a XY chart should have a series consumer for each of the plotted
- * series. There would have two consumer in a XY chart that plot the following
- * series: "start VS name" and "end VS name".
- *
- * @see IChartConsumer
- * @see IDataConsumer
- *
- * @author Gabriel-Andrew Pollo-Guilbert
- */
-public interface ISeriesConsumer extends Consumer<Object> {
-
-}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/NumericalConsumer.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/NumericalConsumer.java
deleted file mode 100644 (file)
index bd4b308..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.function.Predicate;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.provisional.tmf.chart.core.resolver.INumericalResolver;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * This class processes numerical values in order to create valid data for a XY
- * chart. It takes a {@link INumericalResolver} for mapping values and a
- * {@link Predicate} for testing them.
- * <p>
- * It also computes the minimum and maximum values of all the numbers it has
- * consumed.
- *
- * @author Gabriel-Andrew Pollo-Guilbert
- */
-public class NumericalConsumer implements IDataConsumer {
-
-    // ------------------------------------------------------------------------
-    // Members
-    // ------------------------------------------------------------------------
-
-    private final INumericalResolver<Object, Number> fResolver;
-    private final Predicate<@Nullable Number> fPredicate;
-    private final List<Number> fData = new ArrayList<>();
-    private Number fMin;
-    private Number fMax;
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-
-    /**
-     * Constructor with a default non null predicate.
-     *
-     * @param resolver
-     *            The resolver that maps values
-     */
-    public NumericalConsumer(INumericalResolver<Object, Number> resolver) {
-        fResolver = resolver;
-        fPredicate = Objects::nonNull;
-        fMin = fResolver.getMaxValue();
-        fMax = fResolver.getMinValue();
-    }
-
-    /**
-     * Overloaded constructor with a predicate.
-     *
-     * @param resolver
-     *            The resolver that maps values
-     * @param predicate
-     *            The predicate for testing values
-     */
-    public NumericalConsumer(INumericalResolver<Object, Number> resolver, Predicate<@Nullable Number> predicate) {
-        fResolver = resolver;
-        fPredicate = predicate;
-        fMin = fResolver.getMaxValue();
-        fMax = fResolver.getMinValue();
-    }
-
-    // ------------------------------------------------------------------------
-    // Overriden methods
-    // ------------------------------------------------------------------------
-
-    @Override
-    public boolean test(Object obj) {
-        Number number = fResolver.getMapper().apply(obj);
-        return fPredicate.test(number);
-    }
-
-    @Override
-    public void accept(Object obj) {
-        Number number = checkNotNull(fResolver.getMapper().apply(obj));
-
-        /* Update the minimum value */
-        if (fResolver.getComparator().compare(number, fMin) < 0) {
-            fMin = number;
-        }
-
-        /* Update the maximum value */
-        if (fResolver.getComparator().compare(number, fMax) > 0) {
-            fMax = number;
-        }
-
-        fData.add(number);
-    }
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-
-    /**
-     * Accessor that returns the generated list of number.
-     *
-     * @return The list of number
-     */
-    public List<Number> getData() {
-        return ImmutableList.copyOf(fData);
-    }
-
-    /**
-     * Accessor that returns the minimum numerical value that has been consumed.
-     *
-     * @return The minimum value
-     */
-    public Number getMin() {
-        return fMin;
-    }
-
-    /**
-     * Accessor that returns the maximum numerical value that has been consumed.
-     *
-     * @return The maximum value
-     */
-    public Number getMax() {
-        return fMax;
-    }
-
-}
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/package-info.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/consumer/package-info.java
deleted file mode 100644 (file)
index 4a0d816..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 École Polytechnique de Montréal
- *
- * 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
- *******************************************************************************/
-
-@org.eclipse.jdt.annotation.NonNullByDefault
-package org.eclipse.tracecompass.internal.tmf.chart.ui.consumer;
diff --git a/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/data/package-info.java b/tmf/org.eclipse.tracecompass.tmf.chart.ui/src/org/eclipse/tracecompass/internal/tmf/chart/ui/data/package-info.java
new file mode 100644 (file)
index 0000000..c81c7a5
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.tmf.chart.ui.data;
This page took 0.035504 seconds and 5 git commands to generate.