analysis: rename DensityTimeFormat to SubSecondTimeWithUnitFormat
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 7 Jan 2016 20:32:05 +0000 (15:32 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 13 Jan 2016 22:09:51 +0000 (17:09 -0500)
Make it public.

Change-Id: I6adf91b7b15ccc96105f35940641d65704b1ab3d
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/63786
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/SubSecondTimeWithUnitFormat.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/density/DensityTimeFormat.java [deleted file]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/density/SimpleTooltipProvider.java

diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/SubSecondTimeWithUnitFormat.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/SubSecondTimeWithUnitFormat.java
new file mode 100644 (file)
index 0000000..5631c26
--- /dev/null
@@ -0,0 +1,74 @@
+/**********************************************************************
+ * Copyright (c) 2015, 2016 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
+ **********************************************************************/
+
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore;
+
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+
+/**
+ * Time format, it will take a time in nano seconds and convert it to a string
+ * with 3 decimals max.
+ *
+ * examples:
+ * <ul>
+ * <li>100 -> "100 ns"</li>
+ * <li>1001 -> "1.001 us" (mu)</li>
+ * <li>314159264 -> "312.159 ms"</li>
+ * <li>10000002000000 -> "1000.002 s"</li>
+ * </ul>
+ */
+public final class SubSecondTimeWithUnitFormat extends Format {
+
+
+    private static final long serialVersionUID = -5147827135781459548L;
+
+    private static final String SECONDS = "s"; //$NON-NLS-1$
+    private static final String NANOSECONDS = "ns"; //$NON-NLS-1$
+    private static final String MILLISECONDS = "ms"; //$NON-NLS-1$
+    private static final String MICROSECONDS = "\u00B5" + SECONDS; //$NON-NLS-1$
+
+    private static final int NANOS_PER_SEC = 1000000000;
+    private static final int NANOS_PER_MILLI = 1000000;
+    private static final int NANOS_PER_MICRO = 1000;
+
+    private final DecimalFormat fDecimalFormat = new DecimalFormat("#.###"); //$NON-NLS-1$
+
+    @Override
+    public Object parseObject(@Nullable String source, @Nullable ParsePosition pos) {
+        return source == null ? "" : source; //$NON-NLS-1$
+    }
+
+    @Override
+    public StringBuffer format(@Nullable Object obj, @Nullable StringBuffer toAppendTo, @Nullable FieldPosition pos) {
+        final @Nullable StringBuffer appender = toAppendTo;
+        if ((obj != null) && (obj instanceof Double || obj instanceof Long)) {
+            double formattedTime = obj instanceof Long ? ((Long) obj).doubleValue() : ((Double) obj).doubleValue();
+            String unit = NANOSECONDS;
+            if (formattedTime > NANOS_PER_SEC) {
+                unit = SECONDS;
+                formattedTime /= NANOS_PER_SEC;
+            } else if (formattedTime > NANOS_PER_MILLI) {
+                unit = MILLISECONDS;
+                formattedTime /= NANOS_PER_MILLI;
+            } else if (formattedTime > NANOS_PER_MICRO) {
+                unit = MICROSECONDS;
+                formattedTime /= NANOS_PER_MICRO;
+            }
+            String timeString = fDecimalFormat.format(formattedTime);
+            return appender == null ? new StringBuffer() : NonNullUtils.checkNotNull(appender.append(timeString).append(' ').append(unit));
+        }
+        return new StringBuffer();
+    }
+}
\ No newline at end of file
index 542a5dccfb8441752b26be925432781fac902240..46bdd1fff09763c80cd55b55cffd0c3c3b75f5bd 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -11,6 +11,7 @@ package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
 
+import java.text.Format;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -26,8 +27,8 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule;
 import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
 import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density.DensityTimeFormat;
 import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density.MouseDragZoomProvider;
 import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density.MouseSelectionProvider;
 import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density.SimpleTooltipProvider;
@@ -67,7 +68,7 @@ import com.google.common.collect.Lists;
  */
 public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer {
 
-    private static final DensityTimeFormat DENSITY_TIME_FORMATTER = new DensityTimeFormat();
+    private static final Format DENSITY_TIME_FORMATTER = new SubSecondTimeWithUnitFormat();
     private static final RGB BAR_COLOR = new RGB(0x42, 0x85, 0xf4);
     private final Chart fChart;
     private final MouseDragZoomProvider fDragZoomProvider;
diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/density/DensityTimeFormat.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/density/DensityTimeFormat.java
deleted file mode 100644 (file)
index c1c641c..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2015 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
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density;
-
-import java.text.DecimalFormat;
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParsePosition;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
-
-/**
- * Density format, it will take a time in NanoSeconds and convert it to a string
- * with 3 digits.
- *
- * @author Matthew Khouzam
- */
-public final class DensityTimeFormat extends Format {
-
-
-    private static final long serialVersionUID = -5147827135781459548L;
-
-    private static final String SECONDS = "s"; //$NON-NLS-1$
-    private static final String NANOSECONDS = "ns"; //$NON-NLS-1$
-    private static final String MILLISECONDS = "ms"; //$NON-NLS-1$
-    private static final String MICROSECONDS = "\u00B5" + SECONDS; //$NON-NLS-1$
-
-    private static final int NANOS_PER_SEC = 1000000000;
-    private static final int NANOS_PER_MILLI = 1000000;
-    private static final int NANOS_PER_MICRO = 1000;
-
-    private final DecimalFormat fDecimalFormat = new DecimalFormat("#.###"); //$NON-NLS-1$
-
-    @Override
-    public Object parseObject(@Nullable String source, @Nullable ParsePosition pos) {
-        return source == null ? "" : source; //$NON-NLS-1$
-    }
-
-    @Override
-    public StringBuffer format(@Nullable Object obj, @Nullable StringBuffer toAppendTo, @Nullable FieldPosition pos) {
-        final @Nullable StringBuffer appender = toAppendTo;
-        if ((obj != null) && (obj instanceof Double || obj instanceof Long)) {
-            double formattedTime = obj instanceof Long ? ((Long) obj).doubleValue() : ((Double) obj).doubleValue();
-            String unit = NANOSECONDS;
-            if (formattedTime > NANOS_PER_SEC) {
-                unit = SECONDS;
-                formattedTime /= NANOS_PER_SEC;
-            } else if (formattedTime > NANOS_PER_MILLI) {
-                unit = MILLISECONDS;
-                formattedTime /= NANOS_PER_MILLI;
-            } else if (formattedTime > NANOS_PER_MICRO) {
-                unit = MICROSECONDS;
-                formattedTime /= NANOS_PER_MICRO;
-            }
-            String timeString = fDecimalFormat.format(formattedTime);
-            return appender == null ? new StringBuffer() : NonNullUtils.checkNotNull(appender.append(timeString).append(' ').append(unit));
-        }
-        return new StringBuffer();
-    }
-}
\ No newline at end of file
index 91ee2400da31c681875d6bf3d6a6fd35422493f0..f42c0af9a6e20e6e96f43d1c9f6b021f87446eeb 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -15,6 +15,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseTrackListener;
 import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
 import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityViewer;
 import org.swtchart.IAxis;
 import org.swtchart.IBarSeries;
@@ -29,7 +30,7 @@ import org.swtchart.ISeries;
  */
 public class SimpleTooltipProvider extends BaseMouseProvider implements MouseTrackListener {
 
-    private static final Format FORMAT = new DensityTimeFormat();
+    private static final Format FORMAT = new SubSecondTimeWithUnitFormat();
 
     /**
      * Constructor for a tool tip provider.
This page took 0.029063 seconds and 5 git commands to generate.