/** Method with the actual generated action code. */
  public final java_cup.runtime.Symbol CUP$WavefunctionParser$do_action(
      int CUP$WavefunctionParser$act_num,
      java_cup.runtime.lr_parser CUP$WavefunctionParser$parser,
      java.util.Stack CUP$WavefunctionParser$stack,
      int CUP$WavefunctionParser$top)
      throws java.lang.Exception {
    /* Symbol object for return from actions */
    java_cup.runtime.Symbol CUP$WavefunctionParser$result;

    /* select the action based on the action number */
    switch (CUP$WavefunctionParser$act_num) {
        /*. . . . . . . . . . . . . . . . . . . .*/
      case 2: // scfintro ::= FOUNDITER RUNTYP
        {
          Object RESULT = null;
          if (DEBUG) System.out.println("CUP:WFparser: gaussian:  found FOUNDITER ");
          CUP$WavefunctionParser$result =
              new java_cup.runtime.Symbol(
                  2 /*scfintro*/,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$WavefunctionParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 1: // $START ::= startpt EOF
        {
          Object RESULT = null;
          int start_valleft =
              ((java_cup.runtime.Symbol)
                      CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 1))
                  .left;
          int start_valright =
              ((java_cup.runtime.Symbol)
                      CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 1))
                  .right;
          Object start_val =
              (Object)
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 1))
                      .value;
          RESULT = start_val;
          CUP$WavefunctionParser$result =
              new java_cup.runtime.Symbol(
                  0 /*$START*/,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 0))
                      .right,
                  RESULT);
        }
        /* ACCEPT */
        CUP$WavefunctionParser$parser.done_parsing();
        return CUP$WavefunctionParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 0: // startpt ::= scfintro
        {
          Object RESULT = null;
          if (DEBUG) System.out.println("CUP:WFParser: gaussian:  end of parse tree ");

          CUP$WavefunctionParser$result =
              new java_cup.runtime.Symbol(
                  1 /*startpt*/,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 0))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$WavefunctionParser$stack.elementAt(CUP$WavefunctionParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$WavefunctionParser$result;

        /* . . . . . .*/
      default:
        throw new Exception("Invalid action number found in internal parse table");
    }
  }
  /** Method with the actual generated action code. */
  public final java_cup.runtime.Symbol CUP$GMP2OPTParser$do_action(
      int CUP$GMP2OPTParser$act_num,
      java_cup.runtime.lr_parser CUP$GMP2OPTParser$parser,
      java.util.Stack CUP$GMP2OPTParser$stack,
      int CUP$GMP2OPTParser$top)
      throws java.lang.Exception {
    /* Symbol object for return from actions */
    java_cup.runtime.Symbol CUP$GMP2OPTParser$result;

    /* select the action based on the action number */
    switch (CUP$GMP2OPTParser$act_num) {
        /*. . . . . . . . . . . . . . . . . . . .*/
      case 10: // grad2 ::= RmsGrad RGRAD
        {
          Object RESULT = null;
          int rgleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .left;
          int rgright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .right;
          Float rg =
              (Float)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .value;
          // ___________________________________________________________________
          if (DEBUG) System.out.println("CUP:gopt: RMS Force " + rg);
          float rms = rg.floatValue();
          temp3.putField(rms);

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  7 /*grad2*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 9: // grad1 ::= MaxGrad MGRAD
        {
          Object RESULT = null;
          int mgleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .left;
          int mgright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .right;
          Float mg =
              (Float)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .value;
          // ___________________________________________________________________
          if (DEBUG) System.out.println("CUP:gopt: Maximum Force " + mg);
          float maxim = mg.floatValue();
          temp2.putField(maxim);

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  6 /*grad1*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 8: // cycle ::= NSearch ITERATION NT$1 grad1 grad2
        {
          Object RESULT = null;
          // propagate RESULT from NT$1
          if (((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                  .value
              != null)
            RESULT =
                (Object)
                    ((java_cup.runtime.Symbol)
                            CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                        .value;
          int cleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 3))
                  .left;
          int cright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 3))
                  .right;
          Integer c =
              (Integer)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 3))
                      .value;

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  5 /*cycle*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 4))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 7: // NT$1 ::=
        {
          Object RESULT = null;
          int cleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .left;
          int cright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .right;
          Integer c =
              (Integer)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .value;
          // ___________________________________________________________________
          if (DEBUG) System.out.println("CUP:gopt:  ITERATION " + c);
          int cycl = c.intValue();
          temp1.putField(cycl + 1);
          temp1.putField(", ");
          temp2.putField(cycl);
          temp2.putField(", ");
          temp3.putField(cycl);
          temp3.putField(", ");
          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  9 /*NT$1*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 6: // scfcycle ::= Energ ENERGY NT$0 cycle
        {
          Object RESULT = null;
          // propagate RESULT from NT$0
          if (((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                  .value
              != null)
            RESULT =
                (Object)
                    ((java_cup.runtime.Symbol)
                            CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                        .value;
          int eleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                  .left;
          int eright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                  .right;
          Float e =
              (Float)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                      .value;

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  4 /*scfcycle*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 3))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 5: // NT$0 ::=
        {
          Object RESULT = null;
          int eleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .left;
          int eright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                  .right;
          Float e =
              (Float)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .value;
          // ___________________________________________________________________
          if (DEBUG) System.out.println("CUP:gopt:  ENERGY " + e);
          float energ = e.floatValue();
          energ = 100 * energ;
          temp1.putField(energ);

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  8 /*NT$0*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 4: // scfpat ::= scfcycle
        {
          Object RESULT = null;

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  3 /*scfpat*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 3: // scfpat ::= scfpat scfcycle
        {
          Object RESULT = null;
          if (DEBUG) System.out.println("CUP:gopt: in scfpat");
          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  3 /*scfpat*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 2: // scfintro ::= FOUNDITER
        {
          Object RESULT = null;
          if (DEBUG) System.out.println("CUP:gopt:  found the start of Iteration");
          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  2 /*scfintro*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 1: // $START ::= startpt EOF
        {
          Object RESULT = null;
          int start_valleft =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                  .left;
          int start_valright =
              ((java_cup.runtime.Symbol)
                      CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                  .right;
          Object start_val =
              (Object)
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                      .value;
          RESULT = start_val;
          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  0 /*$START*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 1))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        /* ACCEPT */
        CUP$GMP2OPTParser$parser.done_parsing();
        return CUP$GMP2OPTParser$result;

        /*. . . . . . . . . . . . . . . . . . . .*/
      case 0: // startpt ::= scfintro scfpat SCFDONE
        {
          Object RESULT = null;
          if (DEBUG) System.out.println("CUP:gopt:  end of parse tree ");
          table = new JTable();

          //       table = parseSCF.getTable();

          CUP$GMP2OPTParser$result =
              new java_cup.runtime.Symbol(
                  1 /*startpt*/,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 2))
                      .left,
                  ((java_cup.runtime.Symbol)
                          CUP$GMP2OPTParser$stack.elementAt(CUP$GMP2OPTParser$top - 0))
                      .right,
                  RESULT);
        }
        return CUP$GMP2OPTParser$result;

        /* . . . . . .*/
      default:
        throw new Exception("Invalid action number found in internal parse table");
    }
  }
