コード例 #1
0
ファイル: LingDisplay.java プロジェクト: lizziesilver/tetrad
  private List<Integer> getAllIndices(Ling.StoredGraphs storedGraphs) {
    List<Integer> indices = new ArrayList<>();

    for (int i = 0; i < storedGraphs.getNumGraphs(); i++) {
      indices.add(i);
    }

    return indices;
  }
コード例 #2
0
ファイル: LingDisplay.java プロジェクト: lizziesilver/tetrad
  private List<Integer> getUnstableIndices(Ling.StoredGraphs storedGraphs) {
    List<Integer> indices = new ArrayList<>();

    for (int i = 0; i < storedGraphs.getNumGraphs(); i++) {
      if (!storedGraphs.isStable(i)) {
        indices.add(i);
      }
    }

    return indices;
  }
コード例 #3
0
ファイル: LingDisplay.java プロジェクト: lizziesilver/tetrad
  public LingDisplay(final Ling.StoredGraphs storedGraphs) {
    this.storedGraphs = storedGraphs;

    if (storedGraphs.getNumGraphs() == 0) {
      workbench = new GraphWorkbench();
    } else {
      workbench = new GraphWorkbench(storedGraphs.getGraph(0));
    }

    subsetIndices = getStableIndices(storedGraphs);

    final SpinnerNumberModel model =
        new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1);
    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int index = model.getNumber().intValue();
            workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
          }
        });

    spinner = new JSpinner();
    subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"});
    subsetCombo.setSelectedItem("Show Stable");
    spinner.setModel(model);
    totalLabel = new JLabel(" of " + subsetIndices.size());

    subsetCombo.setMaximumSize(subsetCombo.getPreferredSize());
    subsetCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetDisplay();
          }
        });

    spinner.setPreferredSize(new Dimension(50, 20));
    spinner.setMaximumSize(spinner.getPreferredSize());
    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    //        b1.add(Box.createHorizontalGlue());
    //        b1.add(Box.createHorizontalStrut(10));
    b1.add(subsetCombo);
    b1.add(Box.createHorizontalGlue());
    b1.add(new JLabel("DAG "));
    b1.add(spinner);
    b1.add(totalLabel);

    b.add(b1);

    Box b2 = Box.createHorizontalBox();
    JPanel graphPanel = new JPanel();
    graphPanel.setLayout(new BorderLayout());
    JScrollPane jScrollPane = new JScrollPane(workbench);
    //        jScrollPane.setPreferredSize(new Dimension(400, 400));
    graphPanel.add(jScrollPane);
    //        graphPanel.setBorder(new TitledBorder("DAG"));
    b2.add(graphPanel);
    b.add(b2);

    setLayout(new BorderLayout());
    //        add(menuBar(), BorderLayout.NORTH);
    add(b, BorderLayout.CENTER);
  }