Package com.positive.charts.data

Examples of com.positive.charts.data.Range


   *            into account.
   *
   * @return The range.
   */
  public Range getDomainBounds(final boolean includeInterval) {
    Range result = null;
    final Iterator iterator = this.data.iterator();
    while (iterator.hasNext()) {
      final TimeSeries series = (TimeSeries) iterator.next();
      final int count = series.getItemCount();
      if (count > 0) {
        final RegularTimePeriod start = series.getTimePeriod(0);
        final RegularTimePeriod end = series.getTimePeriod(count - 1);
        Range temp;
        if (!includeInterval) {
          temp = new Range(this.getX(start), this.getX(end));
        } else {
          temp = new Range(start
              .getFirstMillisecond(this.workingCalendar), end
              .getLastMillisecond(this.workingCalendar));
        }
        result = Range.combine(result, temp);
      }
View Full Code Here


   *
   * @return The minimum value.
   */
  public double getDomainLowerBound(final boolean includeInterval) {
    double result = Double.NaN;
    final Range r = this.getDomainBounds(includeInterval);
    if (r != null) {
      result = r.getLowerBound();
    }
    return result;
  }
View Full Code Here

   *
   * @return The maximum value.
   */
  public double getDomainUpperBound(final boolean includeInterval) {
    double result = Double.NaN;
    final Range r = this.getDomainBounds(includeInterval);
    if (r != null) {
      result = r.getUpperBound();
    }
    return result;
  }
View Full Code Here

   *
   * @return The range (or <code>null</code> if the dataset is
   *         <code>null</code> or empty).
   */
  public Range findRangeBounds(final CategoryDataset dataset) {
    Range result = DatasetUtilities.findRangeBounds(dataset);
    if (result != null) {
      if (this.includeBaseInRange) {
        result = Range.expandToInclude(result, this.base);
      }
    }
View Full Code Here

    }

    if (plot instanceof ValueAxisPlot) {
      final ValueAxisPlot vap = (ValueAxisPlot) plot;

      Range r = vap.getDataRange(this);
      if (r == null) {
        if (this.timeline instanceof SegmentedTimeline) {
          // Timeline hasn't method getStartTime()
          r = new DateRange(
              ((SegmentedTimeline) this.timeline).getStartTime(),
              ((SegmentedTimeline) this.timeline).getStartTime() + 1);
        } else {
          r = new DateRange();
        }
      }

      long upper = this.timeline
          .toTimelineValue((long) r.getUpperBound());
      long lower;
      final long fixedAutoRange = (long) this.getFixedAutoRange();
      if (fixedAutoRange > 0.0) {
        lower = upper - fixedAutoRange;
      } else {
        lower = this.timeline.toTimelineValue((long) r.getLowerBound());
        final double range = upper - lower;
        final long minRange = (long) this.getAutoRangeMinimumSize();
        if (range < minRange) {
          final long expand = (long) (minRange - range) / 2;
          upper = upper + expand;
View Full Code Here

   * @return The date.
   */
  public Date getMaximumDate() {

    Date result = null;
    final Range range = this.getRange();
    if (range instanceof DateRange) {
      final DateRange r = (DateRange) range;
      result = r.getUpperDate();
    } else {
      result = new Date((long) range.getUpperBound());
    }
    return result;

  }
View Full Code Here

   */
  public Date getMinimumDate() {

    Date result = null;

    final Range range = this.getRange();
    if (range instanceof DateRange) {
      final DateRange r = (DateRange) range;
      result = r.getLowerDate();
    } else {
      result = new Date((long) range.getLowerBound());
    }

    return result;

  }
View Full Code Here

    final double start = this.timeline.toTimelineValue((long) this
        .getRange().getLowerBound());
    final double length = (this.timeline.toTimelineValue((long) this
        .getRange().getUpperBound()) - this.timeline
        .toTimelineValue((long) this.getRange().getLowerBound()));
    Range adjusted = null;
    if (this.isInverted()) {
      adjusted = new DateRange(
          this.timeline
              .toMillisecond((long) (start + (length * (1 - upperPercent)))),
          this.timeline
View Full Code Here

   *            the center value.
   */
  public void centerRange(final double value) {

    final double central = this.range.getCentralValue();
    final Range adjusted = new Range(this.range.getLowerBound() + value
        - central, this.range.getUpperBound() + value - central);
    this.setRange(adjusted);

  }
View Full Code Here

    }

    if (plot instanceof ValueAxisPlot) {
      final ValueAxisPlot vap = (ValueAxisPlot) plot;

      Range r = vap.getDataRange(this);
      if (r == null) {
        r = new Range(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND);
      }

      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 (this.getAutoRangeIncludesZero()) {
        lower = Math.min(lower, 0.0);
        upper = Math.max(upper, 0.0);
      }
      final double range = upper - lower;

      // if fixed auto range, then derive lower bound...
      final double fixedAutoRange = this.getFixedAutoRange();
      if (fixedAutoRange > 0.0) {
        lower = upper - fixedAutoRange;
      } else {
        // ensure the autorange is at least <minRange> in size...
        final double minRange = this.getAutoRangeMinimumSize();
        if (range < minRange) {
          final double expand = (minRange - range) / 2;
          upper = upper + expand;
          lower = lower - expand;
          if (lower == upper) { // see bug report 1549218
            final 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 (this.getAutoRangeStickyZero()) {
          if (upper <= 0.0) {
            upper = Math.min(0.0, upper + this.getUpperMargin()
                * range);
          } else {
            upper = upper + this.getUpperMargin() * range;
          }
          if (lower >= 0.0) {
            lower = Math.max(0.0, lower - this.getLowerMargin()
                * range);
          } else {
            lower = lower - this.getLowerMargin() * range;
          }
        } else {
          upper = upper + this.getUpperMargin() * range;
          lower = lower - this.getLowerMargin() * range;
        }
      }

      this.setRange(new Range(lower, upper), false, false);
    }

  }
View Full Code Here

TOP

Related Classes of com.positive.charts.data.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.