Example usage for org.jfree.chart.axis ValueAxis resizeRange

List of usage examples for org.jfree.chart.axis ValueAxis resizeRange

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis resizeRange.

Prototype

public void resizeRange(double percent) 

Source Link

Document

Increases or decreases the axis range by the specified percentage about the central value and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Auto range the axis
 * 
 * @param axis
 */
public static void autoAxis(ValueAxis axis) {
    axis.resizeRange(0);
}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java

@SuppressWarnings("deprecation")
public JFreeChart makeLikertChart() {

    DefaultCategoryDataset likertDataset = new DefaultCategoryDataset();

    for (int i = 0; i < responses.length; i++) {
        likertDataset.addValue(values[i], "Responses", responses[i]);
    }/*from ww w  .ja v  a  2s. c om*/

    JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title
            null, // "Choices", // domain axis label
            null, // "# of Responses", // range axis label
            likertDataset, PlotOrientation.HORIZONTAL, false, // show legend
            false, // show tooltips
            false // show URLs
    );

    // Set the background colours
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // Configure the bar colors and display
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(244, 252, 212));
    renderer.setDrawBarOutline(true);
    renderer.setOutlinePaint(new Color(34, 35, 237));
    renderer.setOutlineStroke(new BasicStroke(0.5f));
    renderer.setBaseItemLabelsVisible(true);
    if (showPercentages) {
        renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount));
    } else {
        renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }
    // Turn off the Top Value Axis
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setUpperMargin(0.35);
    rangeAxis.resizeRange(1.1f);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(0.4f);
    domainAxis.setMaximumCategoryLabelLines(2);

    // Set the font for the labels
    Font labelFont = new Font("Serif", Font.PLAIN, 6);

    CategoryItemRenderer itemRenderer = plot.getRenderer();
    itemRenderer.setBaseItemLabelFont(labelFont);

    plot.setOutlinePaint(null);

    domainAxis.setLabelFont(labelFont);
    domainAxis.setTickLabelFont(labelFont);
    rangeAxis.setLabelFont(labelFont);
    rangeAxis.setTickLabelFont(labelFont);

    return chart;
}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Multiplies the range on the range axis/axes by the specified factor.
 *
 * @param factor  the zoom factor./*from ww w  . j  a  va2  s  .  c om*/
 * @param info  the plot rendering info.
 * @param source  the source point.
 */
public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source) {
    for (int i = 0; i < this.rangeAxes.size(); i++) {
        ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i);
        if (rangeAxis != null) {
            rangeAxis.resizeRange(factor);
        }
    }
}

From source file:ucar.unidata.idv.control.chart.MyXYPlot.java

/**
 * Multiplies the range on the domain axis/axes by the specified factor.
 *
 * @param factor  the zoom factor./*from   w  ww . j a v a2  s.c  o m*/
 * @param info  the plot rendering info.
 * @param source  the source point.
 */
public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source) {
    for (int i = 0; i < this.domainAxes.size(); i++) {
        ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i);
        if (domainAxis != null) {
            domainAxis.resizeRange(factor);
        }
    }
}