Java Code Examples for org.jfree.data.Range#getUpperBound()
The following examples show how to use
org.jfree.data.Range#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: DefaultContourDataset.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Returns the maximum z-value within visible region of plot. * * @param x the x range. * @param y the y range. * * @return The z range. */ @Override public Range getZValueRange(Range x, Range y) { double minX = x.getLowerBound(); double minY = y.getLowerBound(); double maxX = x.getUpperBound(); double maxY = y.getUpperBound(); double zMin = 1.e20; double zMax = -1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.xValues[k].doubleValue() >= minX && this.xValues[k].doubleValue() <= maxX && this.yValues[k].doubleValue() >= minY && this.yValues[k].doubleValue() <= maxY) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); zMax = Math.max(zMax, this.zValues[k].doubleValue()); } } } return new Range(zMin, zMax); }
Example 2
Source File: DefaultContourDataset.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Returns the maximum z-value within visible region of plot. * * @param x the x range. * @param y the y range. * * @return The z range. */ public Range getZValueRange(Range x, Range y) { double minX = x.getLowerBound(); double minY = y.getLowerBound(); double maxX = x.getUpperBound(); double maxY = y.getUpperBound(); double zMin = 1.e20; double zMax = -1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.xValues[k].doubleValue() >= minX && this.xValues[k].doubleValue() <= maxX && this.yValues[k].doubleValue() >= minY && this.yValues[k].doubleValue() <= maxY) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); zMax = Math.max(zMax, this.zValues[k].doubleValue()); } } } return new Range(zMin, zMax); }
Example 3
Source File: ShortTextTitle.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Returns the content size for the title. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ @Override protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= widthRange.getUpperBound() && bounds.getHeight() <= heightRange.getUpperBound()) { return new Size2D(bounds.getWidth(), bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } }
Example 4
Source File: TimePeriodValuesCollection.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ @Override public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }
Example 5
Source File: AbstractBlock.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
private Range trimToContentWidth(Range r) { if (r == null) { return null; } double lowerBound = 0.0; double upperBound = Double.POSITIVE_INFINITY; if (r.getLowerBound() > 0.0) { lowerBound = trimToContentWidth(r.getLowerBound()); } if (r.getUpperBound() < Double.POSITIVE_INFINITY) { upperBound = trimToContentWidth(r.getUpperBound()); } return new Range(lowerBound, upperBound); }
Example 6
Source File: NumberAxis.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Estimates the maximum width of the tick labels, assuming the specified * tick unit is used. * <P> * Rather than computing the string bounds of every tick on the axis, we * just look at two values: the lower bound and the upper bound for the * axis. These two values will usually be representative. * * @param g2 the graphics device. * @param unit the tick unit to use for calculation. * * @return The estimated maximum width of the tick labels. */ protected double estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); if (isVerticalTickLabels()) { // all tick labels have the same width (equal to the height of the // font)... FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = getTickLabelFont().getLineMetrics("0", frc); result += lm.getHeight(); } else { // look at lower and upper bounds... FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); String lowerStr = ""; String upperStr = ""; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.valueToString(lower); upperStr = unit.valueToString(upper); } double w1 = fm.stringWidth(lowerStr); double w2 = fm.stringWidth(upperStr); result += Math.max(w1, w2); } return result; }
Example 7
Source File: XYBlockPixelSizeRenderer.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Returns the range of values the renderer requires to display all the items from the specified * dataset. * * @param dataset the dataset ({@code null} permitted). * * @return The range ({@code null} if the dataset is {@code null} or empty). * * @see #findDomainBounds(XYDataset) */ @Override public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtils.findRangeBounds(dataset, false); if (r == null) { return null; } else { return new Range(r.getLowerBound() + this.yOffset, r.getUpperBound() + this.blockHeight + this.yOffset); } } else { return null; } }
Example 8
Source File: ShortTextTitle.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the content size for the title. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= widthRange.getUpperBound() && bounds.getHeight() <= heightRange.getUpperBound()) { return new Size2D(bounds.getWidth(), bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } }
Example 9
Source File: TimeTableXYDataset.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }
Example 10
Source File: TimePeriodValuesCollection.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }
Example 11
Source File: XYBlockRenderer.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). * * @see #findRangeBounds(XYDataset) */ @Override public Range findDomainBounds(XYDataset dataset) { if (dataset == null) { return null; } Range r = DatasetUtilities.findDomainBounds(dataset, false); if (r == null) { return null; } return new Range(r.getLowerBound() + this.xOffset, r.getUpperBound() + this.blockWidth + this.xOffset); }
Example 12
Source File: IntervalXYDelegate.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }
Example 13
Source File: NumberAxis.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Converts a data value to a coordinate in Java2D space, assuming that the * axis runs along one edge of the specified dataArea. * <p> * Note that it is possible for the coordinate to fall outside the plotArea. * * @param value the data value. * @param area the area for plotting the data. * @param edge the axis location. * * @return The Java2D coordinate. * * @see #java2DToValue(double, Rectangle2D, RectangleEdge) */ @Override public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = range.getLowerBound(); double axisMax = range.getUpperBound(); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } }
Example 14
Source File: XYBlockPixelSizeRenderer.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Returns the lower and upper bounds (range) of the x-values in the specified dataset. * * @param dataset the dataset ({@code null} permitted). * * @return The range ({@code null} if the dataset is {@code null} or empty). * * @see #findRangeBounds(XYDataset) */ @Override public Range findDomainBounds(XYDataset dataset) { if (dataset == null) { return null; } Range r = DatasetUtils.findDomainBounds(dataset, false); if (r == null) { return null; } return new Range(r.getLowerBound() + this.xOffset, r.getUpperBound() + this.blockWidth + this.xOffset); }
Example 15
Source File: ManageZoomDialog.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** * Sets the current {@link PlotConfiguration} for this dialog. * * @param plotConfig */ private void setPlotConfiguration(PlotConfiguration plotConfig) { if (plotConfig == null) { throw new IllegalArgumentException("plotConfig must not be null!"); } Vector<RangeAxisConfig> rangeConfigsVector = new Vector<RangeAxisConfig>(); String selectedItem = String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()); for (RangeAxisConfig config : plotConfig.getRangeAxisConfigs()) { rangeConfigsVector.add(config); } rangeAxisSelectionCombobox.setModel(new DefaultComboBoxModel<>(rangeConfigsVector)); // reselect the previously selected RangeAxisConfig (if it is still there) if (selectedItem != null) { for (int i = 0; i < rangeAxisSelectionCombobox.getItemCount(); i++) { if (String.valueOf(rangeAxisSelectionCombobox.getItemAt(i)).equals(selectedItem)) { rangeAxisSelectionCombobox.setSelectedIndex(i); break; } } } // fill in values of current chart Plot plot = engine.getChartPanel().getChart().getPlot(); double domainLowerBound = 0; double domainUpperBound = 0; boolean disableDomainZoom = false; NumericalValueRange effectiveRange = engine.getPlotInstance().getPlotData().getDomainConfigManagerData() .getEffectiveRange(); if (plot instanceof XYPlot) { ValueAxis domainAxis = ((XYPlot) plot).getDomainAxis(); if (domainAxis != null) { Range range = domainAxis.getRange(); domainLowerBound = range.getLowerBound(); domainUpperBound = range.getUpperBound(); } else { if (effectiveRange != null) { domainLowerBound = effectiveRange.getLowerBound(); domainUpperBound = effectiveRange.getUpperBound(); } else { disableDomainZoom = true; } } } else { if (effectiveRange != null) { domainLowerBound = effectiveRange.getLowerBound(); domainUpperBound = effectiveRange.getUpperBound(); } else { disableDomainZoom = true; } } domainRangeLowerBoundField.setText(String.valueOf(domainLowerBound)); domainRangeUpperBoundField.setText(String.valueOf(domainUpperBound)); // happens on nominal domain axis domainRangeLowerBoundField.setEnabled(!disableDomainZoom); domainRangeUpperBoundField.setEnabled(!disableDomainZoom); updateValueRange(); updateColorValues(); }
Example 16
Source File: NumberAxis.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Rescales the axis to ensure that all data is visible. */ @Override protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = r.getLowerBound(); if (this.rangeType == RangeType.POSITIVE) { lower = Math.max(0.0, lower); upper = Math.max(0.0, upper); } else if (this.rangeType == RangeType.NEGATIVE) { lower = Math.min(0.0, lower); upper = Math.min(0.0, upper); } if (getAutoRangeIncludesZero()) { lower = Math.min(lower, 0.0); upper = Math.max(upper, 0.0); } double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = upper - fixedAutoRange; } else { // ensure the autorange is at least <minRange> in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; if (lower == upper) { // see bug report 1549218 double adjust = Math.abs(lower) / 10.0; lower = lower - adjust; upper = upper + adjust; } if (this.rangeType == RangeType.POSITIVE) { if (lower < 0.0) { upper = upper - lower; lower = 0.0; } } else if (this.rangeType == RangeType.NEGATIVE) { if (upper > 0.0) { lower = lower - upper; upper = 0.0; } } } if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + getUpperMargin() * range); } else { upper = upper + getUpperMargin() * range; } if (lower >= 0.0) { lower = Math.max(0.0, lower - getLowerMargin() * range); } else { lower = lower - getLowerMargin() * range; } } else { upper = upper + getUpperMargin() * range; lower = lower - getLowerMargin() * range; } } setRange(new Range(lower, upper), false, false); } }
Example 17
Source File: LogAxis.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Adjusts the axis range to match the data range that the axis is * required to display. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = Math.max(r.getLowerBound(), this.smallestValue); double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = Math.max(upper - fixedAutoRange, this.smallestValue); } else { // ensure the autorange is at least <minRange> in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; } // apply the margins - these should apply to the exponent range double logUpper = calculateLog(upper); double logLower = calculateLog(lower); double logRange = logUpper - logLower; logUpper = logUpper + getUpperMargin() * logRange; logLower = logLower - getLowerMargin() * logRange; upper = calculateValue(logUpper); lower = calculateValue(logLower); } setRange(new Range(lower, upper), false, false); } }
Example 18
Source File: LogAxis.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Adjusts the axis range to match the data range that the axis is * required to display. */ @Override protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = Math.max(r.getLowerBound(), this.smallestValue); double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = Math.max(upper - fixedAutoRange, this.smallestValue); } else { // ensure the autorange is at least <minRange> in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; } // apply the margins - these should apply to the exponent range double logUpper = calculateLog(upper); double logLower = calculateLog(lower); double logRange = logUpper - logLower; logUpper = logUpper + getUpperMargin() * logRange; logLower = logLower - getLowerMargin() * logRange; upper = calculateValueNoINF(logUpper); lower = calculateValueNoINF(logLower); } setRange(new Range(lower, upper), false, false); } }
Example 19
Source File: RectangleConstraint.java From buffer_bci with GNU General Public License v3.0 | 3 votes |
/** * Returns a constraint that matches this one on the height attributes, * but has a range width constraint. * * @param range the width range (<code>null</code> not permitted). * * @return A new constraint. */ public RectangleConstraint toRangeWidth(Range range) { ParamChecks.nullNotPermitted(range, "range"); return new RectangleConstraint(range.getUpperBound(), range, LengthConstraintType.RANGE, this.height, this.heightRange, this.heightConstraintType); }
Example 20
Source File: DateRange.java From openstock with GNU General Public License v3.0 | 2 votes |
/** * Constructs a new range that is based on another {@link Range}. The * other range does not have to be a {@link DateRange}. If it is not, the * upper and lower bounds are evaluated as milliseconds since midnight * GMT, 1-Jan-1970. * * @param other the other range (<code>null</code> not permitted). */ public DateRange(Range other) { this(other.getLowerBound(), other.getUpperBound()); }