Example usage for java.awt BasicStroke CAP_ROUND

List of usage examples for java.awt BasicStroke CAP_ROUND

Introduction

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

Prototype

int CAP_ROUND

To view the source code for java.awt BasicStroke CAP_ROUND.

Click Source Link

Document

Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.

Usage

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

public void addLabel(Date date, String label, boolean lower) throws ParseException {
    Day d = new Day(date);
    double millis = d.getFirstMillisecond();
    Marker marker = new ValueMarker(millis);
    marker.setLabel(label);/*from w  ww.ja  v  a 2  s. c om*/
    marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    Color c = new Color(17, 40, 95);
    marker.setLabelPaint(c);
    marker.setPaint(c);
    marker.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 3.0f,
            new float[] { 5f, 5f, 5f, 5f }, 2.0f));
    if (lower) {
        marker.setLabelOffset(new RectangleInsets(18, 0, 0, 5));
    }
    plot.addDomainMarker(marker);
}

From source file:hudson.plugins.karma.portlet.chart.KarmaBuilderTrendChart.java

/**
 * Creates a graph for Karma Coverage results.
 *
 * @param summaries//ww  w .jav a  2 s  .c om
 *          HashMap(key = run date and value = Instrumentation tests
 *          results)
 * @param widthParam
 *          the chart width
 * @param heightParam
 *          the chart height
 * @return Graph (JFreeChart)
 */
private static Graph createTrendChart(final Map<LocalDate, KarmaCoverageResultSummary> summaries,
        int widthParam, int heightParam) {

    return new Graph(-1, widthParam, heightParam) {

        @Override
        protected JFreeChart createGraph() {

            // Show empty chart
            if (summaries == null) {
                JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL,
                        Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false);

                return chart;
            }

            int lineNumber = 0;

            JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL,
                    Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false,
                    false);

            chart.setBackgroundPaint(Color.white);

            CategoryPlot plot = chart.getCategoryPlot();

            // Line thickness
            CategoryItemRenderer renderer = plot.getRenderer();
            BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND,
                    BasicStroke.JOIN_ROUND);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber, stroke);

            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);

            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN);

            NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setUpperBound(Constants.UPPER_BOUND);
            rangeAxis.setLowerBound(Constants.LOWER_BOUND);

            return chart;

        }
    };
}

From source file:hudson.plugins.jacoco.portlet.chart.JacocoBuilderTrendChart.java

/**
 * Creates a graph for JaCoCo Coverage results.
 *
 * @param summaries/* w  ww. j  a va 2  s  .com*/
 *          HashMap(key = run date and value = Instrumentation tests
 *          results)
 * @param widthParam
 *          the chart width
 * @param heightParam
 *          the chart height
 * @return Graph (JFreeChart)
 */
private static Graph createTrendChart(final Map<LocalDate, JacocoCoverageResultSummary> summaries,
        int widthParam, int heightParam) {

    return new Graph(-1, widthParam, heightParam) {

        @Override
        protected JFreeChart createGraph() {

            // Show empty chart
            if (summaries == null) {
                JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL,
                        Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false);

                return chart;
            }

            int lineNumber = 0;

            JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL,
                    Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false,
                    false);

            chart.setBackgroundPaint(Color.white);

            CategoryPlot plot = chart.getCategoryPlot();

            // Line thickness
            CategoryItemRenderer renderer = plot.getRenderer();
            BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND,
                    BasicStroke.JOIN_ROUND);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber, stroke);

            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);

            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN);

            NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            //rangeAxis.setUpperBound(Constants.UPPER_BOUND);
            rangeAxis.setLowerBound(Constants.LOWER_BOUND);

            return chart;

        }
    };
}

From source file:org.optaplanner.benchmark.impl.statistic.movecountperstep.MoveCountPerStepProblemStatistic.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("Accepted/selected moves per step");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    DrawingSupplier drawingSupplier = new DefaultDrawingSupplier();
    plot.setOrientation(PlotOrientation.VERTICAL);

    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries acceptedSeries = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted");
        XYSeries selectedSeries = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " selected");
        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
        if (singleBenchmarkResult.isSuccess()) {
            MoveCountPerStepSingleStatistic singleStatistic = (MoveCountPerStepSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (MoveCountPerStepStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long acceptedMoveCount = point.getMoveCountPerStepMeasurement().getAcceptedMoveCount();
                long selectedMoveCount = point.getMoveCountPerStepMeasurement().getSelectedMoveCount();
                acceptedSeries.add(timeMillisSpent, acceptedMoveCount);
                selectedSeries.add(timeMillisSpent, selectedMoveCount);
            }/*from ww w . j  a va  2  s  .com*/
        }
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        seriesCollection.addSeries(acceptedSeries);
        seriesCollection.addSeries(selectedSeries);
        plot.setDataset(seriesIndex, seriesCollection);

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
            // Dashed line for selected move count
            renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] { 2.0f, 6.0f }, 0.0f));
        } else {
            // Dashed line for selected move count
            renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] { 2.0f, 6.0f }, 0.0f));
        }
        // Render both lines in the same color
        Paint linePaint = drawingSupplier.getNextPaint();
        renderer.setSeriesPaint(0, linePaint);
        renderer.setSeriesPaint(1, linePaint);
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }

    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " move count per step statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MoveCountPerStepStatistic");
}

