/** * 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); }
/** * 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); }
/** * 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); } }
/** * 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); } }
/** * 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(); }
/** * 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(); }
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); }
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); }
/** * 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); } }
/** * 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)); } }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); } }
/** * 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); } }
/** * 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); }
/** * 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); }