Example usage for org.jfree.chart.axis NumberAxis setLowerBound

List of usage examples for org.jfree.chart.axis NumberAxis setLowerBound

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setLowerBound.

Prototype

public void setLowerBound(double min) 

Source Link

Document

Sets the lower bound for the axis range.

Usage

From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java

private void initXYPlot(JFreeChart chart, ChartModel chartModel) {
    initPlot(chart, chartModel);//from   ww  w  .  ja  v  a2 s . com

    org.pentaho.chart.model.TwoAxisPlot twoAxisPlot = (org.pentaho.chart.model.TwoAxisPlot) chartModel
            .getPlot();
    XYPlot xyPlot = chart.getXYPlot();

    List<Integer> colors = getPlotColors(twoAxisPlot);

    for (int i = 0; i < colors.size(); i++) {
        for (int j = 0; j < xyPlot.getDatasetCount(); j++) {
            xyPlot.getRenderer(j).setSeriesPaint(i, new Color(0x00FFFFFF & colors.get(i)));
        }
    }

    Font domainAxisFont = ChartUtils.getFont(twoAxisPlot.getDomainAxis().getFontFamily(),
            twoAxisPlot.getDomainAxis().getFontStyle(), twoAxisPlot.getDomainAxis().getFontWeight(),
            twoAxisPlot.getDomainAxis().getFontSize());
    Font rangeAxisFont = ChartUtils.getFont(twoAxisPlot.getRangeAxis().getFontFamily(),
            twoAxisPlot.getRangeAxis().getFontStyle(), twoAxisPlot.getRangeAxis().getFontWeight(),
            twoAxisPlot.getRangeAxis().getFontSize());
    Font rangeTitleFont = ChartUtils.getFont(twoAxisPlot.getRangeAxis().getLegend().getFontFamily(),
            twoAxisPlot.getRangeAxis().getLegend().getFontStyle(),
            twoAxisPlot.getRangeAxis().getLegend().getFontWeight(),
            twoAxisPlot.getRangeAxis().getLegend().getFontSize());
    Font domainTitleFont = ChartUtils.getFont(twoAxisPlot.getDomainAxis().getLegend().getFontFamily(),
            twoAxisPlot.getDomainAxis().getLegend().getFontStyle(),
            twoAxisPlot.getDomainAxis().getLegend().getFontWeight(),
            twoAxisPlot.getDomainAxis().getLegend().getFontSize());

    NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();

    domainAxis.setAutoRangeIncludesZero(true);
    rangeAxis.setAutoRangeIncludesZero(true);

    AxesLabels axesLabels = getAxesLabels(chartModel);
    if ((axesLabels.rangeAxisLabel.length() > 0) && (rangeTitleFont != null)) {
        rangeAxis.setLabelFont(rangeTitleFont);
    }

    if ((axesLabels.domainAxisLabel.length() > 0) && (domainTitleFont != null)) {
        domainAxis.setLabelFont(domainTitleFont);
    }

    domainAxis.setVerticalTickLabels(
            twoAxisPlot.getHorizontalAxis().getLabelOrientation() == LabelOrientation.VERTICAL);

    if (domainAxisFont != null) {
        domainAxis.setTickLabelFont(domainAxisFont);
    }
    if (rangeAxisFont != null) {
        rangeAxis.setTickLabelFont(rangeAxisFont);
    }

    Number rangeMin = ((NumericAxis) twoAxisPlot.getRangeAxis()).getMinValue();
    if (rangeMin != null) {
        rangeAxis.setLowerBound(rangeMin.doubleValue());
    }
    Number rangeMax = ((NumericAxis) twoAxisPlot.getRangeAxis()).getMaxValue();
    if (rangeMax != null) {
        rangeAxis.setUpperBound(rangeMax.doubleValue());
    }
}

From source file:com.chart.SwingChart.java

/**
 * Set lower and upper limits for an ordinate
 * @param axis Axis to configure/*from ww w.j a v a  2 s  .  co  m*/
 */
void setOrdinateRange(final NumberAxis axis) {
    axis.setAutoRange(false);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));
    final TextField tfMax;
    final TextField tfMin;
    final TextField tfTick;
    final TextField tfFuente;
    grid.add(new Label("Axis"), 0, 0);
    grid.add(new Label(axis.getLabel()), 1, 0);
    grid.add(new Label("Lower"), 0, 1);
    grid.add(tfMin = new TextField(), 1, 1);
    grid.add(new Label("Upper"), 0, 2);
    grid.add(tfMax = new TextField(), 1, 2);
    grid.add(new Label("Space"), 0, 3);
    grid.add(tfTick = new TextField(), 1, 3);

    tfMin.setText(String.valueOf(axis.getLowerBound()));
    tfMax.setText(String.valueOf(axis.getUpperBound()));
    tfTick.setText(String.valueOf(axis.getTickUnit().getSize()));

    new PseudoModalDialog(skeleton, grid, true) {
        @Override
        public boolean validation() {
            axis.setLowerBound(Double.valueOf(tfMin.getText()));
            axis.setUpperBound(Double.valueOf(tfMax.getText()));
            axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText())));
            return true;
        }
    }.show();

}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

private void customizeAxis(ChartDefinition cd, ChartAxis ai, NumberAxis axis) {
    customizeAxisEx(cd, ai, axis);//from  w  w  w  .  j  a  v  a 2 s.c om

    ChartInfo ci = (ChartInfo) cd.getChartHandlerInfo();
    double[] bounds = null;

    if (cd.getSeriesCount() > 0) {
        if (ai.isRangeAxis()) {
            bounds = ci.yAxisValues;
        } else {
            bounds = ci.xAxisValues;
        }
    }

    if (bounds != null) {
        axis.setLowerBound(bounds[0]);
        axis.setUpperBound(bounds[1]);
        axis.setTickUnit(new NumberTickUnit(bounds[2]));
    } else {
        RenderableDataItem u = ai.getUpperBounds();
        RenderableDataItem l = ai.getLowerBounds();
        double inc = ai.getIncrement();

        if (u != null) {
            axis.setUpperBound(u.doubleValue());
        }

        if (l != null) {
            axis.setLowerBound(l.doubleValue());
        }

        if (inc > 0) {
            axis.setTickUnit(new NumberTickUnit(inc));
        }
    }

    axis.setVisible(ai.isVisible());
}