From source file:hudson.plugins.codecover.portlet.chart.CodeCoverBuilderTrendChart.java

/**
 * Creates a graph for CodeCover Coverage results.
 *
 * @param summaries/* w  w  w. j  a v a 2s.c om*/
 *          HashMap(key = run date and value = Instrumentation tests
 *          results)
 * @param widthParam
 *          the chart width
 * @param heightParam
 *          the chart height
 * @return Graph (JFreeChart)
 */
private static Graph createTrendChart(final Map<LocalDate, CodeCoverCoverageResultSummary> summaries,
        int widthParam, int heightParam) {

    return new Graph(-1, widthParam, heightParam) {

        @Override
        protected JFreeChart createGraph() {

            // Show empty chart
            if (summaries == null) {
                JFreeChart chart = ChartFactory.createStackedAreaChart(null, Constants.AXIS_LABEL,
                        Constants.AXIS_LABEL_VALUE, null, PlotOrientation.VERTICAL, true, false, false);

                return chart;
            }

            int lineNumber = 0;

            JFreeChart chart = ChartFactory.createLineChart("", Constants.AXIS_LABEL,
                    Constants.AXIS_LABEL_VALUE, buildDataSet(summaries), PlotOrientation.VERTICAL, true, false,
                    false);

            chart.setBackgroundPaint(Color.white);

            CategoryPlot plot = chart.getCategoryPlot();

            // Line thickness
            CategoryItemRenderer renderer = plot.getRenderer();
            BasicStroke stroke = new BasicStroke(Constants.LINE_THICKNESS, BasicStroke.CAP_ROUND,
                    BasicStroke.JOIN_ROUND);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber++, stroke);
            renderer.setSeriesStroke(lineNumber, stroke);

            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(Constants.FOREGROUND_ALPHA);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);

            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setUpperMargin(Constants.DEFAULT_MARGIN);
            domainAxis.setCategoryMargin(Constants.DEFAULT_MARGIN);

            NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setUpperBound(Constants.UPPER_BOUND);
            rangeAxis.setLowerBound(Constants.LOWER_BOUND);

            return chart;

        }
    };
}

From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java

public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) {
    CoordDataset nData = new CoordDataset();

    for (int i = 0; i < vehicles.size(); i++) {
        Schedule<?> schedule = vehicles.get(i).getSchedule();
        Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule);
        nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED));
        nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED));
        nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED));
    }//  ww w .j av a 2  s  . co m

    JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL,
            false, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesItemLabelsVisible(0, true);

    renderer.setBaseItemLabelGenerator(new LabelGenerator());

    Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
    Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;

    for (int i = 0; i < vehicles.size(); i++) {
        int s = 3 * i;

        renderer.setSeriesItemLabelsVisible(s + 1, true);
        renderer.setSeriesItemLabelsVisible(s + 2, true);
        renderer.setSeriesItemLabelsVisible(s + 3, true);

        renderer.setSeriesShapesVisible(s + 1, true);
        renderer.setSeriesShapesVisible(s + 2, true);
        renderer.setSeriesShapesVisible(s + 3, true);

        renderer.setSeriesLinesVisible(s + 1, true);
        renderer.setSeriesLinesVisible(s + 2, true);
        renderer.setSeriesLinesVisible(s + 3, true);

        renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]);

        renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]);

        renderer.setSeriesStroke(s + 2, new BasicStroke(3));
        renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1,
                new float[] { 5f, 5f }, 0));
    }

    return chart;
}

From source file:org.jfree.fx.demo.FXGraphics2DDemo1.java

