Example usage for java.awt GradientPaint GradientPaint

List of usage examples for java.awt GradientPaint GradientPaint

Introduction

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

Prototype

public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) 

Source Link

Document

Constructs a simple acyclic GradientPaint object.

Usage

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

/**
 * Creates and returns a sample pie chart.
 *
 * @return a sample pie chart./*from   ww  w.j  a v a2  s.  c  om*/
 */
public JFreeChart createPieChartOne() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("pie.pie1.title");
    final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();
    final PieDataset extracted = DatasetUtilities.createPieDatasetForRow(data, 0);
    final JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.orange));
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setCircular(false);
    // make section 1 explode by 100%...
    plot.setExplodePercent(1, 1.00);
    return chart;

}

From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java

public JFreeChart createWallclockChart(String expId) {
    ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance();
    long eid = Long.parseLong(expId);
    log.info("Building experiment chart for eid = " + eid);
    Experiment exp = edao.findExperiment(eid);

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName();

    boolean hasSuccesses = false;
    boolean hasFails = false;

    for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) {
        int i = 1;
        List<ExecutionRecordImpl> runs = new ArrayList<ExecutionRecordImpl>(batch.getRuns());
        Collections.sort(runs, new RunComparator());
        for (ExecutionRecordImpl exr : runs) {
            //log.info("Found Record... "+exr+" stages: "+exr.getStages());
            if (exr != null && exr.getStages() != null) {
                // Look up the object, so we can get the name.
                DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy());
                String dobName = "Object " + i;
                if (dh != null)
                    dobName = dh.getName();

                ResultsForDigitalObjectBean res = new ResultsForDigitalObjectBean(
                        exr.getDigitalObjectReferenceCopy());
                Double time = null;
                boolean success = false;
                // First, attempt to pull from stage records:
                // FIXME: Note that this record is really at the wrong level.
                /*//  ww w  .ja va 2s .c o  m
                if( exr.getStages().size() == 1 ) {
                for( ExecutionStageRecordImpl exsr : exr.getStages() ) {
                    Double stageTime = exsr.getDoubleMeasurement( TecRegMockup.PROP_SERVICE_TIME );
                    if( stageTime != null ) {
                        time = stageTime;
                        success = exsr.isMarkedAsSuccessful();
                    }
                }
                }
                */
                // Pick up from record duration:
                if (time == null && res.getExecutionDuration() != null) {
                    //convert from milli seconds to seconds
                    time = (double) res.getExecutionDuration() / 1000.0;
                    success = res.getHasExecutionSucceededOK();
                }
                log.info("Found DOB: {" + exr.getDigitalObjectReferenceCopy() + "} {" + dobName + "} w/ time "
                        + time);
                if (res.getExecutionRecord() != null)
                    log.info("Timing: " + res.getExecutionRecord().getStartDate() + " "
                            + res.getExecutionRecord().getEndDate());
                if (time != null) {
                    if (success) {
                        dataset.addValue(time, "Succeeded", dobName);
                        hasSuccesses = true;
                    } else {
                        dataset.addValue(time, "Failed", dobName);
                        hasFails = true;
                    }
                }
            }
            // Increment, for the next run.
            i++;
        }
    }
    int si = dataset.getRowIndex("Succeeded");
    int ri = dataset.getRowIndex("Failed");

    // Create the chart.
    JFreeChart chart = ChartFactory.createStackedBarChart(null, "Digital Object", "Time [s]", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);

    // set the range axis to display integers only...
    //final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter());

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f,
            new Color(0.0f, 0.9f, 0.0f));
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0.9f, 0.0f, 0.0f));
    if (hasSuccesses)
        renderer.setSeriesPaint(si, gp0);
    if (hasFails)
        renderer.setSeriesPaint(ri, gp1);

    // Set the tooltips...
    //renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("xy_chart.jsp","series","section"));
    renderer.setBaseToolTipGenerator(new MeasurementToolTipGenerator());

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0));

    // More settings
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    // Remove the border, as the SVG renderer has problems with the text overflowing.
    chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0);
    // Remove the padding between the axes and the plot:
    chart.getPlot().setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    // Set a gradient fill, fading towards the top:
    final GradientPaint gpb0 = new GradientPaint(0.0f, 0.0f, new Color(245, 245, 245), 0.0f, 0.0f, Color.white);
    chart.getPlot().setBackgroundPaint(gpb0);

    return chart;
}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createLineChart3D(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    LineRenderer3D renderer = new LineRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }//from  www  . j av a 2s  . c o m
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("Line Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    GradientPaint gp = new GradientPaint(0.0f, 0.0f, Color.orange, 0.0f, 0.0f, new Color(0, 64, 64));
    renderer.setWallPaint(gp);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:org.processmining.analysis.performance.sequence.Pattern.java

/**
 * Draws a rectangle of width 20, height length and starting point
 * (startX,startY) in the northwest corner of the rectangle. In case
 * logicSteps is true, the height is 10.
 * /*from  w w  w  .  j  av  a 2s  .c om*/
 * @param startX
 *            double
 * @param startY
 *            double
 * @param length
 *            double
 * @param logicSteps
 *            boolean
 * @param g
 *            Graphics2D
 */
public void drawRectangle(double startX, double startY, double length, boolean logicSteps, Graphics2D g) {
    Rectangle2D r = new Rectangle2D.Double(startX, startY, 20, length);
    if (logicSteps) {
        r = new Rectangle2D.Double(startX, startY, 20, 10);
    }
    Color initialColor = g.getColor();
    Paint initialPaint = g.getPaint();
    GradientPaint towhite = new GradientPaint(((Double) startX).floatValue(), ((Double) startY).floatValue(),
            initialColor, ((Double) startX).floatValue() + 20, ((Double) (startY)).floatValue(), Color.WHITE);
    g.setPaint(towhite);
    g.fill(r);
    g.setPaint(initialPaint);
    g.setColor(Color.BLACK);
    g.draw(r);
    g.setColor(initialColor);
}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java

private static JFreeChart createMultiplePieChart3D(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createMultiplePieChart3D("MultiplePie Chart 3D Demo 1", // chart title
            dataset, // data
            TableOrder.BY_COLUMN, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w ww . j  a  v a2s  .co m*/

    chart.setBackgroundPaint(Color.white);

    MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    JFreeChart pieChart = plot.getPieChart();
    PiePlot piePlot = (PiePlot) pieChart.getPlot();

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    piePlot.setSectionPaint("First", gp0);
    piePlot.setSectionPaint("Second", gp1);
    piePlot.setSectionPaint("Third", gp2);

    return chart;

}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createAreaChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);

    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    AreaRenderer renderer = new AreaRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }// w w w.  ja  va  2s .  c o  m
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("Area Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    renderer.setEndType(AreaRendererEndType.LEVEL);

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

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

/**
 * Creates and returns a sample XY plot.
 *
 * @return a sample XY plot./*from  w  w w  .  j  a  v  a  2 s .  com*/
 */
public JFreeChart createXYPlot() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("xyplot.sample1.title");
    final String domain = this.resources.getString("xyplot.sample1.domain");
    final String range = this.resources.getString("xyplot.sample1.range");
    final XYDataset data = DemoDatasetFactory.createSampleXYDataset();
    final JFreeChart chart = ChartFactory.createXYLineChart(title, domain, range, data,
            PlotOrientation.VERTICAL, true, true, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));
    return chart;

}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createStackedAreaChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    StackedAreaRenderer renderer = new StackedAreaRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }/*  ww  w. j av a  2  s  .  c  o  m*/
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("StackedArea Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //        renderer.setRenderAsPercentages(true);

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBarGroup.java

/**
 * Inherited by IChart./*from  ww  w. j  a  v a 2s.c  om*/
 * 
 * @param chartTitle the chart title
 * @param dataset the dataset
 * 
 * @return the j free chart
 */

public JFreeChart createChart(DatasetMap datasets) {

    logger.debug("IN");
    CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1");

    logger.debug("Get plot orientaton");
    PlotOrientation plotOrientation = PlotOrientation.VERTICAL;
    if (horizontalView) {
        plotOrientation = PlotOrientation.HORIZONTAL;
    }

    JFreeChart chart = ChartFactory.createStackedBarChart(name, // chart title
            categoryLabel, // domain axis label
            valueLabel, // range axis label
            dataset, // data
            plotOrientation, // the plot orientation
            legend, // legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(color);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);

    GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
    KeyToGroupMap map = new KeyToGroupMap("G1");
    int numElForGroup = 0;
    for (int idx = 0; idx < numGroups.intValue(); idx++) {
        for (int j = 0; j < numSerieForGroup.intValue(); j++) {
            try {
                String tmpSubCat = (String) subCategoryNames.get(j + idx * numSerieForGroup.intValue());
                map.mapKeyToGroup(tmpSubCat, "G" + (idx + 1));

            } catch (Exception e) {
                logger.error("out of range error in inserting in stacked bar group: continue anayway", e);
            }
        }
    }

    renderer.setSeriesToGroupMap(map);
    renderer.setItemMargin(0.0);
    renderer.setDrawBarOutline(false);
    renderer.setBaseItemLabelsVisible(true);
    if (percentageValue)
        renderer.setBaseItemLabelGenerator(
                new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%")));
    else
        renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
    renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());

    if (maxBarWidth != null) {
        renderer.setMaximumBarWidth(maxBarWidth.doubleValue());
    }

    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;

    /*
    MyCategoryUrlGenerator mycatUrl=new MyCategoryUrlGenerator(rootUrl);
    mycatUrl.setDocument_composition(document_composition);
    mycatUrl.setCategoryUrlLabel(categoryUrlName);
    mycatUrl.setSerieUrlLabel(serieUrlname);
            
    renderer.setItemURLGenerator(mycatUrl);
     */

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(color);

    NumberFormat nf = NumberFormat.getNumberInstance(locale);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis.setNumberFormatOverride(nf);
    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    if (rangeAxisLocation != null) {
        if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
        } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
        }
    }

    int seriesN = dataset.getRowCount();
    int numSerieColored = 0;

    if (orderColorVector != null && orderColorVector.size() > 0) {
        logger.debug("color serie by SERIES_ORDER_COLORS template specification");
        for (int i = 0; i < seriesN; i++) {
            if (orderColorVector.get(i) != null) {
                Color color = orderColorVector.get(i);
                renderer.setSeriesPaint(i, color);
            }
        }
    } else if (colorMap != null) {
        while (numSerieColored < seriesN) {
            for (int i = 1; i <= colorMap.size(); i++) {
                Color color = (Color) colorMap.get("SER" + i);
                Color gradient = new Color(Integer.decode("#FFFFFF").intValue());
                if (gradientMap != null)
                    gradient = (Color) gradientMap.get("SER" + i);

                if (color != null) {
                    Paint p = new GradientPaint(0.0f, 0.0f, color, 0.0f, 0.0f, gradient);

                    //renderer.setSeriesPaint(numSerieColored, color);
                    renderer.setSeriesPaint(numSerieColored, p);
                }
                numSerieColored++;
            }
        }
    }
    renderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

    MyStandardCategoryItemLabelGenerator generator = null;
    if (additionalLabels) {
        generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance());

        double orient = (-Math.PI / 2.0);
        if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
            orient = 0.0;
        }
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());

        renderer.setBaseItemLabelGenerator(generator);
        renderer.setBaseItemLabelsVisible(true);
        //vertical labels          
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        renderer.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));

        //horizontal labels
        /*
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
           ItemLabelAnchor.CENTER, TextAnchor.CENTER));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
           ItemLabelAnchor.CENTER, TextAnchor.CENTER));
         */

    }

    SubCategoryAxis domainAxis = new SubCategoryAxis(categoryLabel + " / " + subCategoryLabel);
    String subCatLabel = "";
    for (int j = 1; j <= numGroups.intValue(); j++) {
        if (subCatLabelsMap != null)
            subCatLabel = (String) subCatLabelsMap.get("CAT" + j);
        else
            subCatLabel = subCategoryLabel;

        domainAxis.addSubCategory(subCatLabel);
        domainAxis
                .setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
        domainAxis.setLabelPaint(styleYaxesLabels.getColor());
        domainAxis.setTickLabelFont(
                new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
        domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());
    }
    plot.setDomainAxis(domainAxis);
    plot.setRenderer(renderer);

    /*
    domainAxis.setCategoryLabelPositions(
    CategoryLabelPositions.createUpRotationLabelPositions(
          Math.PI / 6.0));
     */
    if (legend == true)
        drawLegend(chart);
    logger.debug("OUT");
    return chart;

}

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

/**
 * Creates and returns a sample time series chart.
 *
 * @return a sample time series chart./*from w ww .  jav  a 2 s.  com*/
 */
public JFreeChart createTimeSeries1Chart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("timeseries.sample1.title");
    final String subtitle = this.resources.getString("timeseries.sample1.subtitle");
    final String domain = this.resources.getString("timeseries.sample1.domain");
    final String range = this.resources.getString("timeseries.sample1.range");
    final String copyrightStr = this.resources.getString("timeseries.sample1.copyright");
    final XYDataset data = DemoDatasetFactory.createTimeSeriesCollection3();
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, true, true, false);

    // then customise it a little...
    final TextTitle title2 = new TextTitle(subtitle, new Font("SansSerif", Font.PLAIN, 12));
    //      title2.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0));
    chart.addSubtitle(title2);

    final TextTitle copyright = new TextTitle(copyrightStr, new Font("SansSerif", Font.PLAIN, 9));
    copyright.setPosition(RectangleEdge.BOTTOM);
    copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(copyright);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    final XYPlot plot = chart.getXYPlot();
    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    return chart;

}