Search in sources :

Example 6 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class VisualStyleTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    network = nvts.getNetworkFactory().createNetwork();
    node1 = network.addNode();
    node2 = network.addNode();
    node3 = network.addNode();
    edge = network.addEdge(node1, node2, true);
    CyTable nodeTable = network.getDefaultNodeTable();
    nodeTable.createColumn(attrName, String.class, true);
    nodeTable.getRow(node1.getSUID()).set(attrName, "red");
    nodeTable.getRow(node2.getSUID()).set(attrName, "green");
    nodeTable.getRow(node3.getSUID()).set(attrName, "foo");
    networkView = nvts.getNetworkViewFactory().createNetworkView(network);
    // Create root node.
    final NullVisualProperty minimalRoot = new NullVisualProperty("MINIMAL_ROOT", "Minimal Root Visual Property");
    final BasicVisualLexicon minimalLex = new BasicVisualLexicon(minimalRoot);
    final Set<VisualLexicon> lexSet = new HashSet<VisualLexicon>();
    lexSet.add(minimalLex);
    final VisualMappingFunctionFactory ptFactory = mock(VisualMappingFunctionFactory.class);
    eventHelper = mock(CyEventHelper.class);
    final RenderingEngineFactory<CyNetwork> reFatory = mock(RenderingEngineFactory.class);
    when(reFatory.getVisualLexicon()).thenReturn(minimalLex);
    final NetworkViewRenderer nvRenderer = mock(NetworkViewRenderer.class);
    when(nvRenderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT)).thenReturn(reFatory);
    final CyApplicationManager appManager = mock(CyApplicationManager.class);
    when(appManager.getCurrentNetworkViewRenderer()).thenReturn(nvRenderer);
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(appManager);
    VisualProperty<NullDataType> rootVisualProperty = mock(VisualProperty.class);
    BasicVisualLexicon lexicon = new BasicVisualLexicon(rootVisualProperty);
    vpSet = new HashSet<VisualProperty<Paint>>();
    vpSet.add(BasicVisualLexicon.NODE_BORDER_PAINT);
    vpSet.add(BasicVisualLexicon.NODE_FILL_COLOR);
    dependency = new VisualPropertyDependency<Paint>("dep1", "Dep 1", vpSet, lexicon);
    final VisualStyleFactoryImpl visualStyleFactory = new VisualStyleFactoryImpl(serviceRegistrar, ptFactory);
    originalTitle = "Style 1";
    newTitle = "Style 2";
    style = visualStyleFactory.createVisualStyle(originalTitle);
    style.setDefaultValue(NODE_SIZE, DEF_NODE_SIZE);
    style.setDefaultValue(NODE_FILL_COLOR, DEF_NODE_COLOR);
    reset(eventHelper);
}
Also used : NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) CyEventHelper(org.cytoscape.event.CyEventHelper) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) VisualMappingFunctionFactory(org.cytoscape.view.vizmap.VisualMappingFunctionFactory) CyNetwork(org.cytoscape.model.CyNetwork) Paint(java.awt.Paint) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) NullDataType(org.cytoscape.view.model.NullDataType) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualProperty(org.cytoscape.view.model.VisualProperty) NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) HashSet(java.util.HashSet) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer) Before(org.junit.Before)

Example 7 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class AbstractXGMMLWriterTest method init.

@Before
public void init() {
    netViewTestSupport = new NetworkViewTestSupport();
    netMgr = mock(CyNetworkManager.class);
    netFactory = netViewTestSupport.getNetworkFactory();
    rootNetMgr = netViewTestSupport.getRootNetworkFactory();
    vmMgr = mock(VisualMappingManager.class);
    VisualStyle style = mock(VisualStyle.class);
    when(style.getTitle()).thenReturn("default");
    when(vmMgr.getDefaultVisualStyle()).thenReturn(style);
    when(vmMgr.getVisualStyle(any(CyNetworkView.class))).thenReturn(style);
    renderingEngineMgr = mock(RenderingEngineManager.class);
    when(renderingEngineMgr.getDefaultVisualLexicon()).thenReturn(new BasicVisualLexicon(new NullVisualProperty("MINIMAL_ROOT", "Minimal Root Visual Property")));
    unrecogVisPropMgr = mock(UnrecognizedVisualPropertyManager.class);
    tm = mock(TaskMonitor.class);
    grMgr = mock(CyGroupManager.class);
    grFactory = grTestSupport.getGroupFactory();
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkManager.class)).thenReturn(netMgr);
    when(serviceRegistrar.getService(CyNetworkFactory.class)).thenReturn(netFactory);
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetMgr);
    when(serviceRegistrar.getService(RenderingEngineManager.class)).thenReturn(renderingEngineMgr);
    when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
    when(serviceRegistrar.getService(CyGroupManager.class)).thenReturn(grMgr);
    when(serviceRegistrar.getService(CyGroupFactory.class)).thenReturn(grFactory);
    groupUtil = new GroupUtil(serviceRegistrar);
    createBaseNetwork();
    out = new ByteArrayOutputStream();
    xpathFactory = XPathFactory.newInstance();
    doc = null;
}
Also used : NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) UnrecognizedVisualPropertyManager(org.cytoscape.io.internal.util.UnrecognizedVisualPropertyManager) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) GroupUtil(org.cytoscape.io.internal.util.GroupUtil) CyNetworkManager(org.cytoscape.model.CyNetworkManager) TaskMonitor(org.cytoscape.work.TaskMonitor) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyGroupManager(org.cytoscape.group.CyGroupManager) Before(org.junit.Before)

