Java Code Examples for org.jfree.chart.axis.ValueAxis#getUpperBound()

The following examples show how to use org.jfree.chart.axis.ValueAxis#getUpperBound() . 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: PolarPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 2
Source File: Cardumen_0082_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws the domain tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 *
 * @see #setDomainTickBandPaint(Paint)
 */
public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea,
                                List ticks) {
    Paint bandPaint = getDomainTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis xAxis = getDomainAxis();
        double previous = xAxis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = xAxis.getUpperBound();
        if (fillBand) {
            getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
                    previous, end);
        }
    }
}
 
Example 3
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the domain tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 *
 * @see #setDomainTickBandPaint(Paint)
 */
public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea,
                                List ticks) {
    Paint bandPaint = getDomainTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis xAxis = getDomainAxis();
        double previous = xAxis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = xAxis.getUpperBound();
        if (fillBand) {
            getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea,
                    previous, end);
        }
    }
}
 
Example 4
Source File: Cardumen_009_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws the range tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 *
 * @see #setRangeTickBandPaint(Paint)
 */
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                               List ticks) {
    Paint bandPaint = getRangeTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        if (fillBand) {
            getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                    previous, end);
        }
    }
}
 
Example 5
Source File: 1_XYPlot.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws the range tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 * 
 * @see #setRangeTickBandPaint(Paint)
 */
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                               List ticks) {
    Paint bandPaint = getRangeTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillRangeGridBand(g2, this, axis, dataArea, 
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        if (fillBand) {
            getRenderer().fillRangeGridBand(g2, this, axis, dataArea, 
                    previous, end);
        }
    }
}
 
Example 6
Source File: XYPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the range tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 *
 * @see #setRangeTickBandPaint(Paint)
 */
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                               List ticks) {
    Paint bandPaint = getRangeTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        if (fillBand) {
            getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                    previous, end);
        }
    }
}
 
Example 7
Source File: Cardumen_0082_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws the range tick bands, if any.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 *
 * @see #setRangeTickBandPaint(Paint)
 */
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                               List ticks) {
    Paint bandPaint = getRangeTickBandPaint();
    if (bandPaint != null) {
        boolean fillBand = false;
        ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double current = tick.getValue();
            if (fillBand) {
                getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                        previous, current);
            }
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        if (fillBand) {
            getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
                    previous, end);
        }
    }
}
 
Example 8
Source File: ChartLogics.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Apply an absolute offset to domain (x) axis and move it
 * 
 * @param myChart
 * @param xoffset
 * @param autoRangeY
 */
public static void offsetDomainAxisAbsolute(ChartPanel myChart, double xoffset,
    boolean autoRangeY) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ValueAxis domainAxis = plot.getDomainAxis();
  // apply offset on x

  Range range =
      new Range(domainAxis.getLowerBound() + xoffset, domainAxis.getUpperBound() + xoffset);
  setZoomDomainAxis(myChart, keepRangeWithinAutoBounds(domainAxis, range), autoRangeY);
}
 
Example 9
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Restores the auto-range calculation on the range axis.
 */

public void selectCompleteRangeBounds() {
	Plot plot = this.chart.getPlot();
	if (plot instanceof Zoomable) {
		Zoomable z = (Zoomable) plot;
		// here we tweak the notify flag on the plot so that only
		// one notification happens even though we update multiple
		// axes...
		boolean savedNotify = plot.isNotify();
		plot.setNotify(false);
		// we need to guard against this.zoomPoint being null
		Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
		z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);
		plot.setNotify(savedNotify);

		if (plot instanceof XYPlot) {
			XYPlot xyPlot = (XYPlot) plot;
			Selection selectionObject = new Selection();
			for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) {
				ValueAxis range = xyPlot.getRangeAxis(i);
				Range axisRange = new Range(range.getLowerBound(), range.getUpperBound());
				for (String axisName : axisNameResolver.resolveYAxis(i)) {
					selectionObject.addDelimiter(axisName, axisRange);
				}
			}
			informSelectionListener(selectionObject, null);
		}
	}
}
 
