Ejemplo n.º 1
0
  /**
   * Places into Color array the colors at the node, and returns the number of colors. Uses passed
   * stateColors as color key. If null is passed, uses color system of parent data (using maxState
   * of this StsOfCharcter) or, if there is not parent data object, the default colors.
   */
  public int getColorsAtNode(
      int node, ColorDistribution colors, MesquiteColorTable stateColors, boolean showWeights) {
    int numBinBoundaries = 10;
    double[] binBoundaries = stateColors.getPreferredBinBoundaries();
    if (binBoundaries != null) numBinBoundaries = binBoundaries.length;
    for (int i = 0; i < 10; i++) colors.initialize();
    if (getNumItems() == 1) {
      double s = firstItem.getValue(node);
      colors.setWeight(0, 1.0);
      if (!MesquiteDouble.isCombinable(s)) colors.setColor(0, ColorDistribution.unassigned);
      else {
        int place =
            getPlace(s, stateColors); // (int)(((s-minState)/(maxState-minState))*numBinBoundaries);
        colors.setColor(0, stateColors.getColor(numBinBoundaries, place));
      }
    } else {
      for (int i = 0; i < getNumItems(); i++) {
        double s = getState(node, i);
        colors.setWeight(i, 1.0 / getNumItems());
        if (!MesquiteDouble.isCombinable(s)) colors.setColor(0, ColorDistribution.unassigned);
        else {
          int place =
              getPlace(
                  s, stateColors); // (int)(((s-minState)/(maxState-minState))*numBinBoundaries);
          colors.setColor(i, stateColors.getColor(numBinBoundaries, place));
        }
      }
    }

    return getNumItems();
  }
Ejemplo n.º 2
0
  /**
   * places into the already instantiated ColorDistribution the colors corresponding to the
   * CharacterState, and returns the number of colors. Uses default colors. Mode is
   * MesquiteColorTable.GRAYSCALE, COLORS, COLORS_NO_BW, or DEFAULT (default depends on subclass)
   */
  public int getColorsOfState(
      CharacterState state, ColorDistribution colors, MesquiteColorTable colorTable) {
    if (colors == null || state == null || !(state instanceof ContinuousState)) return 0;
    int numBinBoundaries = 10;
    double[] binBoundaries = colorTable.getPreferredBinBoundaries();
    if (binBoundaries != null) numBinBoundaries = binBoundaries.length;
    colors.initialize();
    ContinuousState cState = (ContinuousState) state;
    if (cState.getNumItems() == 1) {
      double s = cState.getValue(0);
      colors.setWeight(0, 1.0);
      if (!MesquiteDouble.isCombinable(s)) colors.setColor(0, Color.white);
      else {
        int place =
            getPlace(s, colorTable); // (int)(((s-minState)/(maxState-minState))*numBinBoundaries);
        colors.setColor(
            0,
            colorTable.getColor(
                numBinBoundaries, place)); // bug fixed in 1. 12 that had been introduced in 1. 10
        // colors.setColor(0, colorTable.getColor(s, minState, maxState));  1.10 to 1.11
      }
    } else {
      for (int i = 0; i < cState.getNumItems(); i++) {
        double s = cState.getValue(i);
        colors.setWeight(i, 1.0 / cState.getNumItems());
        if (!MesquiteDouble.isCombinable(s)) colors.setColor(0, Color.white);
        else {
          int place =
              getPlace(
                  s, colorTable); // (int)(((s-minState)/(maxState-minState))*numBinBoundaries);
          colors.setColor(
              i,
              colorTable.getColor(
                  numBinBoundaries, place)); // bug fixed in 1. 12 that had been introduced in 1. 10
          // colors.setColor(i, colorTable.getColor(s, minState, maxState));  1.10 to 1.11
        }
      }
    }

    return cState.getNumItems();
  }