Example 8 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImplTest method testEscaping.

@Test
public void testEscaping() throws Exception {
    NetworkViewTestSupport support = new NetworkViewTestSupport();
    CyNetworkView view = support.getNetworkView();
    CyNetwork network = view.getModel();
    String title = "Network_With-Special Characters<>?:\"{}|=+()*&^%$#@![]|;',./\\";
    network.getRow(network).set(CyNetwork.NAME, title);
    {
        Matcher matcher = Cy3SessionReaderImpl.NETWORK_NAME_PATTERN.matcher(SessionUtil.getXGMMLFilename(network));
        Assert.assertTrue(matcher.matches());
        Assert.assertEquals(String.valueOf(network.getSUID()), matcher.group(1));
        Assert.assertEquals(title + ".xgmml", decode(matcher.group(3)));
    }
    {
        Matcher matcher = Cy3SessionReaderImpl.NETWORK_VIEW_NAME_PATTERN.matcher(SessionUtil.getXGMMLFilename(view));
        Assert.assertTrue(matcher.matches());
        Assert.assertEquals(String.valueOf(network.getSUID()), matcher.group(1));
        Assert.assertEquals(String.valueOf(view.getSUID()), matcher.group(2));
        Assert.assertEquals(title + ".xgmml", decode(matcher.group(4)));
    }
}
Also used : Matcher(java.util.regex.Matcher) CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Test(org.junit.Test)

Example 9 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class VisualStyleTest method testApplyPerformance.

@Test
public void testApplyPerformance() throws Exception {
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    final CyNetwork largeNetwork = nvts.getNetworkFactory().createNetwork();
    for (int i = 0; i < NETWORK_SIZE; i++) {
        largeNetwork.addNode();
    }
    final CyNetworkView largeNetworkView = nvts.getNetworkViewFactory().createNetworkView(largeNetwork);
    long global = 0;
    long local = 0;
    final int repeat = 5;
    for (int i = 0; i < repeat; i++) {
        global += runApplyGlobal(largeNetworkView);
        local += runApplyLocal(largeNetworkView);
    }
    long globalAverage = global / repeat;
    long localAverage = local / repeat;
    System.out.println("* Apply to network takes: Global " + globalAverage + " msec.");
    System.out.println("* Apply to network takes: Local " + localAverage + " msec.");
// assertTrue(globalAverage>localAverage);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Paint(java.awt.Paint) Test(org.junit.Test) AbstractVisualStyleTest(org.cytoscape.view.vizmap.AbstractVisualStyleTest)

Example 10 with NetworkViewTestSupport

use of org.cytoscape.ding.NetworkViewTestSupport in project cytoscape-impl by cytoscape.

the class OBOReaderTest method setUp.

@Before
public void setUp() throws Exception {
    viewSupport = new NetworkViewTestSupport();
    netSupport = new NetworkTestSupport();
    netViewFactory = viewSupport.getNetworkViewFactory();
    netFactory = netSupport.getNetworkFactory();
    eventHelper = mock(CyEventHelper.class);
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkViewFactory.class)).thenReturn(netViewFactory);
    when(serviceRegistrar.getService(CyNetworkFactory.class)).thenReturn(netFactory);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Aggregations

NetworkViewTestSupport (org.cytoscape.ding.NetworkViewTestSupport)14 CyNetwork (org.cytoscape.model.CyNetwork)9 Test (org.junit.Test)8 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)7 CyNetworkView (org.cytoscape.view.model.CyNetworkView)7 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)6 TaskMonitor (org.cytoscape.work.TaskMonitor)6 Before (org.junit.Before)6 CyApplicationManager (org.cytoscape.application.CyApplicationManager)5 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)5 HashSet (java.util.HashSet)4 CyEventHelper (org.cytoscape.event.CyEventHelper)4 CyGroupManager (org.cytoscape.group.CyGroupManager)4 CyNetworkManager (org.cytoscape.model.CyNetworkManager)4 CyNode (org.cytoscape.model.CyNode)4 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)4 TaskIterator (org.cytoscape.work.TaskIterator)4 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)3 CyRootNetworkManagerImpl (org.cytoscape.model.internal.CyRootNetworkManagerImpl)3 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)3