Search in sources :

Example 1 with DataSetBuilder

use of hudson.util.DataSetBuilder in project evosuite by EvoSuite.

the class TimePlot method doStats.

private CategoryDataset doStats() {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> timeDataSetBuilder = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
    for (Run<?, ?> build : this.project.getProject().getBuilds()) {
        final BuildAction build_action = build.getAction(BuildAction.class);
        if (build_action == null) {
            // no build action is associated with this build, so skip it
            continue;
        }
        int timeBudget = build_action.getProjectAction().getTimeBudget();
        timeDataSetBuilder.add(timeBudget, "Total Time Budget", new ChartUtil.NumberOnlyBuildLabel(build));
        int totalEffort = build_action.getProjectAction().getTotalEffort();
        timeDataSetBuilder.add(totalEffort, "Time Budget Used", new ChartUtil.NumberOnlyBuildLabel(build));
    }
    return timeDataSetBuilder.build();
}
Also used : ChartUtil(hudson.util.ChartUtil) DataSetBuilder(hudson.util.DataSetBuilder) BuildAction(org.evosuite.jenkins.actions.BuildAction)

Example 2 with DataSetBuilder

use of hudson.util.DataSetBuilder in project hudson-2.x by hudson.

the class Job method getBuildTimeGraph.

public Graph getBuildTimeGraph() {
    return new Graph(getLastBuild().getTimestamp(), 500, 400) {

        @Override
        protected JFreeChart createGraph() {
            class ChartLabel implements Comparable<ChartLabel> {

                final Run run;

                public ChartLabel(Run r) {
                    this.run = r;
                }

                public int compareTo(ChartLabel that) {
                    return Run.ORDER_BY_DATE.compare(that.run, run);
                }

                @Override
                public boolean equals(Object o) {
                    // on (c instanceof ChartLabel)
                    if (o == null || !ChartLabel.class.isAssignableFrom(o.getClass())) {
                        return false;
                    }
                    ChartLabel that = (ChartLabel) o;
                    return run == that.run;
                }

                public Color getColor() {
                    // TODO: consider gradation. See
                    // http://www.javadrive.jp/java2d/shape/index9.html
                    Result r = run.getResult();
                    if (r == Result.FAILURE)
                        return ColorPalette.RED;
                    else if (r == Result.UNSTABLE)
                        return ColorPalette.YELLOW;
                    else if (r == Result.ABORTED || r == Result.NOT_BUILT)
                        return ColorPalette.GREY;
                    else
                        return ColorPalette.BLUE;
                }

                @Override
                public int hashCode() {
                    return run.hashCode();
                }

                @Override
                public String toString() {
                    String l = run.getDisplayName();
                    if (run instanceof Build) {
                        String s = ((Build) run).getBuiltOnStr();
                        if (s != null)
                            l += ' ' + s;
                    }
                    return l;
                }
            }
            DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<String, ChartLabel>();
            for (Run r : getBuilds()) {
                if (r.isBuilding())
                    continue;
                data.add(((double) r.getDuration()) / (1000 * 60), "min", new ChartLabel(r));
            }
            final CategoryDataset dataset = data.build();
            final JFreeChart chart = // chart
            ChartFactory.createStackedAreaChart(// chart
            null, // unused
            null, // range axis label
            Messages.Job_minutes(), // data
            dataset, // orientation
            PlotOrientation.VERTICAL, // include legend
            false, // tooltips
            true, // urls
            false);
            chart.setBackgroundPaint(Color.white);
            final CategoryPlot plot = chart.getCategoryPlot();
            // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(0.8f);
            // plot.setDomainGridlinesVisible(true);
            // plot.setDomainGridlinePaint(Color.white);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);
            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(0.0);
            domainAxis.setUpperMargin(0.0);
            domainAxis.setCategoryMargin(0.0);
            final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            ChartUtil.adjustChebyshev(dataset, rangeAxis);
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            StackedAreaRenderer ar = new StackedAreaRenderer2() {

                @Override
                public Paint getItemPaint(int row, int column) {
                    ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
                    return key.getColor();
                }

                @Override
                public String generateURL(CategoryDataset dataset, int row, int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return String.valueOf(label.run.number);
                }

                @Override
                public String generateToolTip(CategoryDataset dataset, int row, int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return label.run.getDisplayName() + " : " + label.run.getDurationString();
                }
            };
            plot.setRenderer(ar);
            // crop extra space around the graph
            plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
            return chart;
        }
    };
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) DataSetBuilder(hudson.util.DataSetBuilder) StackedAreaRenderer2(hudson.util.StackedAreaRenderer2) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) StackedAreaRenderer(org.jfree.chart.renderer.category.StackedAreaRenderer) ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) Graph(hudson.util.Graph) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) CategoryDataset(org.jfree.data.category.CategoryDataset) RectangleInsets(org.jfree.ui.RectangleInsets) JSONObject(net.sf.json.JSONObject)

Example 3 with DataSetBuilder

use of hudson.util.DataSetBuilder in project memory-map-plugin by Praqma.