Example 10
Source File: ChartLogics.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @param myChart
 * @return Range the domainAxis zoom (X-axis)
 */
public static Range getZoomDomainAxis(ChartPanel myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ValueAxis domainAxis = plot.getDomainAxis();

  return new Range(domainAxis.getLowerBound(), domainAxis.getUpperBound());
}
 
Example 11
Source File: ChartLogicsFX.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Move a chart by a percentage x-offset if xoffset is <0 the shift will be negativ (xoffset>0
 * results in a positive shift)
 * 
 * @param myChart
 * @param xoffset in percent
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void offsetDomainAxis(ChartViewer myChart, double xoffset, boolean autoRangeY) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ValueAxis domainAxis = plot.getDomainAxis();
  // apply offset on x
  double distance = (domainAxis.getUpperBound() - domainAxis.getLowerBound()) * xoffset;

  Range range =
      new Range(domainAxis.getLowerBound() + distance, domainAxis.getUpperBound() + distance);
  setZoomDomainAxis(myChart, keepRangeWithinAutoBounds(domainAxis, range), autoRangeY);
}
 
Example 12
Source File: DefaultPolarItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draw the radial gridlines - the rings.
 *
 * @param g2  the drawing surface (<code>null</code> not permitted).
 * @param plot  the plot (<code>null</code> not permitted).
 * @param radialAxis  the radial axis (<code>null</code> not permitted).
 * @param ticks  the ticks (<code>null</code> not permitted).
 * @param dataArea  the data area.
 */
@Override
public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, 
        ValueAxis radialAxis, List ticks, Rectangle2D dataArea) {

    ParamChecks.nullNotPermitted(radialAxis, "radialAxis");
    g2.setFont(radialAxis.getTickLabelFont());
    g2.setPaint(plot.getRadiusGridlinePaint());
    g2.setStroke(plot.getRadiusGridlineStroke());

    double centerValue;
    if (radialAxis.isInverted()) {
        centerValue = radialAxis.getUpperBound();
    } else {
        centerValue = radialAxis.getLowerBound();
    }
    Point center = plot.translateToJava2D(0, centerValue, radialAxis, dataArea);

    Iterator iterator = ticks.iterator();
    while (iterator.hasNext()) {
        NumberTick tick = (NumberTick) iterator.next();
        double angleDegrees = plot.isCounterClockwise() 
                ? plot.getAngleOffset() : -plot.getAngleOffset();
        Point p = plot.translateToJava2D(angleDegrees,
                tick.getNumber().doubleValue(), radialAxis, dataArea);
        int r = p.x - center.x;
        int upperLeftX = center.x - r;
        int upperLeftY = center.y - r;
        int d = 2 * r;
        Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d);
        g2.setPaint(plot.getRadiusGridlinePaint());
        g2.draw(ring);
    }
}
 
Example 13
Source File: ChartLogicsFX.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Zoom in (negative zoom) or zoom out of axis.
 * 
 * @param myChart
 * @param zoom percentage zoom factor
 * @param start point on this range (first click/pressed event), used as center
 */
public static void zoomAxis(ValueAxis axis, double zoom, double start) {
  double lower = axis.getLowerBound();
  double upper = axis.getUpperBound();
  double dist = upper - lower;
  double f = (start - lower) / dist;

  lower -= dist * zoom * f;
  upper += dist * zoom * (1 - f);

  if (lower < upper) {
    Range range = new Range(lower, upper);
    setZoomAxis(axis, keepRangeWithinAutoBounds(axis, range));
  }
}
 
Example 14
Source File: HistogramDialog.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * tries to find the next local maximum to jump to the prev peak
 */
private void jumpToPrevPeak() {
  XYPlot plot = getXYPlot();
  if (plot == null) {
    return;
  }

  XYDataset data = plot.getDataset(0);
  // get center of zoom
  ValueAxis x = plot.getDomainAxis();
  double mid = (x.getUpperBound() + x.getLowerBound()) / 2;

  boolean started = false;

  for (int i = data.getItemCount(0) - 1; i >= 1; i--) {
    double mz = data.getXValue(0, i);
    if (mz < mid) {
      // wait for y to be 0 to start the search for a new peak
      if (!started) {
        if (data.getYValue(0, i) == 0) {
          started = true;
        }
      } else {
        // intensity drops?
        if (data.getYValue(0, i - 1) != 0 && data.getYValue(0, i) >= 100
            && data.getYValue(0, i - 1) < data.getYValue(0, i)) {
          // peak found with max at i
          setZoomAroundPeakAt(i);
          return;
        }
      }
    }
  }
}
 
