Ejemplo n.º 1
0
 /**
  * This method sets the automatically computed colors for the legend. Use setCustom(...) to set
  * custom colors.
  *
  * @param colors
  */
 public void setComputedColors(List<Integer> colors) {
   if (mColors != null && colors.size() == mColors.length) {
     Utils.copyIntegers(colors, mColors);
   } else {
     mColors = Utils.convertIntegers(colors);
   }
 }
Ejemplo n.º 2
0
  /**
   * Sets a custom legend's labels and colors arrays. The colors count should match the labels
   * count. * Each color is for the form drawn at the same index. * A null label will start a group.
   * * A ColorTemplate.COLOR_SKIP color will avoid drawing a form This will disable the feature that
   * automatically calculates the legend labels and colors from the datasets. Call resetCustom() to
   * re-enable automatic calculation (and then notifyDataSetChanged() is needed to auto-calculate
   * the legend again)
   */
  public void setCustom(List<Integer> colors, List<String> labels) {

    if (colors.size() != labels.size()) {
      throw new IllegalArgumentException("colors array and labels array need to be of same size");
    }

    mColors = Utils.convertIntegers(colors);
    mLabels = Utils.convertStrings(labels);
    mIsLegendCustom = true;
  }
Ejemplo n.º 3
0
  /**
   * Colors and labels that will be appended to the end of the auto calculated colors and labels
   * arrays after calculating the legend. (if the legend has already been calculated, you will need
   * to call notifyDataSetChanged() to let the changes take effect)
   */
  public void setExtra(List<Integer> colors, List<String> labels) {
    if (mExtraColors != null && mExtraColors.length == colors.size()) {
      Utils.copyIntegers(colors, mExtraColors);
    } else {
      this.mExtraColors = Utils.convertIntegers(colors);
    }

    if (mExtraLabels != null && mExtraLabels.length == labels.size()) {
      Utils.copyStrings(labels, mExtraLabels);
    } else {
      this.mExtraLabels = Utils.convertStrings(labels);
    }
  }
Ejemplo n.º 4
0
  /**
   * Constructor. Provide colors and labels for the legend.
   *
   * @param colors
   * @param labels
   */
  public Legend(List<Integer> colors, List<String> labels) {
    this();

    if (colors == null || labels == null) {
      throw new IllegalArgumentException("colors array or labels array is NULL");
    }

    if (colors.size() != labels.size()) {
      throw new IllegalArgumentException("colors array and labels array need to be of same size");
    }

    this.mColors = Utils.convertIntegers(colors);
    this.mLabels = Utils.convertStrings(labels);
  }