Package com.positive.charts.data

Examples of com.positive.charts.data.DefaultKeyedValues


   */
  public static KeyedValues getCumulativePercentages(final KeyedValues data) {
    if (data == null) {
      throw new IllegalArgumentException("Null 'data' argument.");
    }
    final DefaultKeyedValues result = new DefaultKeyedValues();
    double total = 0.0;
    for (int i = 0; i < data.getItemCount(); i++) {
      final Number v = data.getValue(i);
      if (v != null) {
        total = total + v.doubleValue();
      }
    }
    double runningTotal = 0.0;
    for (int i = 0; i < data.getItemCount(); i++) {
      final Number v = data.getValue(i);
      if (v != null) {
        runningTotal = runningTotal + v.doubleValue();
      }
      result.addValue(data.getKey(i), new Double(runningTotal / total));
    }
    return result;
  }
View Full Code Here


  /**
   * Constructs a new dataset, initially empty.
   */
  public DefaultPieDataset() {
    this.data = new DefaultKeyedValues();
  }
View Full Code Here

   */
  public DefaultPieDataset(final KeyedValues data) {
    if (data == null) {
      throw new IllegalArgumentException("Null 'data' argument.");
    }
    this.data = new DefaultKeyedValues();
    for (int i = 0; i < data.getItemCount(); i++) {
      this.data.addValue(data.getKey(i), data.getValue(i));
    }
  }
View Full Code Here

    // Composite originalComposite = g2.getComposite();
    // g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    // 1.0f));

    // classify the keys according to which side the label will appear...
    final DefaultKeyedValues leftKeys = new DefaultKeyedValues();
    final DefaultKeyedValues rightKeys = new DefaultKeyedValues();

    double runningTotal = 0.0;
    final Iterator iterator = keys.iterator();
    while (iterator.hasNext()) {
      final Comparable key = (Comparable) iterator.next();
      boolean include = true;
      double v = 0.0;
      final Number n = this.dataset.getValue(key);
      if (n == null) {
        include = !this.ignoreNullValues;
      } else {
        v = n.doubleValue();
        include = this.ignoreZeroValues ? v > 0.0 : v >= 0.0;
      }

      if (include) {
        runningTotal = runningTotal + v;
        // work out the mid angle (0 - 90 and 270 - 360) = right,
        // otherwise left
        final double mid = this.startAngle
            + (this.direction.getFactor()
                * ((runningTotal - v / 2.0) * 360) / totalValue);
        if (Math.cos(Math.toRadians(mid)) < 0.0) {
          leftKeys.addValue(key, new Double(mid));
        } else {
          rightKeys.addValue(key, new Double(mid));
        }
      }
    }

    g2.setFont(this.getLabelFont());
View Full Code Here

TOP

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

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.