Example 15
Source File: ChartLogicsFX.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @param myChart
 * @return Range the domainAxis zoom (X-axis)
 */
public static Range getZoomDomainAxis(ChartViewer myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ValueAxis domainAxis = plot.getDomainAxis();

  return new Range(domainAxis.getLowerBound(), domainAxis.getUpperBound());
}
 
Example 16
Source File: DefaultValueAxisEditor.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Standard constructor: builds a property panel for the specified axis.
 *
 * @param axis  the axis, which should be changed.
 */
public DefaultValueAxisEditor(ValueAxis axis) {

    super(axis);

    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();
    this.autoTickUnitSelection = axis.isAutoTickUnitSelection();

    this.gridPaintSample = new PaintSample(Color.blue);
    this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f));

    this.availableStrokeSamples = new StrokeSample[3];
    this.availableStrokeSamples[0] = new StrokeSample(
            new BasicStroke(1.0f));
    this.availableStrokeSamples[1] = new StrokeSample(
            new BasicStroke(2.0f));
    this.availableStrokeSamples[2] = new StrokeSample(
            new BasicStroke(3.0f));

    JTabbedPane other = getOtherTabs();

    JPanel range = new JPanel(new LCBLayout(3));
    range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    range.add(new JPanel());
    this.autoRangeCheckBox = new JCheckBox(localizationResources.getString(
            "Auto-adjust_range"), this.autoRange);
    this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff");
    this.autoRangeCheckBox.addActionListener(this);
    range.add(this.autoRangeCheckBox);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Minimum_range_value")));
    this.minimumRangeValue = new JTextField(Double.toString(
            this.minimumValue));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    this.minimumRangeValue.setActionCommand("MinimumRange");
    this.minimumRangeValue.addActionListener(this);
    this.minimumRangeValue.addFocusListener(this);
    range.add(this.minimumRangeValue);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Maximum_range_value")));
    this.maximumRangeValue = new JTextField(Double.toString(
            this.maximumValue));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    this.maximumRangeValue.setActionCommand("MaximumRange");
    this.maximumRangeValue.addActionListener(this);
    this.maximumRangeValue.addFocusListener(this);
    range.add(this.maximumRangeValue);
    range.add(new JPanel());

    other.add(localizationResources.getString("Range"), range);

    other.add(localizationResources.getString("TickUnit"),
            createTickUnitPanel());
}
 
Example 17
Source File: DefaultValueAxisEditor.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Standard constructor: builds a property panel for the specified axis.
 *
 * @param axis  the axis, which should be changed.
 */
public DefaultValueAxisEditor(ValueAxis axis) {

    super(axis);

    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();
    this.autoTickUnitSelection = axis.isAutoTickUnitSelection();

    this.gridPaintSample = new PaintSample(Color.blue);
    this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f));

    this.availableStrokeSamples = new StrokeSample[3];
    this.availableStrokeSamples[0] = new StrokeSample(
            new BasicStroke(1.0f));
    this.availableStrokeSamples[1] = new StrokeSample(
            new BasicStroke(2.0f));
    this.availableStrokeSamples[2] = new StrokeSample(
            new BasicStroke(3.0f));

    JTabbedPane other = getOtherTabs();

    JPanel range = new JPanel(new LCBLayout(3));
    range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    range.add(new JPanel());
    this.autoRangeCheckBox = new JCheckBox(localizationResources.getString(
            "Auto-adjust_range"), this.autoRange);
    this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff");
    this.autoRangeCheckBox.addActionListener(this);
    range.add(this.autoRangeCheckBox);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Minimum_range_value")));
    this.minimumRangeValue = new JTextField(Double.toString(
            this.minimumValue));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    this.minimumRangeValue.setActionCommand("MinimumRange");
    this.minimumRangeValue.addActionListener(this);
    this.minimumRangeValue.addFocusListener(this);
    range.add(this.minimumRangeValue);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Maximum_range_value")));
    this.maximumRangeValue = new JTextField(Double.toString(
            this.maximumValue));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    this.maximumRangeValue.setActionCommand("MaximumRange");
    this.maximumRangeValue.addActionListener(this);
    this.maximumRangeValue.addFocusListener(this);
    range.add(this.maximumRangeValue);
    range.add(new JPanel());

    other.add(localizationResources.getString("Range"), range);

    other.add(localizationResources.getString("TickUnit"),
            createTickUnitPanel());
}
 
