コード例 #1
0
  @Override
  public CyNetworkView buildCyNetworkView(final CyNetwork network) {
    final CyNetworkView view = networkViewFactory.createNetworkView(network);
    final CyLayoutAlgorithm layout = layouts.getDefaultLayout();
    TaskIterator itr =
        layout.createTaskIterator(
            view, layout.getDefaultLayoutContext(), CyLayoutAlgorithm.ALL_NODE_VIEWS, "");
    Task nextTask = itr.next();
    try {
      nextTask.run(parentTaskMonitor);
    } catch (Exception e) {
      throw new RuntimeException("Could not finish layout", e);
    }

    parentTaskMonitor.setProgress(1.0d);
    return view;
  }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    taskMonitor = mock(TaskMonitor.class);

    CyLayoutAlgorithm def = mock(CyLayoutAlgorithm.class);
    Object context = new Object();
    when(def.createLayoutContext()).thenReturn(context);
    when(def.getDefaultLayoutContext()).thenReturn(context);
    when(def.createTaskIterator(
            Mockito.any(CyNetworkView.class),
            Mockito.any(Object.class),
            Mockito.anySet(),
            Mockito.any(String.class)))
        .thenReturn(new TaskIterator(new SimpleTask()));

    layouts = mock(CyLayoutAlgorithmManager.class);
    when(layouts.getDefaultLayout()).thenReturn(def);

    NetworkTestSupport nts = new NetworkTestSupport();
    netFactory = nts.getNetworkFactory();

    networkManager = nts.getNetworkManager();
    rootNetworkManager = nts.getRootNetworkFactory();

    cyApplicationManager = mock(CyApplicationManager.class);

    properties = new Properties();
    CyProperty<Properties> cyProperties =
        new SimpleCyProperty<Properties>(
            "Test", properties, Properties.class, SavePolicy.DO_NOT_SAVE);
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    setViewThreshold(DEF_THRESHOLD);

    viewFactory = nvts.getNetworkViewFactory();
    readUtil = new ReadUtils(new StreamUtilImpl(cyProperties));
  }