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:edu.ucla.stat.SOCR.chart.demo.LineChartDemo3.java

/**
 * Creates a chart./*from w  w  w . j  a  va 2  s.c  om*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart based on the supplied dataset.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

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

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    setXSummary(dataset);
    return chart;
}

From source file:de.atomfrede.tools.evalutation.tools.plot.custom.CustomSimplePlot.java

@Override
protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) {
    XYDatasetWrapper mainDataset = datasetWrappers[0];

    JFreeChart chart = ChartFactory.createXYLineChart(mainDataset.getSeriesName(), "Index",
            mainDataset.getSeriesName(), mainDataset.getDataset(), PlotOrientation.VERTICAL, true, false,
            false);//from www.  ja  v  a2 s.c om

    XYPlot plot = (XYPlot) chart.getPlot();
    // all adjustments for first/main dataset
    plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum());
    plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum());
    // some additional "design" stuff for the plot
    plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor());
    plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke()));

    for (int i = 1; i < datasetWrappers.length; i++) {
        XYDatasetWrapper wrapper = datasetWrappers[i];
        plot.setDataset(i, wrapper.getDataset());
        chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName());

        NumberAxis axis = new NumberAxis(wrapper.getSeriesName());
        plot.setRangeAxis(i, axis);
        plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);

        plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0);
        plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0);
        // map the second dataset to the second axis
        plot.mapDatasetToRangeAxis(i, i);

        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setBaseShapesVisible(false);
        renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke()));
        plot.setRenderer(i, renderer);
        plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor());
    }
    // change the background and gridline colors
    plot.setBackgroundPaint(Color.white);
    plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    return chart;
}

From source file:diplomawork.model.ViewForDiagram.java

/**
 * Creates a chart.//from w ww. j a v  a 2s. c  o  m
 *
 * @param dataset a dataset.
 *
 * @return A chart.
 */
private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("EUR/USD", // 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);
    plot.setOutlinePaint(null);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setSeriesPaint(0, Color.BLUE);
    }
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("dd HH:mm:ss"));
    return chart;
}

From source file:binky.reportrunner.ui.actions.admin.GetAuditChartAction.java

@Override
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String execute() throws Exception {

    // do some stuff and get a chart going
    // DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    TimeSeriesCollection dataSet = new TimeSeriesCollection();
    List<RunnerHistoryEvent> events = auditService.getSuccessEvents(module, new Date(fromDate),
            new Date(toDate));
    Map<String, TimeSeries> serieses = new HashMap<String, TimeSeries>();
    for (RunnerHistoryEvent e : events) {
        TimeSeries s = serieses.get(e.getMethod());
        if (s == null) {
            s = new TimeSeries(e.getMethod());
            serieses.put(e.getMethod(), s);
        }/* ww  w .  j a  va  2 s.  c o m*/
        s.addOrUpdate(new Millisecond(e.getTimeStamp()), e.getRunTime());
    }
    for (TimeSeries s : serieses.values()) {
        dataSet.addSeries(s);
    }
    chart = ChartFactory.createTimeSeriesChart(module, "", "run time (ms)", dataSet, true, false, false);

    // .createLineChart("","","Run Time (ms)",dataSet,PlotOrientation.VERTICAL,
    // true,false,false);
    XYPlot linePlot = (XYPlot) chart.getPlot();
    linePlot.setDomainGridlinesVisible(true);
    linePlot.setRangeGridlinesVisible(true);
    linePlot.setRangeGridlinePaint(Color.black);
    linePlot.setDomainGridlinePaint(Color.black);
    TextTitle subTitle = new TextTitle("Successful Executions");
    subTitle.setFont(new Font("Arial", Font.ITALIC, 10));
    chart.addSubtitle(subTitle);
    chart.getTitle().setFont(new Font("Arial", Font.BOLD, 12));

    DateAxis axis = (DateAxis) linePlot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss dd-MM-yyyy"));

    XYItemRenderer r = linePlot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    return SUCCESS;
}

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 . ja va2  s . c om

    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.cerberus.refactor.LineChart.java