Example 18
Source File: DefaultValueAxisEditor.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Standard constructor: builds a property panel for the specified axis.
 *
 * @param axis  the axis, which should be changed.
 */
public DefaultValueAxisEditor(ValueAxis axis) {

    super(axis);

    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();
    this.autoTickUnitSelection = axis.isAutoTickUnitSelection();

    this.gridPaintSample = new PaintSample(Color.blue);
    this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f));

    this.availableStrokeSamples = new StrokeSample[3];
    this.availableStrokeSamples[0] = new StrokeSample(
            new BasicStroke(1.0f));
    this.availableStrokeSamples[1] = new StrokeSample(
            new BasicStroke(2.0f));
    this.availableStrokeSamples[2] = new StrokeSample(
            new BasicStroke(3.0f));

    JTabbedPane other = getOtherTabs();

    JPanel range = new JPanel(new LCBLayout(3));
    range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    range.add(new JPanel());
    this.autoRangeCheckBox = new JCheckBox(localizationResources.getString(
            "Auto-adjust_range"), this.autoRange);
    this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff");
    this.autoRangeCheckBox.addActionListener(this);
    range.add(this.autoRangeCheckBox);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Minimum_range_value")));
    this.minimumRangeValue = new JTextField(Double.toString(
            this.minimumValue));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    this.minimumRangeValue.setActionCommand("MinimumRange");
    this.minimumRangeValue.addActionListener(this);
    this.minimumRangeValue.addFocusListener(this);
    range.add(this.minimumRangeValue);
    range.add(new JPanel());

    range.add(new JLabel(localizationResources.getString(
            "Maximum_range_value")));
    this.maximumRangeValue = new JTextField(Double.toString(
            this.maximumValue));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    this.maximumRangeValue.setActionCommand("MaximumRange");
    this.maximumRangeValue.addActionListener(this);
    this.maximumRangeValue.addFocusListener(this);
    range.add(this.maximumRangeValue);
    range.add(new JPanel());

    other.add(localizationResources.getString("Range"), range);

    other.add(localizationResources.getString("TickUnit"),
            createTickUnitPanel());
}
 
Example 19
Source File: ChartLogics.java    From old-mzmine3 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Apply an relative offset to an axis and move it. LowerBound and UpperBound are defined by
 * {@link ValueAxis#getDefaultAutoRange()}
 * 
 * @param myChart
 * @param offset percentage
 */
public static void offsetAxis(ValueAxis axis, double offset) {
  double distance = (axis.getUpperBound() - axis.getLowerBound()) * offset;
  Range range = new Range(axis.getLowerBound() + distance, axis.getUpperBound() + distance);
  setZoomAxis(axis, keepRangeWithinAutoBounds(axis, range));
}
 
Example 20
Source File: ChartLogicsFX.java    From old-mzmine3 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Apply an relative offset to an axis and move it. LowerBound and UpperBound are defined by
 * {@link ValueAxis#getDefaultAutoRange()}
 * 
 * @param myChart
 * @param offset percentage
 */
public static void offsetAxis(ValueAxis axis, double offset) {
  double distance = (axis.getUpperBound() - axis.getLowerBound()) * offset;
  Range range = new Range(axis.getLowerBound() + distance, axis.getUpperBound() + distance);
  setZoomAxis(axis, keepRangeWithinAutoBounds(axis, range));
}