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

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

Introduction

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

Prototype

public void setRangeGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:loadmaprenderer.ResultDisplayChart.java

private JFreeChart makeChart(XYDataset dataset, String chartTitle, String dataTitle) {
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "Year", dataTitle, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLUE);
    plot.setRangeGridlinePaint(Color.BLUE);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);/*  ww  w .  j  a va 2  s  .  co m*/
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRange(true);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    Double range = dataLine.getMaxY() - dataLine.getMinY();
    if (Math.abs(range) < 0.1)
        range = dataLine.getMaxY();
    rangeAxis.setRange(dataLine.getMinY() - range * 0.1, dataLine.getMaxY() + range * 0.1);
    return chart;
}

From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java

private JFreeChart createRhatChart(final XYDataset dataset) {
    final JFreeChart RhatChart = ChartFactory.createXYLineChart("Iterative PSRF Plot", "Iteration No.",
            "R-Hat(p)", dataset, PlotOrientation.VERTICAL, false, true, false);

    RhatChart.setBackgroundPaint(Color.white);
    final XYPlot RhatPlot = RhatChart.getXYPlot();
    RhatPlot.setDomainGridlinePaint(Color.white);
    RhatPlot.setRangeGridlinePaint(Color.white);

    final NumberAxis rangeAxis = (NumberAxis) RhatPlot.getRangeAxis();
    rangeAxis.setAutoRange(true);/*from www.  jav  a  2  s.c  o  m*/
    rangeAxis.setAutoRangeIncludesZero(false);

    return RhatChart;
}

From source file:com.kurvlrgui.gui.ChartPanel.java

/**
 * Creates new form ChartPanel/*from   w  ww  .j a v a 2s.  c  o m*/
 */
public ChartPanel(String title, NumericData s1, NumericData s2) {
    initComponents();

    calculated = new XYSeries("Calculated");
    for (NumericPair np : s1.values) {
        calculated.add(np.x, np.y);
    }

    observed = null;
    if (s2 != null) {
        observed = new XYSeries("Observed");
        for (NumericPair np : s2.values) {
            observed.add(np.x, np.y);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(calculated);
    if (s2 != null)
        dataset.addSeries(observed);

    JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true,
            true, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);

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

    panel = new org.jfree.chart.ChartPanel(chart);

    panel.setHorizontalAxisTrace(true);
    panel.setVerticalAxisTrace(true);

    this.add(panel);
}

From source file:Interfaz.XYLineChart.java

/** Constructor de clase 
* @param d Dimension/* w w w  .  j  a  v a  2 s .  c o m*/
*/
public XYLineChart(Dimension d, ArrayList<Restriccion> rest, ArrayList<Coordenada> cor) {

    //se declara el grafico XY Lineal
    XYDataset xydataset = xyDataset(rest, cor);
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Graficas lineales", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);

    //personalizacin del grafico
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    // -> Pinta Shapes en los puntos dados por el XYDataset
    //        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    //        xylineandshaperenderer.setBaseShapesVisible(true);
    //        //--> muestra los valores de cada punto XY
    //        XYItemLabelGenerator xy = new StandardXYItemLabelGenerator();
    //        xylineandshaperenderer.setBaseItemLabelGenerator( xy );
    //        xylineandshaperenderer.setBaseItemLabelsVisible(true);
    //        xylineandshaperenderer.setBaseLinesVisible(true);
    //        xylineandshaperenderer.setBaseItemLabelsVisible(true);                
    //fin de personalizacin

    //se crea la imagen y se asigna a la clase ImageIcon
    BufferedImage bufferedImage = jfreechart.createBufferedImage(d.width, d.height);
    this.setImage(bufferedImage);
}

From source file:pfg.graphic.Chart.java

/**
 * L'initialisation se fait  part afin de ne pas ouvrir une fentre ds qu'on cre un objet
 *//* w  w w . j  a v a2 s  .c  o m*/
private void init() {
    init = true;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            xAxisLabel, // x-axis label
            yAxisLabel, // 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);
    }

    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new java.awt.Dimension(1024, 600));
    setContentPane(panel);

    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setVisible(true);
}

From source file:etssi.Graphique.java

/**
 * Creates a chart./*from  w w w .  ja  va 2s.  com*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Graphique", // chart title
            "Tranche Horaire (0 avant 6h, 1 de 6h  10h, 2 de 10h  16h, 3 de 16h  20h, 4 aprs 20h ", // x axis label
            "Montant passagers", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // 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.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    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:org.ewhoxford.swt.bloodpressure.ui.MeasurePageTab.java

/**
 * Creates a chart./*  w w w  . j a va  2s . c  om*/
 * 
 * @param dataset
 *            a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset, XYPlot bpMeasureXYPlot) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Blood Pressure Measure", // title
            "time(s)", // x-axis label
            "Pressure(mmHg)", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    bpMeasureXYPlot = (XYPlot) chart.getPlot();
    bpMeasureXYPlot.setBackgroundPaint(Color.lightGray);
    bpMeasureXYPlot.setDomainGridlinePaint(Color.white);
    bpMeasureXYPlot.setRangeGridlinePaint(Color.white);

    // bpMeasureXYPlot.setAxisOffset(new RectangleInsets(300, 0, 0,
    // BOUNDARY_NUMBER_OF_POINTS));
    // bpMeasureXYPlot.setDomainCrosshairVisible(true);
    // bpMeasureXYPlot.setRangeCrosshairVisible(true);

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

    ValueAxis axis = bpMeasureXYPlot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    // axis.setRange(0, 1000);
    axis.setAutoRange(true);
    axis = bpMeasureXYPlot.getRangeAxis();
    axis.setRange(0, 300.0);

    // DateAxis axis = (DateAxis) plot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    // axis.setRange(0, 1000);

    return chart;

}

From source file:br.unicamp.cst.behavior.bn.support.Grafico.java

public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    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.setShapesVisible(true);/* w  w  w  .  j  a v  a2 s .  com*/
    renderer.setShapesFilled(true);

    setXyplot(plot);
    setChart(chart);

    ChartFrame frame = new ChartFrame(frametitle, chart);

    frame.pack();
    frame.setVisible(true);
}

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

public MemoryUsageDemo(int i) {
    super(new BorderLayout());
    total = new TimeSeries("Total Memory");
    total.setMaximumItemAge(i);/* ww w. j ava2s.  c  om*/
    free = new TimeSeries("Free Memory");
    free.setMaximumItemAge(i);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(total);
    timeseriescollection.addSeries(free);
    DateAxis dateaxis = new DateAxis("Time");
    NumberAxis numberaxis = new NumberAxis("Memory");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesPaint(1, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
    jfreechart.setBackgroundPaint(Color.white);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartpanel);
}

From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java

private JFreeChart createVhatVsWChart(final XYDataset dataset) {
    final JFreeChart VhatVsWChart = ChartFactory.createXYLineChart("Plots of sqrt(vHat) and sqrt(W)",
            "Iteration No.", "Variance Estimates", dataset, PlotOrientation.VERTICAL, true, true, false);

    VhatVsWChart.setBackgroundPaint(Color.white);
    final XYPlot VhatVsWPlot = VhatVsWChart.getXYPlot();
    VhatVsWPlot.setDomainGridlinePaint(Color.white);
    VhatVsWPlot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    VhatVsWPlot.setRenderer(renderer);//from  w  w w .ja  v  a  2  s .  c o  m

    return VhatVsWChart;
}