Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseShapesVisible.

Prototype

public void setBaseShapesVisible(boolean flag) 

Source Link

Document

Sets the base 'shapes visible' flag and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:grafici.MediciTimeSeriesChart.java

/**
 * Creates a chart.//from   w  w  w  . j a  v  a2s  . c  o m
 * 
 * @param dataset
 *            a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(titolo, // title
            "Date", // x-axis label
            "Occorrenze", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}

From source file:eu.choreos.vv.chart.XYChart.java

private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // initial series
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from  w  w w .j  ava2  s  .  c om

    // set chart background
    chart.setBackgroundPaint(Color.white);

    // set a few custom plot features
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the plot's axes to display integers
    TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setStandardTickUnits(ticks);
    domain.resizeRange(1.1);
    domain.setLowerBound(0.5);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setStandardTickUnits(ticks);
    range.setUpperBound(range.getUpperBound() * 1.1);

    // render shapes and lines
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);
    plot.setRenderer(renderer);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    return chart;
}

From source file:com.ace.capitalflows.ui.frame.chart.NianYdChart.java

/**
 * Creates a chart./*from  w  w w .  j  a v a  2  s. c o m*/
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title
            "NianYd", // x-axis label
            "YiMeiYuan", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));

    return chart;

}

From source file:com.ace.capitalflows.ui.frame.chart.NianJdChart.java

/**
 * Creates a chart.//from w ww  .  j  ava2  s. c  om
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title
            "NianJd", // x-axis label
            "YiMeiYuan", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM"));

    return chart;

}

From source file:org.spf4j.perf.impl.chart.Charts.java

private static JFreeChart createJFreeChart(final String chartName, final String uom,
        final XYDataset timeseriescollection) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(chartName, "Time", uom, timeseriescollection,
            true, true, false);//from w  w w  .  ja va 2  s .c  o m
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setVerticalTickLabels(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator("Tooltip {0}"));
    return jfreechart;
}

From source file:TimeSeriesChartDemo1.java

/**
 * Creates a chart.//from   w  w  w.j av  a  2s  . c  o  m
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset1();
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Annotation Demo 2", "Date", "Price Per Unit",
            xydataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Secondary");
    numberaxis1.setAutoRangeIncludesZero(false);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createDataset2());
    xyplot.mapDatasetToRangeAxis(1, 1);/*from  w  w  w .j a  v  a  2  s  .c  om*/
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Annotation 1 (2.0, 167.3)", 2D,
            167.30000000000001D, -0.78539816339744828D);
    xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    xypointerannotation.setPaint(Color.red);
    xypointerannotation.setArrowPaint(Color.red);
    xylineandshaperenderer.addAnnotation(xypointerannotation);
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(true, true);
    xylineandshaperenderer1.setSeriesPaint(0, Color.black);
    xylineandshaperenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation("Annotation 2 (15.0, 613.2)", 15D,
            613.20000000000005D, 1.5707963267948966D);
    xypointerannotation1.setTextAnchor(TextAnchor.TOP_CENTER);
    xylineandshaperenderer1.addAnnotation(xypointerannotation1);
    xyplot.setRenderer(1, xylineandshaperenderer1);
    LegendTitle legendtitle = new LegendTitle(xylineandshaperenderer);
    LegendTitle legendtitle1 = new LegendTitle(xylineandshaperenderer1);
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(compositetitle);
    return jfreechart;
}

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

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {
    //DomainAxis//from ww  w. j  av a2  s.  c  o m
    DateAxis timeAxis = new DateAxis("");
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);
    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));
    //RangeAxis
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false); // override default
    //        valueAxis.setAutoRange(false);
    //        valueAxis.setDefaultAutoRange(new Range(100, 1150));
    //Renderer
    XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    XYURLGenerator urlGenerator = null;
    //            urlGenerator = new StandardXYURLGenerator();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);
    //Plot
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    //        plot.setRangePannable(true);
    //chart
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.setBackgroundPaint(Color.white);
    return chart;
}

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

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*from   ww w .j av  a2s.com*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}

From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java

private static ChartPanel createChart(String title, String y_axis, XYDataset dataset, boolean createLegend) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "Date", // x-axis label
            y_axis, // y-axis label
            dataset, // data
            createLegend, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//w  ww . j a v  a2 s  .co  m

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    final XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("dd.MM. HH:mm"));

    return new ChartPanel(chart);

}