Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:jenkins.plugins.livingdoc.chart.ProjectSummaryChart.java

private void customizeChart(JFreeChart chart) {

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    adjustBound(plot.getRangeAxis());//  ww  w  .j a v a 2s  .  c  o  m

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(SUCCESS_SERIES, GREEN_COLOR);
    renderer.setSeriesPaint(FAILURES_SERIES, Color.red);

    LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) renderer;
    lineAndShapeRenderer.setBaseItemLabelGenerator(new NumberLabelGenerator());
    lineAndShapeRenderer.setBaseItemLabelsVisible(true);
    lineAndShapeRenderer.setBaseShapesVisible(true);
    lineAndShapeRenderer.setDrawOutlines(true);
    lineAndShapeRenderer.setUseFillPaint(true);

    renderer.setBaseStroke(new BasicStroke(2.0f));
}

From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java

private static JFreeChart createPieChart() {
    DefaultPieDataset defaultpiedataset = new DefaultPieDataset();
    defaultpiedataset.setValue("Engineering", 43.200000000000003D);
    defaultpiedataset.setValue("Research", 13.199999999999999D);
    defaultpiedataset.setValue("Advertising", 20.899999999999999D);
    PiePlot pieplot = new PiePlot(defaultpiedataset);
    pieplot.setBackgroundPaint(null);/*from   www . jav  a2  s  . c  o m*/
    pieplot.setOutlinePaint(null);
    pieplot.setBaseSectionOutlinePaint(Color.white);
    pieplot.setBaseSectionOutlineStroke(new BasicStroke(2.0F));
    pieplot.setLabelFont(new Font("Dialog", 0, 18));
    pieplot.setMaximumLabelWidth(0.25D);
    JFreeChart jfreechart = new JFreeChart(pieplot);
    jfreechart.setBackgroundPaint(null);
    jfreechart.removeLegend();
    jfreechart.setPadding(RectangleInsets.ZERO_INSETS);
    return jfreechart;
}

From source file:graph_line.java

public void addMarkers(double peak) {
    if (_active > 0) {
        Marker m1 = new ValueMarker(peak);
        m1.setStroke(new BasicStroke((float) .5));
        m1.setPaint(Color.GRAY);//from w ww  . ja v  a2s  . c  o  m
        plot.addDomainMarker(m1);
    }
}

From source file:org.sonar.server.charts.jruby.TrendsChart.java

public void initSerie(Long serieId, String legend, boolean isPercent) {
    TimeSeries series = new TimeSeries(legend);

    int index = seriesById.size();
    seriesById.put(serieId, series);/*  w  ww .  j a v  a2 s . co m*/

    TimeSeriesCollection timeSeriesColl = new TimeSeriesCollection();
    timeSeriesColl.addSeries(series);
    plot.setDataset(index, timeSeriesColl);

    if (isPercent) {
        if (percentAxisId == -1) {
            NumberAxis rangeAxis = new NumberAxis();
            rangeAxis.setNumberFormatOverride(new DecimalFormat("0'%'"));
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setUpperBound(100.0);
            rangeAxis.setLowerBound(0.0);
            plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_LEFT);
            plot.setRangeAxis(index, rangeAxis);
            plot.mapDatasetToRangeAxis(index, index);
            percentAxisId = index;

        } else {
            plot.mapDatasetToRangeAxis(index, percentAxisId);
        }
    } else {
        NumberAxis rangeAxis = new NumberAxis(displayLegend ? legend : null);
        rangeAxis.setAutoRangeIncludesZero(false);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setAutoRangeMinimumSize(2.0);
        plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_RIGHT);
        plot.setRangeAxis(index, rangeAxis);
        plot.mapDatasetToRangeAxis(index, index);
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesPaint(0, COLORS[index % COLORS.length]);
    plot.setRenderer(index, renderer);
}

From source file:org.optaplanner.benchmark.impl.statistic.calculatecount.CalculateCountProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Calculate count per second");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    yAxis.setAutoRangeIncludesZero(false);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries series = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (CalculateCountStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long calculateCountPerSecond = point.getCalculateCountPerSecond();
                series.add(timeMillisSpent, calculateCountPerSecond);
            }/*from   w ww .  j  av a  2s.c  o m*/
        }
        plot.setDataset(seriesIndex, new XYSeriesCollection(series));

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " calculate count statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "CalculateCountStatistic");
}

From source file:org.optaplanner.benchmark.impl.statistic.bestsolutionmutation.BestSolutionMutationProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Best solution mutation count");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    yAxis.setAutoRangeIncludesZero(true);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries series = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            BestSolutionMutationSingleStatistic singleStatistic = (BestSolutionMutationSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (BestSolutionMutationStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long mutationCount = point.getMutationCount();
                series.add(timeMillisSpent, mutationCount);
            }//from  ww  w  .jav  a 2s.  c  o  m
        }
        plot.setDataset(seriesIndex, new XYSeriesCollection(series));

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " best solution mutation statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart,
            problemBenchmarkResult.getName() + "BestSolutionMutationStatistic");
}

From source file:org.encog.workbench.tabs.rbf.RadialBasisFunctionsTab.java

public JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(null, "input (x)", "output (y)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);
    plot.setDomainPannable(true);/* w ww  .j a va 2s .c o  m*/
    plot.setRangePannable(true);
    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setDrawSeriesLineAsPath(true);
    r.setSeriesStroke(0, new BasicStroke(1.5f));
    r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 4.0f }, 0.0f));
    r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f));
    r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 4.0f, 4.0f }, 0.0f));

    return chart;
}

From source file:extern.AsymmetricStatisticalBarRenderer.java

/**
 * Default constructor./*  w  w w.j a  v  a 2 s. co m*/
 */
public AsymmetricStatisticalBarRenderer() {
    super();
    this.errorIndicatorPaint = Color.gray;
    this.errorIndicatorStroke = new BasicStroke(1.0f);
}

From source file:org.jfree.experimental.chart.plot.dial.StandardDialFrame.java

/**
 * Creates a new instance of <code>StandardDialFrame</code> that spans
 * the arc specified./*from w  w w  .j a v  a 2 s. co m*/
 *
 * @param startAngle  the startAngle (in degrees).
 * @param extent  the extent of the arc (in degrees, counter-clockwise).
 */
public StandardDialFrame(double startAngle, double extent) {
    this.backgroundPaint = Color.gray;
    this.foregroundPaint = new Color(100, 100, 150);
    this.stroke = new BasicStroke(2.0f);
    this.innerRadius = 0.25;
    this.outerRadius = 0.75;
    this.startAngle = startAngle;
    this.extent = extent;
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDataset(xData, YDataAnalitic, YDataNumerical), PlotOrientation.VERTICAL, true, true, false);
    System.out.println("vvvv");
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesStroke(1, new BasicStroke(2.0f));
    plot.setRenderer(renderer);//from   w ww . j  a  v a  2  s  .  com
    setContentPane(chartPanel);

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}