From 64228bfe646ab30d0361f43519f560e011d01509 Mon Sep 17 00:00:00 2001 From: Klaas Boesche Date: Mon, 21 Sep 2015 09:19:27 +0000 Subject: Remove html title handling from Chart, ChartCreators, and HtmlChartVisitor, handle in HtmlCreator -- MOS_MIGRATED_REVID=103528221 --- .../lib/profiler/chart/AggregatingChartCreator.java | 2 +- .../devtools/build/lib/profiler/chart/Chart.java | 18 ------------------ .../build/lib/profiler/chart/DetailedChartCreator.java | 2 +- .../build/lib/profiler/chart/HtmlChartVisitor.java | 1 - .../devtools/build/lib/profiler/chart/HtmlCreator.java | 9 +++++++-- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/AggregatingChartCreator.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/AggregatingChartCreator.java index 3a81934374..85b28a6bcb 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/AggregatingChartCreator.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/AggregatingChartCreator.java @@ -100,7 +100,7 @@ public class AggregatingChartCreator implements ChartCreator { @Override public Chart create() { - Chart chart = new Chart(info.comment); + Chart chart = new Chart(); CommonChartCreator.createCommonChartItems(chart, info); createTypes(chart); diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/Chart.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/Chart.java index b13fb8f1c2..47119a4023 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/Chart.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/Chart.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.profiler.chart; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -29,9 +28,6 @@ public class Chart { /** The type that is returned when an unknown type is looked up. */ public static final ChartBarType UNKNOWN_TYPE = new ChartBarType("Unknown type", Color.RED); - /** The title of the chart. */ - private final String title; - /** The rows of the chart. */ private final Map rows = new HashMap<>(); @@ -50,16 +46,6 @@ public class Chart { /** The maximum stop value of any bar in the chart. */ private long maxStop; - /** - * Creates a chart. - * - * @param title the title of the chart - */ - public Chart(String title) { - Preconditions.checkNotNull(title); - this.title = title; - } - /** * Adds a bar to a row of the chart. If a row with the given id already * exists, the bar is added to the row, otherwise a new row is created and the @@ -206,10 +192,6 @@ public class Chart { return list; } - public String getTitle() { - return title; - } - public int getRowCount() { return rows.size(); } diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/DetailedChartCreator.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/DetailedChartCreator.java index 2689b34cb1..ea53104749 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/DetailedChartCreator.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/DetailedChartCreator.java @@ -41,7 +41,7 @@ public class DetailedChartCreator implements ChartCreator { @Override public Chart create() { - Chart chart = new Chart(info.comment); + Chart chart = new Chart(); CommonChartCreator.createCommonChartItems(chart, info); createTypes(chart); diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java index f9c8993707..c288d8a229 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java @@ -73,7 +73,6 @@ public class HtmlChartVisitor implements ChartVisitor { @Override public void visit(Chart chart) { maxStop = chart.getMaxStop(); - heading(chart.getTitle(), 1); printContentBox(); diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlCreator.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlCreator.java index 4059301a03..899e339d4c 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlCreator.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlCreator.java @@ -34,6 +34,7 @@ public final class HtmlCreator { private final Chart chart; private final HtmlChartVisitor chartVisitor; private final Optional skylarkStats; + private final String title; /** * Pre-formatted statistics for each phase of the profiled build. @@ -42,11 +43,13 @@ public final class HtmlCreator { private HtmlCreator( PrintStream out, + String title, Chart chart, Optional skylarkStats, int htmlPixelsPerSecond, List statistics) { this.out = out; + this.title = title; this.chart = chart; chartVisitor = new HtmlChartVisitor(out, htmlPixelsPerSecond); this.skylarkStats = skylarkStats; @@ -68,7 +71,7 @@ public final class HtmlCreator { private void htmlFrontMatter() { out.println(""); - out.printf("%s", chart.getTitle()); + out.printf("%s", title); chartVisitor.printCss(chart.getSortedTypes()); if (skylarkStats.isPresent()) { @@ -77,6 +80,7 @@ public final class HtmlCreator { out.println(""); out.println(""); + out.printf("

%s

\n", title); } private void htmlBackMatter() { @@ -130,7 +134,8 @@ public final class HtmlCreator { skylarkStats = Optional.absent(); } Chart chart = chartCreator.create(); - new HtmlCreator(out, chart, skylarkStats, htmlPixelsPerSecond, statistics).print(); + new HtmlCreator(out, info.comment, chart, skylarkStats, htmlPixelsPerSecond, statistics) + .print(); } } } -- cgit v1.2.3