public BufferedImage bi(TimeSeriesCollection timeseriescollection, String xname, String name, int count) {

    BufferedImage bi = null;//w w  w .  j  ava 2 s  .  c om
    boolean fc = false;
    XYDataset xydataset = timeseriescollection;

    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(name, xname, name, xydataset, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(false);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        Shape point = ShapeUtilities.createDiagonalCross(1, 1);
        String[] seriesColors = { "#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" };
        String[] seriesColors2 = { "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" };
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
        for (int a = 0; a < count; a++) {
            xylineandshaperenderer.setSeriesShape(a, point);
            xyitemrenderer.setSeriesStroke(a, new BasicStroke(1.0F));
            //TODO check this - fc is always false
            if (fc) {
                xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors[count - a - 1]));
            } else {
                xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors2[count - a - 1]));
            }
        }

    }
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));

    bi = jfreechart.createBufferedImage(500, 270);

    return bi;

}

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

private static JFreeChart createTimeSeriesChart2(XYDataset dataset) {

    DateAxis timeAxis = new DateAxis(xAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);/*from w  ww .  jav a  2  s  .  c  om*/
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    JFreeChart chart = new JFreeChart("TimeSeries Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    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);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);

    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}

From source file:org.ujmp.jfreechart.MatrixChartPanel.java

public synchronized void redraw() {
    Dataset dataset = null;/* w ww.  ja  v a  2  s .  co  m*/
    dataset = new XYSeriesCollectionWrapper(getMatrix());
    // dataset = new CategoryDatasetWrapper(getMatrix());

    String title = getMatrix().getLabel();
    String xLabel = StringUtil.format(getMatrix().getMatrix().getDimensionLabel(Matrix.ROW));
    String yLabel = null;

    // setChart(ChartFactory.createLineChart(title, xLabel, yLabel,
    // (CategoryDataset) dataset, PlotOrientation.VERTICAL, true,
    // true, false));
    setChart(ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset,
            PlotOrientation.VERTICAL, true, true, false));

    XYPlot plot = getChart().getXYPlot();

    if (getConfig().isLogScaleDomain()) {
        try {
            NumberAxis axis = new LogarithmicAxis(null);
            plot.setDomainAxis(axis);
        } catch (Exception e) {
            NumberAxis axis = new NumberAxis();
            plot.setDomainAxis(axis);
        }
    } else {
        NumberAxis axis = new NumberAxis();
        plot.setDomainAxis(axis);
    }

    if (getConfig().isLogScaleRange()) {
        try {
            NumberAxis axis = new LogarithmicAxis(null);
            plot.setRangeAxis(axis);
        } catch (Exception e) {
            NumberAxis axis = new NumberAxis();
            plot.setRangeAxis(axis);
        }
    } else {
        NumberAxis axis = new NumberAxis();
        plot.setRangeAxis(axis);
    }

    getChart().setTitle((String) null);

    getChart().setBackgroundPaint(Color.WHITE);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseShapesVisible(false);
    renderer.setDrawSeriesLineAsPath(true);
    for (int i = 0; i < getMatrix().getColumnCount(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(3));
        plot.setRenderer(i, renderer);
    }

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.getRangeAxis().setAutoRange(true);
    plot.getDomainAxis().setAutoRange(true);
    plot.getDomainAxis().setUpperMargin(0);

    setMouseZoomable(false);
}

From source file:edu.ucla.stat.SOCR.chart.SuperNormalDistributionChart.java

/**
 * Creates a chart./*from  w  w  w . ja  v a 2s  .c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.squale.squaleweb.util.graph.HistoMaker.java

/**
 * This method create the JFreechart chart
 * /*from  w ww  .  j  a  va  2 s  .  co  m*/
 * @param maxAxisToday Does the max for the date axis should be set to today ?
 * @return A JFreeChart chart
 */
public JFreeChart getChart(boolean maxAxisToday) {
    JFreeChart retChart = super.getChart();
    if (null == retChart) {
        retChart = ChartFactory.createTimeSeriesChart(mTitle, mXLabel, mYLabel, mDataSet, mShowLegend, false,
                false);
        XYPlot plot = retChart.getXYPlot();
        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
        xylineandshaperenderer.setBaseShapesVisible(true);
        plot.setRenderer(xylineandshaperenderer);
        SimpleDateFormat sdf = new SimpleDateFormat(mDateFormat);
        DateAxis axis = (DateAxis) plot.getDomainAxis();
        if (maxAxisToday) {
            axis.setMaximumDate(new Date());
        }
        axis.setDateFormatOverride(sdf);
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        yAxis.setAutoRangeMinimumSize(2.0);
        super.setChart(retChart);
    }
    return retChart;
}