Exemple #3
0
  /** Set the current parameters to a given value. */
  public void updateParams(Value newParams) {
    if (this.params == newParams) return;

    this.params = newParams;
    Value.Structured params = (Value.Structured) this.params; // save us doing repeated typecasts.
    int numLeaves = findNumLeaves(params);
    int depth = findTreeDepth(params) + 1;

    setLayout(new GridLayout(numLeaves, depth));

    int currentDepth = 0; // Keep track of how deep into the tree we are
    int currentLeaf = 0; // Keep track of how many leaf noded have been placed so far.
    Component[][] component = new Component[depth][numLeaves];

    // Use a stack to keep track of parameters not yet drawn (could also be done recursively.)
    java.util.Stack paramStack = new java.util.Stack();
    paramStack.add(params);
    while (true) {
      Value.Structured currentParams = (Value.Structured) paramStack.pop();
      int splitAttribute = currentParams.intCmpnt(0);

      if (splitAttribute == -1) {
        Value.Structured subModelParams = (Value.Structured) currentParams.cmpnt(2);
        Value.Model subModel = (Value.Model) subModelParams.cmpnt(0);
        Value subParams = subModelParams.cmpnt(1);
        Component leaf = DualVisualiser.makeComponent(varName, parentName, subModel, subParams);

        component[currentDepth][currentLeaf] = leaf;

        currentLeaf++;

        if (currentLeaf < numLeaves) {
          while (component[currentDepth - 1][currentLeaf] == null) {
            currentDepth--;
          }
        }

      } else {
        Value.Vector paramVector = (Value.Vector) currentParams.cmpnt(2);
        for (int i = 0; i < paramVector.length(); i++) {
          Value.Structured elt = (Value.Structured) paramVector.elt(paramVector.length() - i - 1);
          paramStack.push(elt);
        }

        int x = currentLeaf;
        for (int value = 0; value < paramVector.length(); value++) {
          Value.Structured elt = (Value.Structured) paramVector.elt(value);
          int subLeaves = findNumLeaves(elt);
          Color colour = getColour(value);
          for (int j = 0; j < subLeaves; j++) {
            if (component[currentDepth][x] != null) {
              throw new RuntimeException(
                  "SHouldn't be overwriting! [" + currentDepth + "," + x + "]");
            }
            if (j == 0)
              component[currentDepth][x] =
                  new JLabel(currentParams.cmpnt(0).toString() + " = " + value);
            else component[currentDepth][x] = new JLabel("");
            component[currentDepth][x].setBackground(colour);
            ((JComponent) component[currentDepth][x]).setOpaque(true);
            x++;
          }
        }

        currentDepth++;
      }
      if (currentLeaf == numLeaves) break;
    }

    for (int i = 0; i < numLeaves; i++) {
      for (int j = 0; j < depth; j++) {
        //         if ( component[j][i] == null ) component[j][i] = new JLabel("("+j+","+i+")");
        if (component[j][i] == null) component[j][i] = new JLabel("");
        this.add(component[j][i]);
      }
    }
  }