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

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

Introduction

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

Prototype

public void setOrientation(PlotOrientation orientation) 

Source Link

Document

Sets the orientation for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:bicat.gui.GraphicPane.java

/**
 * Creates a line chart with/*from w  w w. j  a va 2  s .co m*/
 * default settings.
 *
 * @param title       the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset     the dataset for the chart (<code>null</code> permitted).
 * @param orientation the plot orientation (horizontal or vertical) (
 *                    <code>null</code> NOT permitted).
 * @param legend      a flag specifying whether or not a legend is required.
 * @param tooltips    configure chart to generate tool tips?
 * @param urls        configure chart to generate URLs?
 * @return The chart.
 */
public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    ValueMarker vm = new ValueMarker(marker);
    vm.setPaint(Color.GRAY);
    // plot.addRangeMarker(vm, Layer.FOREGROUND); //.setPaint(Color.PINK));
    plot.addDomainMarker(vm, Layer.FOREGROUND);

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:org.mwc.debrief.sensorfusion.views.DataSupport.java

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

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

    chart.setBackgroundPaint(Color.white);

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

    plot.setOrientation(PlotOrientation.HORIZONTAL);

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

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

    return chart;

}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

public static JFreeChart createCustomXYStepAreaChart(TimePeriodValuesCollection top,
        TimePeriodValuesCollection bottom) {
    DateAxis xAxis = new DateAxis(null);
    NumberAxis yAxis = new NumberAxis("price");
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    yAxis.setUpperBound(100);// w  ww  .  java  2 s  . c om
    yAxis.setLowerBound(0.0);

    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setDataset(0, top);
    plot.setDataset(1, bottom);
    XYStepAreaRenderer bottomRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    XYStepAreaRenderer topRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    topRenderer.setRangeBase(1.0);
    topRenderer.setSeriesPaint(0, new Color(204, 255, 153));
    bottomRenderer.setSeriesPaint(0, new Color(51, 255, 204));
    plot.setRenderer(bottomRenderer);
    plot.setRenderer(1, topRenderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:bicat.gui.GraphicPane.java

public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*w w w  .j a  v  a2s  .  c  o m*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    for (int i = 0; i < marker.length; i++) {
        ValueMarker vm = new ValueMarker(marker[i]);
        vm.setPaint(Color.GRAY.brighter());
        // plot.addRangeMarker(vm, Layer.FOREGROUND);
        // //.setPaint(Color.PINK));
        plot.addDomainMarker(vm, Layer.FOREGROUND);
    }

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:bicat.gui.GraphicPane.java

public static JFreeChart myCreateSimpleXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*  ww w .j  a v  a2  s  .c  om*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    // xAxis.setAxisLineVisible(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    // yAxis.setAxisLineVisible(false); // new?

    // xAxis.setAxisLineVisible(false);
    // yAxis.setAxisLineVisible(false);

    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    /*
     * for(int i = 0; i < marker.length; i++) { ValueMarker vm = new
     * ValueMarker(marker[i]); vm.setPaint(Color.GRAY.brighter());
     * //plot.addRangeMarker(vm, Layer.FOREGROUND);
     * //.setPaint(Color.PINK)); plot.addDomainMarker(vm, Layer.FOREGROUND);
     * }
     */

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

}

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

private static JFreeChart createScatterChart(XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }/*w  w  w  .jav a2s  .c om*/

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart("Scatter 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);

    yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;

}

From source file:org.operamasks.faces.render.graph.CurveAreaChartRenderer.java

private JFreeChart createXYCurveAreaChart(XYDataset dataset, PlotOrientation orientation) {
    ValueAxis xAxis;/*from ww  w. j av a 2s . c  om*/
    if (dataset instanceof TimeSeriesCollection) {
        xAxis = new DateAxis();
    } else {
        xAxis = new NumberAxis();
        ((NumberAxis) xAxis).setAutoRangeIncludesZero(false);
    }
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYCurveAndShapeRenderer renderer = new XYCurveAndShapeRenderer(true, false);
    renderer.setDrawArea(true);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (dataset.getSeriesCount() > 1) {
        plot.setForegroundAlpha(0.75f);
    }

    return new JFreeChart(null, null, plot, false);
}

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

/**
 * A demonstration application showing an XY series containing a null value.
 *
 * @param title  the frame title./*  w ww.  java  2 s  .  c  o  m*/
 */
public WaterTemperatureDemo(final String title) {

    super(title);
    final XYDataset dataset = createDataset();

    final NumberAxis rangeAxis = new NumberAxis("Temperature");
    rangeAxis.setRange(-0.55, -0.15);

    final NumberAxis domainAxis = new NumberAxis("Depth");
    domainAxis.setInverted(true);
    domainAxis.setRange(0.0, 35.0);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new StandardXYItemRenderer();

    final XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    final JFreeChart chart = new JFreeChart("Water Temperature By Depth", plot);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:org.optaplanner.benchmark.impl.statistic.calculatecount.CalculateCountProblemStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    Locale locale = benchmarkReport.getLocale();
    NumberAxis xAxis = new NumberAxis("Time spent");
    xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale));
    NumberAxis yAxis = new NumberAxis("Calculate count per second");
    yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale));
    yAxis.setAutoRangeIncludesZero(false);
    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setOrientation(PlotOrientation.VERTICAL);
    int seriesIndex = 0;
    for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) {
        XYSeries series = new XYSeries(
                singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix());
        XYItemRenderer renderer = new XYLineAndShapeRenderer();
        if (singleBenchmarkResult.isSuccess()) {
            CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmarkResult
                    .getSingleStatistic(problemStatisticType);
            for (CalculateCountStatisticPoint point : singleStatistic.getPointList()) {
                long timeMillisSpent = point.getTimeMillisSpent();
                long calculateCountPerSecond = point.getCalculateCountPerSecond();
                series.add(timeMillisSpent, calculateCountPerSecond);
            }//from  ww  w.j  a va  2 s .  c om
        }
        plot.setDataset(seriesIndex, new XYSeriesCollection(series));

        if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) {
            // Make the favorite more obvious
            renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        }
        plot.setRenderer(seriesIndex, renderer);
        seriesIndex++;
    }
    JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " calculate count statistic",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "CalculateCountStatistic");
}

From source file:org.mwc.cmap.grideditor.chart.ChartBuilder.java

public JFreeChart buildChart() {
    final ValueAxis xAxis = myManager.createXAxis();
    final ValueAxis yAxis = myManager.createYAxis();
    final XYDataset data = myManager.getXYDataSet();
    final XYLineAndShapeRenderer renderer = new ColorRenderer();
    final XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer);
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    final JFreeChart result = new JFreeChart(myManager.getChartTitle(), JFreeChart.DEFAULT_TITLE_FONT, xyplot,
            false);//  w  w  w  .j  a  v  a2 s  . c  om
    ChartUtilities.applyCurrentTheme(result);
    return result;
}