示例#1
0
 public void layoutByKnowledge() {
   GraphWorkbench resultWorkbench = getWorkbench();
   Graph graph = resultWorkbench.getGraph();
   IKnowledge knowledge = getAlgorithmRunner().getParams().getKnowledge();
   SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
   //        resultWorkbench.setGraph(graph);
 }
示例#2
0
  void storeLatestWorkbenchGraph() {
    Graph latestWorkbenchGraph = workbench.getGraph();

    if (latestWorkbenchGraph.getNumNodes() == 0) {
      return;
    }

    SearchParams searchParams = algorithmRunner.getParams();

    try {
      Graph graph = new MarshalledObject<Graph>(latestWorkbenchGraph).get();

      if (graph == null) {
        throw new NullPointerException("Null graph");
      }

      if (searchParams != null) {
        searchParams.setSourceGraph(graph);
      }
    } catch (IOException e) {
      e.printStackTrace();

      if (searchParams != null) {
        searchParams.setSourceGraph(null);
      }
    } catch (ClassNotFoundException e) {
      if (searchParams != null) {
        searchParams.setSourceGraph(null);
      }

      e.printStackTrace();
    }
  }
示例#3
0
  private JScrollPane dagWorkbenchScroll(Graph dag) {

    GraphWorkbench dagWorkbench = new GraphWorkbench(dag);
    dagWorkbench.setAllowDoubleClickActions(false);
    dagWorkbench.setAllowNodeEdgeSelection(true);
    JScrollPane dagWorkbenchScroll = new JScrollPane(dagWorkbench);
    dagWorkbenchScroll.setPreferredSize(new Dimension(450, 450));

    dagWorkbench.addMouseListener(
        new MouseAdapter() {
          public void mouseExited(MouseEvent e) {
            storeLatestWorkbenchGraph();
          }
        });

    return dagWorkbenchScroll;
  }
示例#4
0
  /**
   * Returns a list of all the SessionNodeWrappers (TetradNodes) and SessionNodeEdges that are model
   * components for the respective SessionNodes and SessionEdges selected in the workbench. Note
   * that the workbench, not the SessionEditorNodes themselves, keeps track of the selection.
   *
   * @return the set of selected model nodes.
   */
  public java.util.List getSelectedModelComponents() {
    java.util.List<Component> selectedComponents = workbench.getSelectedComponents();
    java.util.List<TetradSerializable> selectedModelComponents =
        new ArrayList<TetradSerializable>();

    for (Component comp : selectedComponents) {
      if (comp instanceof DisplayNode) {
        selectedModelComponents.add(((DisplayNode) comp).getModelNode());
      } else if (comp instanceof DisplayEdge) {
        selectedModelComponents.add(((DisplayEdge) comp).getModelEdge());
      }
    }

    return selectedModelComponents;
  }
示例#5
0
 public void setGraph(Graph graph) {
   workbench.setGraph(graph);
 }
示例#6
0
 public Graph getGraph() {
   return workbench.getGraph();
 }
示例#7
0
  private void resetDisplay() {
    String option = (String) subsetCombo.getSelectedItem();

    if ("Show All".equals(option)) {
      final List<Integer> _subsetIndices = getAllIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, 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.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    } else if ("Show Stable".equals(option)) {
      final List<Integer> _subsetIndices = getStableIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, 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.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    } else if ("Show Unstable".equals(option)) {
      final List<Integer> _subsetIndices = getUnstableIndices(getStoredGraphs());
      subsetIndices.clear();
      subsetIndices.addAll(_subsetIndices);

      int min = subsetIndices.size() == 0 ? 0 : 1;
      final SpinnerNumberModel model = new SpinnerNumberModel(min, min, 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.setModel(model);
      totalLabel.setText(" of " + _subsetIndices.size());

      if (subsetIndices.isEmpty()) {
        workbench.setGraph(new EdgeListGraph());
      } else {
        workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(0)));
      }
    }
  }