org.jfree.data.Range.getLength()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.jfree.data.Range.getLength方法的一些代码示例,展示了Range.getLength的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.getLength方法的具体详情如下:
包路径:org.jfree.data.Range
类名称:Range
方法名:getLength

Range.getLength介绍

[英]Returns the length of the range.
[中]返回范围的长度。

代码示例

代码示例来源:origin: jfree/jfreechart

/**
 * Translates a data value to an angle on the dial.
 *
 * @param value  the value.
 *
 * @return The angle on the dial.
 */
public double valueToAngle(double value) {
  value = value - this.range.getLowerBound();
  double baseAngle = 180 + ((this.meterAngle - 180) / 2);
  return baseAngle - ((value / this.range.getLength()) * this.meterAngle);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Translates a data value to an angle on the dial.
 *
 * @param value  the value.
 *
 * @return The angle on the dial.
 */
public double valueToAngle(double value) {
  value = value - this.range.getLowerBound();
  double baseAngle = 180 + ((this.meterAngle - 180) / 2);
  return baseAngle - ((value / this.range.getLength()) * this.meterAngle);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Maps a data value into the fixed range.
 *
 * @param value  the value.
 *
 * @return The mapped value.
 */
private double mapValueToFixedRange(double value) {
  double lower = this.fixedRange.getLowerBound();
  double length = this.fixedRange.getLength();
  if (value < lower) {
    return lower + length + ((value - lower) % length);
  }
  else {
    return lower + ((value - lower) % length);
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Maps a data value into the fixed range.
 *
 * @param value  the value.
 *
 * @return The mapped value.
 */
private double mapValueToFixedRange(double value) {
  double lower = this.fixedRange.getLowerBound();
  double length = this.fixedRange.getLength();
  if (value < lower) {
    return lower + length + ((value - lower) % length);
  }
  else {
    return lower + ((value - lower) % length);
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Sets the range for the dial and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @param range  the range (<code>null</code> not permitted and zero-length
 *               ranges not permitted).
 *
 * @see #getRange()
 */
public void setRange(Range range) {
  if (range == null) {
    throw new IllegalArgumentException("Null 'range' argument.");
  }
  if (!(range.getLength() > 0.0)) {
    throw new IllegalArgumentException(
        "Range length must be positive.");
  }
  this.range = range;
  fireChangeEvent();
}

代码示例来源:origin: jfree/jfreechart

/**
 * Sets the range for the dial and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @param range  the range ({@code null} not permitted and zero-length
 *               ranges not permitted).
 *
 * @see #getRange()
 */
public void setRange(Range range) {
  Args.nullNotPermitted(range, "range");
  if (!(range.getLength() > 0.0)) {
    throw new IllegalArgumentException(
        "Range length must be positive.");
  }
  this.range = range;
  fireChangeEvent();
}

代码示例来源:origin: senbox-org/snap-desktop

private Range getNewPlotBounds(Range bounds) {
  double range = bounds.getLength();
  double delta = range * relativePlotInset;
  return new Range(Math.max(0, bounds.getLowerBound() - delta),
           bounds.getUpperBound() + delta);
}

代码示例来源:origin: bcdev/beam

private Range getNewPlotBounds(Range bounds) {
  double range = bounds.getLength();
  double delta = range * relativePlotInset;
  return new Range(Math.max(0, bounds.getLowerBound() - delta),
           bounds.getUpperBound() + delta);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Increases or decreases the axis range by the specified percentage about
 * the specified anchor value and sends an {@link AxisChangeEvent} to all
 * registered listeners.
 * <P>
 * To double the length of the axis range, use 200% (2.0).
 * To halve the length of the axis range, use 50% (0.5).
 *
 * @param percent  the resize factor.
 * @param anchorValue  the new central value after the resize.
 *
 * @see #resizeRange(double)
 */
public void resizeRange(double percent, double anchorValue) {
  if (percent > 0.0) {
    double halfLength = this.range.getLength() * percent / 2;
    Range adjusted = new Range(anchorValue - halfLength,
        anchorValue + halfLength);
    setRange(adjusted);
  }
  else {
    setAutoRange(true);
  }
}

代码示例来源:origin: jfree/jfreechart

/**
 * Zooms in on the current range.
 *
 * @param lowerPercent  the new lower bound.
 * @param upperPercent  the new upper bound.
 */
public void zoomRange(double lowerPercent, double upperPercent) {
  double start = this.range.getLowerBound();
  double length = this.range.getLength();
  double r0, r1;
  if (isInverted()) {
    r0 = start + (length * (1 - upperPercent));
    r1 = start + (length * (1 - lowerPercent));
  }
  else {
    r0 = start + length * lowerPercent;
    r1 = start + length * upperPercent;
  }
  if ((r1 > r0) && !Double.isInfinite(r1 - r0)) {
    setRange(new Range(r0, r1));
  }
}

代码示例来源:origin: jfree/jfreechart

/**
 * Slides the axis range by the specified percentage.
 *
 * @param percent  the percentage.
 *
 * @since 1.0.13
 */
public void pan(double percent) {
  Range r = getRange();
  double length = range.getLength();
  double adj = length * percent;
  double lower = r.getLowerBound() + adj;
  double upper = r.getUpperBound() + adj;
  setRange(lower, upper);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Slides the axis range by the specified percentage.
 *
 * @param percent  the percentage.
 *
 * @since 1.0.13
 */
public void pan(double percent) {
  Range range = getRange();
  double length = range.getLength();
  double adj = length * percent;
  double lower = range.getLowerBound() + adj;
  double upper = range.getUpperBound() + adj;
  setRange(lower, upper);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Selects a tick unit when the axis is displayed horizontally.
 *
 * @param g2  the graphics device.
 * @param drawArea  the drawing area.
 * @param dataArea  the data area.
 * @param edge  the side of the rectangle on which the axis is displayed.
 */
protected void selectHorizontalAutoTickUnit(Graphics2D g2,
    Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) {
  double tickLabelWidth
    = estimateMaximumTickLabelWidth(g2, getTickUnit());
  // Compute number of labels
  double n = getRange().getLength()
        * tickLabelWidth / dataArea.getWidth();
  setTickUnit(
      (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n),
      false, false);
 }

代码示例来源:origin: jfree/jfreechart

/**
 * Selects a tick unit when the axis is displayed vertically.
 *
 * @param g2  the graphics device.
 * @param drawArea  the drawing area.
 * @param dataArea  the data area.
 * @param edge  the side of the rectangle on which the axis is displayed.
 */
protected void selectVerticalAutoTickUnit(Graphics2D g2,
    Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) {
  double tickLabelWidth
    = estimateMaximumTickLabelWidth(g2, getTickUnit());
  // Compute number of labels
  double n = getRange().getLength()
        * tickLabelWidth / dataArea.getHeight();
  setTickUnit(
    (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n),
    false, false);
 }

代码示例来源:origin: jfree/jfreechart

/**
 * Creates a new range by adding margins to an existing range.
 *
 * @param range  the range ({@code null} not permitted).
 * @param lowerMargin  the lower margin (expressed as a percentage of the
 *                     range length).
 * @param upperMargin  the upper margin (expressed as a percentage of the
 *                     range length).
 *
 * @return The expanded range.
 */
public static Range expand(Range range,
              double lowerMargin, double upperMargin) {
  Args.nullNotPermitted(range, "range");
  double length = range.getLength();
  double lower = range.getLowerBound() - length * lowerMargin;
  double upper = range.getUpperBound() + length * upperMargin;
  if (lower > upper) {
    lower = lower / 2.0 + upper / 2.0;
    upper = lower;
  }
  return new Range(lower, upper);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Zooms in on the current range.
 *
 * @param lowerPercent  the new lower bound.
 * @param upperPercent  the new upper bound.
 */
public void zoomRange(double lowerPercent, double upperPercent) {
  double start = this.range.getLowerBound();
  double length = this.range.getLength();
  Range adjusted = null;
  if (isInverted()) {
    adjusted = new Range(start + (length * (1 - upperPercent)),
               start + (length * (1 - lowerPercent)));
  }
  else {
    adjusted = new Range(start + length * lowerPercent,
        start + length * upperPercent);
  }
  setRange(adjusted);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Zooms (in or out) on the plot's value axis.
 * <p>
 * If the value 0.0 is passed in as the zoom percent, the auto-range
 * calculation for the axis is restored (which sets the range to include
 * the minimum and maximum data values, thus displaying all the data).
 *
 * @param percent  the zoom amount.
 */
@Override
public void zoom(double percent) {
  if (percent > 0.0) {
    double range = getRangeAxis().getRange().getLength();
    double scaledRange = range * percent;
    getRangeAxis().setRange(this.anchorValue - scaledRange / 2.0,
        this.anchorValue + scaledRange / 2.0);
  }
  else {
    getRangeAxis().setAutoRange(true);
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Zooms (in or out) on the plot's value axis.
 * <p>
 * If the value 0.0 is passed in as the zoom percent, the auto-range
 * calculation for the axis is restored (which sets the range to include
 * the minimum and maximum data values, thus displaying all the data).
 *
 * @param percent  the zoom amount.
 */
public void zoom(double percent) {
  if (percent > 0.0) {
    double range = getRangeAxis().getRange().getLength();
    double scaledRange = range * percent;
    getRangeAxis().setRange(this.anchorValue - scaledRange / 2.0,
        this.anchorValue + scaledRange / 2.0);
  }
  else {
    getRangeAxis().setAutoRange(true);
  }
}

代码示例来源:origin: jfree/jfreechart

/**
 * Pans the domain axes by the specified percentage.
 *
 * @param percent  the distance to pan (as a percentage of the axis length).
 * @param info the plot info
 * @param source the source point where the pan action started.
 *
 * @since 1.0.13
 */
@Override
public void panDomainAxes(double percent, PlotRenderingInfo info,
    Point2D source) {
  if (!isDomainPannable() || this.domainAxis == null) {
    return;
  }
  double length = this.domainAxis.getRange().getLength();
  double adj = percent * length;
  if (this.domainAxis.isInverted()) {
    adj = -adj;
  }
  this.domainAxis.setRange(this.domainAxis.getLowerBound() + adj,
      this.domainAxis.getUpperBound() + adj);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Pans the range axes by the specified percentage.
 *
 * @param percent  the distance to pan (as a percentage of the axis length).
 * @param info the plot info
 * @param source the source point where the pan action started.
 *
 * @since 1.0.13
 */
@Override
public void panRangeAxes(double percent, PlotRenderingInfo info,
    Point2D source) {
  if (!isRangePannable() || this.rangeAxis == null) {
    return;
  }
  double length = this.rangeAxis.getRange().getLength();
  double adj = percent * length;
  if (this.rangeAxis.isInverted()) {
    adj = -adj;
  }
  this.rangeAxis.setRange(this.rangeAxis.getLowerBound() + adj,
      this.rangeAxis.getUpperBound() + adj);
}

相关文章