/** get CharacterState at node N */
 public CharacterState getCharacterState(CharacterState cs, int ic, int it) {
   ContinuousState c;
   if (cs != null && cs instanceof ContinuousState) c = (ContinuousState) cs;
   else c = new ContinuousState();
   c.setItemsAs(this);
   for (int item = 0; item < getNumberOfItems(); item++) c.setValue(item, getState(ic, it, item));
   return c;
 }
  /**
   * 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();
  }