Package com.positive.charts.data

Examples of com.positive.charts.data.Range


  public static Range findRangeBounds(final CategoryDataset dataset,
      final boolean includeInterval) {
    if (dataset == null) {
      throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Range result = null;
    if (dataset instanceof RangeInfo) {
      final RangeInfo info = (RangeInfo) dataset;
      result = info.getRangeBounds(includeInterval);
    } else {
      result = iterateCategoryRangeBounds(dataset, includeInterval);
View Full Code Here


  public static Range findRangeBounds(final XYDataset dataset,
      final boolean includeInterval) {
    if (dataset == null) {
      throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Range result = null;
    if (dataset instanceof RangeInfo) {
      final RangeInfo info = (RangeInfo) dataset;
      result = info.getRangeBounds(includeInterval);
    } else {
      result = iterateXYRangeBounds(dataset);
View Full Code Here

  public static Range findStackedRangeBounds(final CategoryDataset dataset,
      final double base) {
    if (dataset == null) {
      throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Range result = null;
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    final int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
      double positive = base;
      double negative = base;
      final int seriesCount = dataset.getRowCount();
      for (int series = 0; series < seriesCount; series++) {
        final Number number = dataset.getValue(series, item);
        if (number != null) {
          final double value = number.doubleValue();
          if (value > 0.0) {
            positive = positive + value;
          }
          if (value < 0.0) {
            negative = negative + value;
            // '+', remember value is negative
          }
        }
      }
      minimum = Math.min(minimum, negative);
      maximum = Math.max(maximum, positive);
    }
    if (minimum <= maximum) {
      result = new Range(minimum, maximum);
    }
    return result;

  }
View Full Code Here

   * @return The value range (<code>null</code> if the dataset contains no
   *         values).
   */
  public static Range findStackedRangeBounds(final CategoryDataset dataset,
      final KeyToGroupMap map) {
    Range result = null;
    if (dataset != null) {

      // create an array holding the group indices...
      final int[] groupIndex = new int[dataset.getRowCount()];
      for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(dataset
            .getRowKey(i)));
      }

      // minimum and maximum for each group...
      final int groupCount = map.getGroupCount();
      final double[] minimum = new double[groupCount];
      final double[] maximum = new double[groupCount];

      final int categoryCount = dataset.getColumnCount();
      for (int item = 0; item < categoryCount; item++) {
        final double[] positive = new double[groupCount];
        final double[] negative = new double[groupCount];
        final int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
          final Number number = dataset.getValue(series, item);
          if (number != null) {
            final double value = number.doubleValue();
            if (value > 0.0) {
              positive[groupIndex[series]] = positive[groupIndex[series]]
                  + value;
            }
            if (value < 0.0) {
              negative[groupIndex[series]] = negative[groupIndex[series]]
                  + value;
              // '+', remember value is negative
            }
          }
        }
        for (int g = 0; g < groupCount; g++) {
          minimum[g] = Math.min(minimum[g], negative[g]);
          maximum[g] = Math.max(maximum[g], positive[g]);
        }
      }
      for (int j = 0; j < groupCount; j++) {
        result = Range.combine(result,
            new Range(minimum[j], maximum[j]));
      }
    }
    return result;

  }
View Full Code Here

      if (negative < minimum) {
        minimum = negative;
      }
    }
    if (minimum <= maximum) {
      return new Range(minimum, maximum);
    } else {
      return null;
    }
  }
View Full Code Here

      }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
      return null;
    } else {
      return new Range(minimum, maximum);
    }
  }
View Full Code Here

      }
    }
    if (minimum > maximum) {
      return null;
    } else {
      return new Range(minimum, maximum);
    }
  }
View Full Code Here

      }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
      return null;
    } else {
      return new Range(minimum, maximum);
    }
  }
View Full Code Here

   *
   */
  public void drawRangeGridline(final GC gc, final CategoryPlot plot,
      final ValueAxis axis, final Rectangle dataArea, final double value) {

    final Range range = axis.getRange();
    if (!range.contains(value)) {
      return;
    }

    final PlotOrientation orientation = plot.getOrientation();
    final double v = axis.valueToJava2D(value, dataArea, plot
View Full Code Here

    final RectangleAdapter dataArea = new RectangleAdapter(dataAreaRect);

    if (marker instanceof ValueMarker) {
      final ValueMarker vm = (ValueMarker) marker;
      final double value = vm.getValue();
      final Range range = axis.getRange();

      if (!range.contains(value)) {
        return;
      }

      // set alpha
      final int oldAlpha = gc.getAlpha();
      gc.setAlpha(marker.getAlpha());

      final PlotOrientation orientation = plot.getOrientation();
      final double v = axis.valueToJava2D(value, dataArea.getRectangle(),
          plot.getRangeAxisEdge());
      Line line = null;
      if (orientation == PlotOrientation.HORIZONTAL) {
        line = Line
            .Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
      } else if (orientation == PlotOrientation.VERTICAL) {
        line = Line
            .Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
      }

      gc.setForeground(marker.getPaint());
      marker.getStroke().set(gc);
      GCUtilities.draw(gc, line);

      final String label = marker.getLabel();
      final RectangleAnchor anchor = marker.getLabelAnchor();
      if (label != null) {
        final Font labelFont = marker.getLabelFont();
        gc.setFont(labelFont);
        gc.setForeground(marker.getLabelPaint());
        final Point coordinates = this
            .calculateRangeMarkerTextAnchorPoint(gc, orientation,
                dataArea.getRectangle(), line.getBounds(),
                marker.getLabelOffset(),
                LengthAdjustmentType.EXPAND, anchor);
        TextUtilities.drawAlignedString(label, gc, coordinates.x,
            coordinates.y, marker.getLabelTextAnchor());
      }

      gc.setAlpha(oldAlpha);
    } else if (marker instanceof IntervalMarker) {

      final IntervalMarker im = (IntervalMarker) marker;
      final double start = im.getStartValue();
      final double end = im.getEndValue();
      final Range range = axis.getRange();
      if (!(range.intersects(start, end))) {
        return;
      }

      final int oldAlpha = gc.getAlpha();
      gc.setAlpha(marker.getAlpha());
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.