Example usage for org.jfree.chart.axis SymbolAxis setFixedDimension

List of usage examples for org.jfree.chart.axis SymbolAxis setFixedDimension

Introduction

In this page you can find the example usage for org.jfree.chart.axis SymbolAxis setFixedDimension.

Prototype

public void setFixedDimension(double dimension) 

Source Link

Document

Sets the fixed dimension for the axis.

Usage

From source file:web.diva.server.model.LineChartGenerator.java

/**
 * Creates a chart.//from  w  ww.  j  a  va 2  s .com
 *
 * @param dataset the data for the chart.
 * @param lcr the line chart result
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String[] colors, String[] columnIds, int[] selection) {

    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title
            "", // x axis label
            "", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    if (selection == null) {
        for (int x = 0; x < colors.length; x++) {

            renderer.setSeriesShapesVisible(x, false);
            renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[x]));

        }
    } else {
        for (int x = 0; x < selection.length; x++) {

            renderer.setSeriesShapesVisible(x, false);
            renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[selection[x]]));

        }

    }

    plot.setRenderer(renderer);

    SymbolAxis rangeAxis = new SymbolAxis("", columnIds);
    rangeAxis.setGridBandsVisible(false);
    rangeAxis.setVerticalTickLabels(true);
    rangeAxis.setVisible(true);
    //        rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 1));
    rangeAxis.setFixedDimension(51.0);

    boolean auto = rangeAxis.getAutoRangeIncludesZero();
    rangeAxis.setAutoRangeIncludesZero(true ^ auto);
    rangeAxis.setTickUnit(new NumberTickUnit(1));
    rangeAxis.setRange(0, columnIds.length);

    plot.setDomainAxis(rangeAxis);

    return chart;

}

From source file:web.diva.server.unused.ProfilePlotGenerator.java

/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings./*  ww  w.j a  v a  2  s.c  o m*/
 *
 * @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.
 */
private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset,
        PlotOrientation orientation, boolean legend, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    Font f = new Font("ARIAL", 1, 7);
    //        NumberAxis xAxis = new NumberAxis(xAxisLabel);
    //        xAxis.setAutoRangeIncludesZero(false);
    SymbolAxis xAxis = new SymbolAxis("", columnIds);
    xAxis.setAxisLineVisible(false);
    xAxis.setGridBandsVisible(false);
    xAxis.setVerticalTickLabels(true);
    xAxis.setVisible(true);

    xAxis.setTickLabelPaint(shadowColor);
    xAxis.setTickLabelFont(f);
    xAxis.setFixedDimension(51.0);

    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    xAxis.setTickUnit(new NumberTickUnit(1));
    xAxis.setRange(0, columnIds.length);
    //        NumberAxis yAxis = new NumberAxis(yAxisLabel);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setAxisLineVisible(false);
    yAxis.setTickLabelFont(f);
    yAxis.setTickLabelPaint(Color.BLUE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseShapesVisible(false);
    renderer.setPaint(shadowColor);

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

    plot.setBackgroundPaint(Color.WHITE);

    plot.setDomainGridlinePaint(shadowColor);
    plot.setRangeGridlinePaint(shadowColor);
    plot.setOutlinePaint(Color.BLUE);
    //        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //        plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    plot.setDomainAxis(xAxis);

    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

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

}