Example usage for org.jfree.chart JFreeChart getXYPlot

List of usage examples for org.jfree.chart JFreeChart getXYPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getXYPlot.

Prototype

public XYPlot getXYPlot() 

Source Link

Document

Returns the plot cast as an XYPlot .

Usage

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the point-related properties of a scatter plot.
 * /*from  w w  w  . ja v a2  s . com*/
 * @param aControl
 *            Chart control to be updated.
 * @param aScatter
 *            Visual settings to be applied.
 */
public static void updateScatter(JFreeChart aControl, ScatterSettings aScatter) {
    updateScatter(aControl.getXYPlot(), aScatter);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the general properties of a chart.
 * /*from   w ww  .j  av  a 2  s.  c om*/
 * @param aControl
 *            Chart control to be updated.
 * @param aGeneral
 *            General visual settings to be applied.
 */
public static void updateGeneral(JFreeChart aControl, GeneralVisSettings aGeneral) {
    updateGeneral(aControl.getXYPlot(), aGeneral);
}

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 {/* w w  w . j  a v  a 2s.  c  om*/
        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:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the axis-related properties of a chart.
 * //from w  w w  .  j a  v  a2 s.c  o  m
 * @param aControl
 *            Chart control to be updated.
 * @param aAxes
 *            Axis-related visual settings to be applied.
 * @param aGrid
 *            Grid-related visual settings to be applied.
 */
public static void updateAxes(JFreeChart aControl, AxesSettings aAxes, GridSettings aGrid) {
    XYPlot plot = aControl.getXYPlot();
    Range domainDataRange = aAxes.getLogarithmicDomainAxis()
            ? new Range(logLowerBound(plot.getDataset(), true),
                    plot.getDataRange(plot.getDomainAxis()).getUpperBound())
            : plot.getDataRange(plot.getDomainAxis());
    Range rangeDataRange = aAxes.getLogarithmicRangeAxis()
            ? new Range(logLowerBound(plot.getDataset(), false),
                    plot.getDataRange(plot.getRangeAxis()).getUpperBound())
            : plot.getDataRange(plot.getRangeAxis());
    updateAxes(plot, aAxes, aGrid, domainDataRange, rangeDataRange);
}

From source file:ImageProcessing.ImageProcessing.java

public static JFreeChart createHistogram(double[] dataset_values, Color barColor) {
    //Creates a histogram based on passed values and bar colors.        
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("Values", dataset_values, 255, 0, 255);

    JFreeChart chart = ChartFactory.createHistogram(null, //Title
            null, //X Label
            null, //Y Label
            dataset, //Dataset
            org.jfree.chart.plot.PlotOrientation.VERTICAL, //Plot orientation
            true, false, false); //Other details

    //Remove chart legends to save space, we don't really need them anyway
    chart.removeLegend();/* w w  w.j a  v a  2  s . c  om*/
    //Set bar colors according to the parameter passed.
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    renderer.setSeriesPaint(0, barColor);
    //Set background to null (the background will be similar to frame color in display.
    chart.setBackgroundPaint(null);

    return chart;
}

From source file:org.talend.dataprofiler.chart.ChartDecorator.java

/**
 * DOC bZhou Comment method "decorateXYPlot".
 * //from   www .ja v a  2  s.c  o m
 * @param chart
 */
private static void decorateXYPlot(JFreeChart chart) {

    Font font = null;
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer render = plot.getRenderer();
    ValueAxis domainAxis = plot.getDomainAxis();
    ValueAxis valueAxis = plot.getRangeAxis();

    font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE);//$NON-NLS-1$

    render.setBaseItemLabelFont(font);

    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$
    domainAxis.setLabelFont(font);

    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$
    valueAxis.setLabelFont(font);

    font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE);//$NON-NLS-1$
    domainAxis.setTickLabelFont(font);
    valueAxis.setTickLabelFont(font);

    setLegendFont(chart);

    font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$
    TextTitle title = chart.getTitle();
    if (title != null) {
        title.setFont(font);
    }

    font = null;
}

From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java

