Пример #1
0
  private void elaborate(ParseNode newRoot) {
    (root = newRoot).doParent();
    if (root.badFlag) return;

    variables = new Hashtable<Object, Hashtable>();
    legalVariables = new Hashtable<String, Integer>();
    knowns = new Hashtable<String, Double>();
    knowns.put("pi", new Double(Math.PI));
    knowns.put("Pi", new Double(Math.PI));
    knowns.put("PI", new Double(Math.PI));
    parameters = new Hashtable<String, Double>();
    make_legalVariables();
    fixImpliedMultiplication(root);
    if (find_variables(root) == null) {
      theValue = null;
      variables = null;
      legalVariables = null;
      knowns = null;
      parameters = null;
      root = null;
      return;
    } // end if

    Hashtable h = (Hashtable) (variables.get(root));
    Enumeration k = h.keys();
    while (k.hasMoreElements()) {
      String var = (String) k.nextElement();
      // System.out.println(var);
      Double t = (Double) knowns.get(var);
      // System.out.println(t);

      if (t == null) continue;

      Vector v = (Vector) h.get(var);
      Enumeration e = v.elements();
      while (e.hasMoreElements()) {
        ParseNode pn = (ParseNode) e.nextElement();
        pn.value = t;
      } // end while
    } // end while

    for (Enumeration e = variables.keys(); e.hasMoreElements(); ) {
      Object r;
      h = (Hashtable) (variables.get(r = e.nextElement()));

      for (k = knowns.keys(); k.hasMoreElements(); ) h.remove(k.nextElement());

      variables.put(r, h);
    } // end for

    condenseConstants(root);

    if ((theValue = root.value) != null) {
      valueString = MathUtil.trimDouble(theValue.doubleValue(), 12);
    } // end if
    else valueString = null;

    varStrings = new SortedKeyStrings((Hashtable) (variables.get(root))).theKeys;
  } // end elaborate
  /**
   * Returns a string representation of this <code>MultiPointXY</code> object.
   *
   * @return a string representation of this <code>MultiPointXY</code> object.
   * @see java.lang.Object#toString()
   */
  public String toString() {
    StringBuffer b = new StringBuffer(16);
    b.append("x = ").append(MathUtil.trimDouble(x, numDigits)).append("\ny values:");

    int n = yArray.length;

    if (n == 0) {
      b.append("  (none)");
    } else {
      b.append("\n");
    }

    for (int i = 0; i < n; i++) {
      b.append(MathUtil.trimDouble(yArray[i], numDigits));
      if (i < n - 1) {
        b.append(", ");
      }
    } // end for i

    return b.toString();
  } // end toString