/**
 * Creates a chart./*from w ww  . ja  v a2 s .co  m*/
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", // title
            null, // x-axis label
            "US cents/lb", // y-axis label
            dataset);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
            new Font(fontName, Font.PLAIN, 14)));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);
    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setDrawSeriesLineAsPath(true);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);
        renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesPaint(1, new Color(24, 123, 58));
        renderer.setSeriesPaint(2, new Color(149, 201, 136));
        renderer.setSeriesPaint(3, new Color(1, 62, 29));
        renderer.setSeriesPaint(4, new Color(81, 176, 86));
        renderer.setSeriesPaint(5, new Color(0, 55, 122));
        renderer.setSeriesPaint(6, new Color(0, 92, 165));
    }

    return chart;

}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list/* w w w . j ava  2s.c  o  m*/
 * @param title
 * @param xAxisTitle
 * @param yAxisTitle
 * @param isVertical
 * @param width
 * @param height
 */
public JFreeChart createLineChart(final List<Object> list, final String title, final String xAxisTitle,
        final String yAxisTitle, final boolean isVertical, final int width, final int height) {
    DefaultCategoryDataset catDataSet = new DefaultCategoryDataset();
    for (int i = 0; i < list.size(); i++) {
        Object xVal = list.get(i++);
        Object yVal = list.get(i);

        double xv = getDbl(xVal);
        numMin = Math.min(numMin, xv);
        numMax = Math.max(numMax, xv);

        catDataSet.addValue(getDbl(yVal), "X", xVal.toString());
    }

    /*XYDataset dataset = createXYDataSet(list);
    JFreeChart chart = ChartFactory.createXYLineChart( 
        title,      // chart title 
        xAxisTitle, // domain axis label 
        yAxisTitle, // range axis label 
        dataset,    // data 
        isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, 
        false,       // include legend 
        true,       // tooltips? 
        false       // URLs? 
    ); 
            
    XYPlot xyplot = chart.getXYPlot();
    NumberAxis numberAxis = (NumberAxis) xyplot.getDomainAxis();
    numberAxis.setRange(numMin, numMax);
            
    //ValueAxis axis = xyplot.getDomainAxis();
    //axis = xyplot.getRangeAxis();
    //((NumberAxis) axis).setTickUnit(new NumberTickUnit(1));
    //axis.setRange(1870,2010);*/

    /*
    JFreeChart jfreechart = ChartFactory.createLineChart3D(
        title, 
        xAxisTitle, 
        yAxisTitle, 
        catDataSet, 
        PlotOrientation.VERTICAL, 
        false, 
        true, 
        false);
    jfreechart.setBackgroundPaint(new Color(187, 187, 221));
    CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
            
    NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            
    CategoryItemRenderer renderer = categoryplot.getRenderer(); 
    renderer.setSeriesPaint(0, new Color(95, 158, 160)); 
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); 
    */
    JFreeChart jfreechart = ChartFactory.createLineChart(title, xAxisTitle, yAxisTitle, catDataSet,
            PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangeGridlinePaint(Color.DARK_GRAY);
    categoryplot.setBackgroundPaint(null);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryItemRenderer renderer = categoryplot.getRenderer();
    renderer.setSeriesPaint(0, new Color(95, 158, 160));
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);

    BasicStroke lineStroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    renderer.setBaseStroke(lineStroke);
    renderer.setBaseOutlineStroke(lineStroke);
    renderer.setSeriesStroke(0, lineStroke);

    //renderer.setOutlineStroke(lineStroke);
    //renderer.setStroke(lineStroke);

    return jfreechart;
}

From source file:net.imglib2.script.analysis.Histogram.java

static private final void setBackgroundDefault(final JFreeChart chart) {
    BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 1.0f }, 0.0f);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlineStroke(gridStroke);
    plot.setDomainGridlineStroke(gridStroke);
    plot.setBackgroundPaint(new Color(235, 235, 235));
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setOutlineVisible(false);//from   ww w .j a  v a 2  s .c o m
    plot.getDomainAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getDomainAxis().setLabelPaint(Color.gray);
    plot.getRangeAxis().setLabelPaint(Color.gray);
    plot.getDomainAxis().setTickLabelPaint(Color.gray);
    plot.getRangeAxis().setTickLabelPaint(Color.gray);
    chart.getTitle().setPaint(Color.gray);
}

From source file:smarthouse_server.LineChart.java

/**
 * Creates a sample chart./*from   www. j a  va 2 s.  c o m*/
 * 
 * @param dataset  a dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    chart = ChartFactory.createLineChart("Room Monitor #", // chart title
            "Time", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    //        StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    //    legend.setShapeScaleX(1.5);
    //  legend.setShapeScaleY(1.5);
    //legend.setDisplaySeriesLines(true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.getDomainAxis().setVisible(false);
    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    //        renderer.setDrawShapes(true);

    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 10.0f, 6.0f }, 0.0f));
    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));
    /*        renderer.setSeriesStroke(
    2, new BasicStroke(
        2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
        1.0f, new float[] {2.0f, 6.0f}, 0.0f
    )
            );*/
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
}