예제 #1
0
  Graph getLatestWorkbenchGraph() {
    if (algorithmRunner.getParams() == null) {
      return null;
    }

    Graph graph = algorithmRunner.getParams().getSourceGraph();

    if (graph == null) {
      return algorithmRunner.getSourceGraph();
    }

    return 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
  JScrollPane workbenchScroll(String resultLabel) {
    Graph resultGraph = resultGraph();

    Graph sourceGraph = algorithmRunner.getSourceGraph();
    SearchParams searchParams = algorithmRunner.getParams();
    Graph latestWorkbenchGraph = null;

    if (searchParams != null) {
      latestWorkbenchGraph = searchParams.getSourceGraph();
    }

    if (latestWorkbenchGraph == null) {
      GraphUtils.arrangeBySourceGraph(resultGraph, sourceGraph);
    } else {
      GraphUtils.arrangeBySourceGraph(resultGraph, latestWorkbenchGraph);
    }

    //        boolean arrangedAll = DataGraphUtils.arrangeBySourceGraph(resultGraph,
    //                latestWorkbenchGraph);
    //
    //        if (!arrangedAll) {
    //            arrangedAll =
    //                    DataGraphUtils.arrangeBySourceGraph(resultGraph, sourceGraph);
    //        }

    //        if (!arrangedAll) {
    //            DataGraphUtils.circleLayout(resultGraph, 200, 200, 150);
    //        }

    this.workbench = new GraphWorkbench(resultGraph);

    graphHistory.clear();
    graphHistory.add(resultGraph);

    this.workbench.setAllowDoubleClickActions(false);
    this.workbench.setAllowNodeEdgeSelection(true);
    this.workbenchScroll = new JScrollPane(workbench);
    //        workbenchScroll.setPreferredSize(new Dimension(450, 450));
    //        workbenchScroll.setBorder(new TitledBorder(resultLabel));

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

    return workbenchScroll;
  }