the class MemoryMapBuildAction method doDrawMemoryMapUsageGraph.

public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSet = new DataSetBuilder<>();
    String members = req.getParameter("categories");
    String graphTitle = req.getParameter("title");
    String uniqueDataSet = req.getParameter("dataset");
    int w = Integer.parseInt(req.getParameter("width"));
    int h = Integer.parseInt(req.getParameter("height"));
    List<String> memberList = Arrays.asList(members.split(","));
    HashMap<String, ValueMarker> markers = new HashMap<>();
    String scale = getRecorder().getScale();
    double max = buildDataSet(memberList, uniqueDataSet, dataSet, markers);
    filterMarkers(markers);
    String s = "";
    if (scale.equalsIgnoreCase("kilo")) {
        s = "k";
    } else if (scale.equalsIgnoreCase("mega")) {
        s = "M";
    } else if (scale.equalsIgnoreCase("giga")) {
        s = "G";
    }
    String byteLegend = s + "Bytes";
    String wordLegend = s + "Words";
    String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend;
    JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataSet.build(), markers.values());
    chart.setBackgroundPaint(Color.WHITE);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    ChartUtil.generateGraph(req, rsp, chart, w, h);
}
Also used : DataSetBuilder(hudson.util.DataSetBuilder) ValueMarker(org.jfree.chart.plot.ValueMarker) JFreeChart(org.jfree.chart.JFreeChart)

Example 4 with DataSetBuilder

use of hudson.util.DataSetBuilder in project violations-plugin by jenkinsci.

the class AbstractViolationsBuildAction method doGraph.

/**
 * This corresponds to the url ./graph.
 *
 * @param req
 *            the request parameters.
 * @param rsp
 *            the response.
 * @throws IOException
 *             if there is an error writing the graph
 */
public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
    String type = req.getParameter("type");
    if (ChartUtil.awtProblemCause != null) {
        // not available. send out error message
        rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
        return;
    }
    getBuild().getTimestamp();
    if (!StringUtil.isBlank(type)) {
        ChartUtil.generateGraph(req, rsp, new SeverityTypeDataSet(getReport(), type).createChart(), X_SIZE, Y_SIZE);
        return;
    }
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
    for (ViolationsReport r : ViolationsReport.iteration(getBuild())) {
        for (String ty : r.getViolations().keySet()) {
            dsb.add(roundUp(r.getViolations().get(ty)), ty, new ChartUtil.NumberOnlyBuildLabel((Run) r.getBuild()));
        }
    }
    ChartUtil.generateGraph(req, rsp, createChart(dsb.build()), X_SIZE, Y_SIZE);
}
Also used : ChartUtil(hudson.util.ChartUtil) DataSetBuilder(hudson.util.DataSetBuilder) ViolationsReport(hudson.plugins.violations.ViolationsReport) Run(hudson.model.Run) SeverityTypeDataSet(hudson.plugins.violations.graph.SeverityTypeDataSet)

Example 5 with DataSetBuilder

use of hudson.util.DataSetBuilder in project hudson-2.x by hudson.

the class History method getCountGraph.

/**
 * Graph of # of tests over time.
 */
public Graph getCountGraph() {
    return new GraphImpl("") {

        protected DataSetBuilder<String, ChartLabel> createDataSet() {
            DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<String, ChartLabel>();
            List<TestResult> list;
            try {
                list = getList(Integer.parseInt(Stapler.getCurrentRequest().getParameter("start")), Integer.parseInt(Stapler.getCurrentRequest().getParameter("end")));
            } catch (NumberFormatException e) {
                list = getList();
            }
            for (TestResult o : list) {
                data.add(o.getPassCount(), "2Passed", new ChartLabel(o));
                data.add(o.getFailCount(), "1Failed", new ChartLabel(o));
                data.add(o.getSkipCount(), "0Skipped", new ChartLabel(o));
            }
            return data;
        }
    };
}
Also used : DataSetBuilder(hudson.util.DataSetBuilder) TestResult(hudson.tasks.test.TestResult)

Aggregations

DataSetBuilder (hudson.util.DataSetBuilder)8 ChartUtil (hudson.util.ChartUtil)3 Run (hudson.model.Run)2 ViolationsReport (hudson.plugins.violations.ViolationsReport)2 TestResult (hudson.tasks.test.TestResult)2 BuildAction (org.evosuite.jenkins.actions.BuildAction)2 JFreeChart (org.jfree.chart.JFreeChart)2 TypeSummary (hudson.plugins.violations.TypeSummary)1 SeverityTypeDataSet (hudson.plugins.violations.graph.SeverityTypeDataSet)1 NumberOnlyBuildLabel (hudson.util.ChartUtil.NumberOnlyBuildLabel)1 Graph (hudson.util.Graph)1 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)1 StackedAreaRenderer2 (hudson.util.StackedAreaRenderer2)1 Color (java.awt.Color)1 JSONObject (net.sf.json.JSONObject)1 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 ValueMarker (org.jfree.chart.plot.ValueMarker)1 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)1