Example usage for org.jfree.chart.plot XYPlot setRenderer

List of usage examples for org.jfree.chart.plot XYPlot setRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRenderer.

Prototype

public void setRenderer(XYItemRenderer renderer) 

Source Link

Document

Sets the renderer for the primary dataset and sends a change event to all registered listeners.

Usage

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);
    setContentPane(chartPanel);/*ww  w. j a va2s  .  c o  m*/

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

}

From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java

private void configurePlot() {
    XYPlot plot = (XYPlot) jfreechart.getPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setDataset(dataset);/*from w  ww  .ja v a  2s  . co  m*/
    plot.setDomainAxis(x);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setRangeAxis(y);
    plot.setRenderer(renderer);
    plot.setBackgroundAlpha(0.0f);
}

From source file:edu.ku.brc.specify.plugins.sgr.HistogramChart.java

private void update() {
    UIRegistry.loadAndPushResourceBundle("specify_plugins");

    HistogramDataset dataSet = new HistogramDataset();
    double max = resultSet.getMax();

    dataSet.addSeries(getResourceString("SGR_HISTO_DATASERIES"), resultSet.getValues(1.0), 40, 0.0, max);

    JFreeChart chart = ChartFactory.createHistogram(getResourceString("SGR_HISTO_TITLE"),
            getResourceString("SGR_HISTO_X_AXIS"), getResourceString("SGR_HISTO_Y_AXIS"), dataSet,
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from www  .  ja  v a2  s.c om*/

    UIRegistry.popResourceBundle();

    XYPlot plot = chart.getXYPlot();
    CustomRenderer.setDefaultBarPainter(new StandardXYBarPainter());
    CustomRenderer renderer = new CustomRenderer(dataSet);
    plot.setRenderer(renderer);
    renderer.setMargin(0.1);

    ChartPanel chartPanel = new ChartPanel(chart, true, true, true, true, true);
    removeAll();
    add(chartPanel);
    validate();
}

From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformHistogramChart.java

protected JFreeChart createChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    // then customise it a little...
    // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do"));
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new ClusteredXYBarRenderer());
    //plot.setRenderer(new XYBarRenderer());
    XYItemRenderer renderer = plot.getRenderer();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // setXSummary(dataset);  //X  is time
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    return chart;
}

From source file:carfuzzy.Operations.java

public JFreeChart setToChart(double input, double membership, XYSeries series, XYSeriesCollection collection,
        String x_axis) { // kurallari cizdirdikten sonra cizdir.

    series.add(input, membership);/*from   w  ww. jav a  2  s .  com*/
    series.add(input, 0);
    series.add(0, membership);
    collection.addSeries(series);

    JFreeChart chart = XYGraph.drawChart(collection, x_axis, "Membership");
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer renderer = plot.getRenderer();

    renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f));
    renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f));
    plot.setRenderer(renderer);
    return chart;
}

From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java

@OnAwt
@Override/*from   w  ww.java 2s.  co  m*/
public void setShowShapes(boolean flag) {
    boolean oldValue = this.showShapes;
    if (oldValue != flag) {
        this.showShapes = flag;
        XYPlot plot = chart.getXYPlot();
        plot.setRenderer(createLineShapeRenderer());
    }
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {//from   w  w  w .  jav  a 2 s . c o m
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}

From source file:service.chart.TimeSeriesChart.java

/**
 * Utworz wykres szeregu czasowego na podstawie zestawu danych
 * /*  w w w.  ja v  a  2 s  .c  o  m*/
 * @param dataset Zestaw danych
 * @return Wykres szeregu czasowego
 */
private JFreeChart createChart(XYDataset dataset) {

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

    chart.setBackgroundPaint(Color.white);

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

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

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

    return chart;
}

From source file:ejemplo.Ejemplo.java

private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//w w w .  j a  v a  2 s.  c  o  m

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

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

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

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    return chart;

}

From source file:edu.mit.fss.examples.member.gui.CommSubsystemPanel.java

/**
 * Instantiates a new communications subsystem panel for a subsystem. 
 * Signals are sent via the associated {@link federate}.
 *
 * @param federate the federate/*from w  w w .  ja va 2  s  .c o m*/
 * @param subsystem the subsystem
 */
public CommSubsystemPanel(Federate federate, CommSubsystem subsystem) {
    this.subsystem = subsystem;

    logger.trace("Creating and adding receiver panel.");
    receiverPanel = new ReceiverPanel(subsystem.getReceiver());
    logger.trace("Adding receiver panel as an object listener.");
    listenerList.add(ObjectChangeListener.class, receiverPanel);
    addTab("Receiver", receiverPanel);

    logger.trace("Creating and adding transmitter panel.");
    transmitterPanel = new TransmitterPanel(federate, subsystem.getTransmitter());
    logger.trace("Adding transmitter panel as an object listener.");
    listenerList.add(ObjectChangeListener.class, transmitterPanel);
    addTab("Transmitter", transmitterPanel);

    logger.trace("Creating and adding connectivity chart panel.");
    connectivityChart = ChartFactory.createTimeSeriesChart(null, "Time", "Connectivity", connectDataset, true,
            false, false);
    connectivityChart.setBackgroundPaint(getBackground());
    if (connectivityChart.getPlot() instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) connectivityChart.getPlot();
        XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4));
        xyPlot.setRenderer(renderer);
        xyPlot.setBackgroundPaint(Color.WHITE);
        xyPlot.setDomainGridlinePaint(Color.GRAY);
        xyPlot.setRangeGridlinePaint(Color.GRAY);
    }
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.add(new ChartPanel(connectivityChart), BorderLayout.CENTER);
    chartPanel.add(new JButton(exportAction), BorderLayout.SOUTH);
    addTab("Connectivity", chartPanel);
}