public static double translateScreenX(double screenX, Rectangle2D imageArea, JFreeChart chart) {
    //       XYPlot plot = chart.getXYPlot();
    //       boolean isDomainInverted = plot.getDomainAxis().isInverted();
    //       Range domainSection = plot.getDomainAxis().getRange();
    ValueAxis axis = chart.getXYPlot().getDomainAxis();

    return axis.java2DToValue(screenX, imageArea, RectangleEdge.BOTTOM);
    //       if (isDomainInverted) {
    //          return domainSection.getUpperBound() - (screenX - imageArea.getMinX()) 
    //                / imageArea.getWidth() * domainSection.getLength();
    //       } else {
    //          return (screenX - imageArea.getMinX()) / imageArea.getWidth() 
    //                * domainSection.getLength() + domainSection.getLowerBound();
    //       }// w  ww  .  j a v  a  2  s .  co  m
}

From source file:org.gumtree.vis.awt.PlotFactory.java

public static JFreeChart createTimeChart(ITimeSeriesSet timeSeriesSet) {
    //      TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    JFreeChart chart = ChartFactory.createTimeSeriesChart(timeSeriesSet.getTitle(), null,
            timeSeriesSet.getYTitle()/*from   w w w .j  av  a2 s  . c  o m*/
                    + (timeSeriesSet.getYUnits() != null ? " (" + timeSeriesSet.getYUnits() + ")" : ""),
            timeSeriesSet, true, true, false);
    XYPlot xyplot = chart.getXYPlot();
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setAutoRange(true);
    //        valueaxis.setFixedAutoRange(60000D);   
    valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 200D);
    valueaxis.setAutoRange(true);
    XYItemRenderer renderer = xyplot.getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(false);
    }
    chartTheme.apply(chart);
    Font font = valueaxis.getLabelFont();
    valueaxis.setLabelFont(font.deriveFont(Font.PLAIN));
    return chart;
}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

public static JFreeChart getPlot(int[] yData, String title, String xlabel, String ylabel) {
    int[] xData = getXData(yData.length);
    XYSeriesCollection datCol = getCollection(xData, yData, "Data");

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            xlabel, // X-Axis label
            ylabel, // Y-Axis label
            new XYSeriesCollection(), // Dataset
            PlotOrientation.VERTICAL, true, // Show legend
            true, true);//w w w . ja v a2s  . c  om

    // Add the series

    // Set the rendering
    XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true);

    chart.getXYPlot().setRenderer(0, rend1);

    return chart;
}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

private static void decorateCategoryPlot(JFreeChart chart) {

    XYPlot plot = chart.getXYPlot();
    XYItemRenderer render = plot.getRenderer();
    ValueAxis domainAxis = plot.getDomainAxis();
    ValueAxis valueAxis = plot.getRangeAxis();

    Font font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE); //$NON-NLS-1$

    render.setBaseItemLabelFont(font);//w  ww.j  a va  2s .  c om
    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$
    domainAxis.setLabelFont(font);
    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$
    valueAxis.setLabelFont(font);
    font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE); //$NON-NLS-1$
    domainAxis.setTickLabelFont(font);
    valueAxis.setTickLabelFont(font);
    font = new Font("Tahoma", Font.PLAIN, BASE_LEGEND_LABEL_SIZE); //$NON-NLS-1$
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setItemFont(font);
    }
    font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE); //$NON-NLS-1$
    TextTitle title = chart.getTitle();
    if (title != null) {
        title.setFont(font);
    }
    font = null;
    if (render instanceof BarRenderer) {
        int rowCount = chart.getCategoryPlot().getDataset().getRowCount();
        domainAxis.setUpperMargin(0.1);
        // domainAxis.setMaximumCategoryLabelLines(10);
        ((BarRenderer) render).setItemMargin(-0.40 * rowCount);
    }
    // set color
    int rowCount = chart.getXYPlot().getDataset().getSeriesCount();
    for (int i = 0; i < rowCount; i++) {
        plot.getRenderer().setSeriesPaint(i, Color.RED);
    }

}