Java Code Examples for org.jfree.chart.ChartPanel#restoreAutoRangeBounds()

The following examples show how to use org.jfree.chart.ChartPanel#restoreAutoRangeBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartLogics.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Auto range the range axis
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartPanel myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  // trick. Otherwise auto range will fail sometimes
  rangeAxis.setRange(rangeAxis.getRange());
  rangeAxis.setAutoRangeIncludesZero(true);
  myChart.restoreAutoRangeBounds();
}
 
Example 2
Source File: ChartLogics.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Auto range the range axis
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartPanel myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  // trick. Otherwise auto range will fail sometimes
  rangeAxis.setRange(rangeAxis.getRange());
  rangeAxis.setAutoRangeIncludesZero(true);
  myChart.restoreAutoRangeBounds();
}
 
Example 3
Source File: ChartLogics.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Auto range the range axis
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartPanel myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  // trick. Otherwise auto range will fail sometimes
  rangeAxis.setRange(rangeAxis.getRange());
  rangeAxis.setAutoRangeIncludesZero(true);
  myChart.restoreAutoRangeBounds();
}
 
Example 4
Source File: ChartPanelTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoRangeBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
public void test2502355_restoreAutoRangeBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoRangeBounds();
    assertEquals(1, this.chartChangeEvents.size());
}