Java Code Examples for org.jfree.chart.axis.NumberAxis#setAutoRangeStickyZero()

The following examples show how to use org.jfree.chart.axis.NumberAxis#setAutoRangeStickyZero() . 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: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));

    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));

    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));

}
 
Example 2
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));
    
    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));
    
    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));
    
}
 
Example 3
Source File: MirrorChartFactory.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private static JFreeChart createMirrorChart(String labelA, double precursorMZA, double rtA,
    DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB,
    boolean showTitle, boolean showLegend) {
  PseudoSpectrumDataSet data =
      dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA);
  PseudoSpectrumDataSet dataMirror =
      dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB);

  NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat();
  NumberFormat intensityFormat = new DecimalFormat("0.#");

  // set the X axis (retention time) properties
  NumberAxis xAxis = new NumberAxis("m/z");
  xAxis.setNumberFormatOverride(mzForm);
  xAxis.setUpperMargin(0.08);
  xAxis.setLowerMargin(0.00);
  xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setMinorTickCount(5);

  PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false);
  PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false);

  // create subplot 1...
  final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]");
  final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1);
  subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
  rangeAxis1.setNumberFormatOverride(intensityFormat);
  rangeAxis1.setAutoRangeIncludesZero(true);
  rangeAxis1.setAutoRangeStickyZero(true);

  // create subplot 2...
  final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]");
  rangeAxis2.setNumberFormatOverride(intensityFormat);
  rangeAxis2.setAutoRangeIncludesZero(true);
  rangeAxis2.setAutoRangeStickyZero(true);
  rangeAxis2.setInverted(true);
  final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2);
  subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(xAxis);
  plot.setGap(0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);

  // set the plot properties
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

  // set rendering order
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(false);

  // return a new chart containing the overlaid plot...
  JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  chart.setBackgroundPaint(Color.white);
  chart.getTitle().setVisible(false);

  chart.getXYPlot().setRangeZeroBaselineVisible(true);
  chart.getTitle().setVisible(showTitle);
  chart.getLegend().setVisible(showLegend);

  return chart;
}
 
Example 4
Source File: SpectrumChartFactory.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public static EChartPanel createMirrorChartPanel(String labelA, double precursorMZA, double rtA,
    DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB,
    boolean showTitle, boolean showLegend) {
  PseudoSpectrumDataSet data =
      dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA);
  PseudoSpectrumDataSet dataMirror =
      dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB);

  NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat();
  NumberFormat intensityFormat = new DecimalFormat("0.#");

  // set the X axis (retention time) properties
  NumberAxis xAxis = new NumberAxis("m/z");
  xAxis.setNumberFormatOverride(mzForm);
  xAxis.setUpperMargin(0.08);
  xAxis.setLowerMargin(0.00);
  xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setMinorTickCount(5);

  PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false);
  PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false);

  // create subplot 1...
  final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]");
  final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1);
  subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
  rangeAxis1.setNumberFormatOverride(intensityFormat);
  rangeAxis1.setAutoRangeIncludesZero(true);
  rangeAxis1.setAutoRangeStickyZero(true);

  // create subplot 2...
  final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]");
  rangeAxis2.setNumberFormatOverride(intensityFormat);
  rangeAxis2.setAutoRangeIncludesZero(true);
  rangeAxis2.setAutoRangeStickyZero(true);
  rangeAxis2.setInverted(true);
  final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2);
  subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
  plot.setGap(0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);


  // set the plot properties
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

  // set rendering order
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(false);

  // return a new chart containing the overlaid plot...
  JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  chart.setBackgroundPaint(Color.white);
  chart.getTitle().setVisible(false);

  // chart.getXYPlot().setRangeZeroBaselineVisible(true);
  chart.getTitle().setVisible(showTitle);
  chart.getLegend().setVisible(showLegend);

  return new EChartPanel(chart);
}
 
Example 5
Source File: ExcitationEditorJPanel.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
static ExcitationPanel createPanel(ControlLinear excitation, Vector<XYFunctionInterface> functions)
{
      ControlLinear cl = ControlLinear.safeDownCast(excitation);
      XYSeriesCollection seriesCollection = new XYSeriesCollection();
      
      FunctionXYSeries xySeries = new FunctionXYSeries("excitation");
      SetControlNodes cnodes = cl.getControlValues();
      XYFunctionInterface ctrlFunction = createFunctionFromControlLinear(xySeries, cnodes, !cl.getUseSteps());
      int np = ctrlFunction.getNumberOfPoints();
      functions.add(ctrlFunction);
      seriesCollection.addSeries(xySeries);
      
      FunctionXYSeries xySeriesMin = new FunctionXYSeries("min");
      SetControlNodes minNodes = cl.getControlMinValues();
      XYFunctionInterface minFunction = createFunctionFromControlLinear(xySeriesMin, minNodes, false);
      functions.add(minFunction);
      seriesCollection.addSeries(xySeriesMin);
     
      FunctionXYSeries xySeriesMax = new FunctionXYSeries("max");
      SetControlNodes maxNodes = cl.getControlMaxValues();
      XYFunctionInterface maxFunction = createFunctionFromControlLinear(xySeriesMax, maxNodes, false);
      functions.add(maxFunction);
      seriesCollection.addSeries(xySeriesMax);
      
      JFreeChart chart = FunctionPanel.createFunctionChart(
                 "", "", "", seriesCollection,
                 true, true);
      FunctionPlot xyPlot = (FunctionPlot)chart.getXYPlot();
      XYDataset xyDataset = xyPlot.getDataset();

      Vector<XYFunctionInterface> xyFunctions = new Vector<XYFunctionInterface>(functions.size());
      for (int i=0; i<functions.size(); i++)
          xyFunctions.add(functions.get(i));

      ExcitationRenderer renderer = new ExcitationRenderer(excitation, functions);
      ValueAxis va = xyPlot.getRangeAxis();
      if (va instanceof NumberAxis) {
         NumberAxis na = (NumberAxis) va;
         na.setAutoRangeIncludesZero(false);
         na.setAutoRangeStickyZero(false);
         xyPlot.setRangeAxis(na);
         na.setNumberFormatOverride(new DecimalFormat("0.0000"));
      }
      xyPlot.setRenderer(renderer);
      ExcitationPanel dPanel =  new ExcitationPanel(chart);
      
      return dPanel;
}