コード例 #1
0
    public EquationLogItemPanel(EquationLogItem equationLogItem) {
      myEquationLogItem = equationLogItem;

      setLayout(new GridBagLayout());
      setBackground(Color.WHITE);

      GridBagConstraints constraints = new GridBagConstraints();
      constraints.gridy = 0;
      constraints.weighty = 0;
      constraints.weightx = 0;
      constraints.fill = GridBagConstraints.NONE;
      constraints.anchor = GridBagConstraints.NORTHWEST;

      JLabel label = new JLabel("equation");
      add(label, constraints);

      constraints.gridx = 1;
      SNodeTree leftTree = new SNodeTree(myEquationLogItem.getLeftRepresentator());
      add(leftTree, constraints);

      constraints.gridx = 2;
      SNodeTree rightTree = new SNodeTree(myEquationLogItem.getRightRepresentator());
      add(rightTree, constraints);

      constraints.gridx = 3;
      constraints.weightx = 1;
      JLabel reasonLabel = new JLabel(myEquationLogItem.getReason());
      reasonLabel.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              if (e.getClickCount() == 2) {
                String ruleModel = myEquationLogItem.getRuleModel();
                final String ruleID = myEquationLogItem.getRuleId();
                openRule(ruleModel, ruleID);
              }
            }
          });
      add(reasonLabel, constraints);

      List<Pair<String, String>> causes = myEquationLogItem.getCauses();
      if (!causes.isEmpty()) {
        constraints.gridx = 4;
        constraints.weightx = 0;
        CausesTree causesTree = new CausesTree(causes);
        add(causesTree, constraints);
        causesTree.rebuildNow();
      }

      leftTree.rebuildNow();
      rightTree.rebuildNow();
    }
コード例 #2
0
  private void addEquationLog(
      JPanel panel, GridBagConstraints constraints, final EquationLogItem item) {
    constraints.weightx = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.NORTHWEST;

    constraints.gridx = 0;
    JLabel label = new JLabel("equation");
    panel.add(label, constraints);

    constraints.gridx = 1;
    SNodeTree leftTree = new SNodeTree(item.getLeftRepresentator());
    panel.add(leftTree, constraints);

    constraints.gridx = 2;
    SNodeTree rightTree = new SNodeTree(item.getRightRepresentator());
    panel.add(rightTree, constraints);

    constraints.gridx = 3;
    constraints.weightx = 1;
    JLabel reasonLabel = new JLabel(item.getReason());
    reasonLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 2) {
              String ruleModel = item.getRuleModel();
              final String ruleID = item.getRuleId();
              openRule(ruleModel, ruleID);
            }
          }
        });
    panel.add(reasonLabel, constraints);

    List<Pair<String, String>> causes = item.getCauses();
    constraints.gridx = 4;
    constraints.weightx = 0;
    if (!causes.isEmpty()) {

      CausesTree causesTree = new CausesTree(causes);
      panel.add(causesTree, constraints);
      causesTree.rebuildNow();
    } else {
      add(new JLabel(""), constraints);
    }

    leftTree.rebuildNow();
    rightTree.rebuildNow();
  }