Package CLIPSJNI

Examples of CLIPSJNI.FactAddressValue


    List<FactAddressValue> currentStateList = currentStateMultifieldValue
        .multifieldValue();
    if (currentStateList.isEmpty()) {
      return;
    }
    FactAddressValue currentState = currentStateList.get(0);

    assertedName = currentState.getFactSlot("name").toString();
    if (assertedName.contentEquals(lastAssertedName)) {
      clips.run(1);
      nextUIState();
      return;
    }
    lastAssertedName = assertedName;

    if (currentState.getFactSlot("state").toString().equals("final")) {
      nextButton.setActionCommand("restart");
      nextButton.setText(properties.getProperty("RESTART").toString());

      MultifieldValue citiesMultifieldValue = (MultifieldValue) clips
          .eval("(find-all-facts ((?f result)) TRUE)");
      List<FactAddressValue> cityList = citiesMultifieldValue
          .multifieldValue();

      if (!cityList.isEmpty()) {
        textPane.setText(properties.getProperty("RESULTS_END_TEXT")
            .toString());

        String headers[] = { properties.getProperty("CITIES") };

        ArrayList<Result> resultList = new ArrayList<Result>();
        for (FactAddressValue city : cityList) {
          resultList.add(new Result(city.getFactSlot("city")
              .getValue().toString()));
        }

        Collections.sort(resultList, new ResultComparator());

        String data[][] = new String[resultList.size()][1];
        int i = 0;
        for (Result result : resultList) {
          data[i][0] = result.getName();

          if (i == 0) {
            displayImage(result.getImage());
          }

          String newName = data[i++][0];
          System.out.println(newName);
        }

        answersTable = new JTable(data, headers);
        answersTable.getTableHeader().setReorderingAllowed(false);
        answersTable.setEnabled(false);

        JScrollPane scrollPane = new JScrollPane(answersTable);

        answerPanel.add(scrollPane);
        frame.pack();
      } else {
        textPane.setText(properties.getProperty("NO_RESULTS_END_TEXT")
            .toString());
      }

      answerPanel.repaint();
      return;
    } else if (currentState.getFactSlot("state").toString()
        .equals("initial")) {
      displayImage(null);
      nextButton.setActionCommand("start");
      nextButton.setText(properties.getProperty("START").toString());
    } else {
      nextButton.setActionCommand("next");
      nextButton.setText(properties.getProperty("NEXT").toString());
    }

    String text = ((SymbolValue) currentState.getFactSlot("text"))
        .lexemeValue();
    textPane.setText(properties.getProperty(text).toString());

    boolean checkboxes = false;
    if (currentState.getFactSlot("answerType").toString()
        .equals("checkBox")) {
      checkboxes = true;

    }

    answerPanel.removeAll();
    answerButtons = !checkboxes ? new ButtonGroup() : null;

    MultifieldValue answersMultifieldValue = (MultifieldValue) currentState
        .getFactSlot("answers");
    List<PrimitiveValue> answersList = answersMultifieldValue
        .multifieldValue();

    for (PrimitiveValue answer : answersList) {
      JToggleButton button;
      if (checkboxes) {
        button = new JCheckBox(properties
            .getProperty(answer.toString()).toString(), false);
        concatenate = true;
      } else {
        button = new JRadioButton(properties.getProperty(
            answer.toString()).toString(), false);
        concatenate = false;
      }

      MultifieldValue selectedMultifieldValue = (MultifieldValue) currentState
          .getFactSlot("selected");
      List<PrimitiveValue> selectedList = selectedMultifieldValue
          .multifieldValue();
      for (PrimitiveValue selected : selectedList) {
        if (answer.toString().equals(selected.toString())) {
View Full Code Here

TOP

Related Classes of CLIPSJNI.FactAddressValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.