Search in sources :

Example 1 with BasicVisualLexicon

use of org.cytoscape.view.presentation.property.BasicVisualLexicon 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 2 with BasicVisualLexicon

use of org.cytoscape.view.presentation.property.BasicVisualLexicon 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 3 with BasicVisualLexicon

use of org.cytoscape.view.presentation.property.BasicVisualLexicon in project cytoscape-api by cytoscape.

the class BasicVisualLexiconTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    // Create root node.
    richRoot = new NullVisualProperty("RICH_ROOT", "Rich Root Visual Property");
    richLex = new BasicVisualLexicon(richRoot);
}
Also used : NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) Before(org.junit.Before)

Example 4 with BasicVisualLexicon

use of org.cytoscape.view.presentation.property.BasicVisualLexicon in project cytoscape-impl by cytoscape.

the class VisualStyleSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    evtHelper = mock(CyEventHelper.class);
    twoDRoot = new NullVisualProperty("2D_ROOT", "2D Root Visual Property");
    lexicon = new BasicVisualLexicon(twoDRoot);
    VisualStyle defaultStyle = new DummyVisualStyle(DEFAULT_STYLE_NAME);
    final VisualStyleFactory visualStyleFactory = mockVisualStyleFactory(defaultStyle);
    final VisualMappingFunctionFactory discreteMappingFactory = mockMappingFunctionFactory(DiscreteMapping.class);
    final VisualMappingFunctionFactory continuousMappingFactory = mockMappingFunctionFactory(ContinuousMapping.class);
    final VisualMappingFunctionFactory passthroughMappingFactory = mockMappingFunctionFactory(PassthroughMapping.class);
    final RenderingEngineManager renderingEngineManager = mock(RenderingEngineManager.class);
    when(renderingEngineManager.getDefaultVisualLexicon()).thenReturn(lexicon);
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(evtHelper);
    when(serviceRegistrar.getService(VisualStyleFactory.class)).thenReturn(visualStyleFactory);
    when(serviceRegistrar.getService(RenderingEngineManager.class)).thenReturn(renderingEngineManager);
    when(serviceRegistrar.getService(VisualMappingFunctionFactory.class, "(mapping.type=discrete)")).thenReturn(discreteMappingFactory);
    when(serviceRegistrar.getService(VisualMappingFunctionFactory.class, "(mapping.type=continuous)")).thenReturn(continuousMappingFactory);
    when(serviceRegistrar.getService(VisualMappingFunctionFactory.class, "(mapping.type=passthrough)")).thenReturn(passthroughMappingFactory);
    final CalculatorConverterFactory calcFactory = new CalculatorConverterFactory();
    serializer = new VisualStyleSerializer(calcFactory, serviceRegistrar);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) VisualMappingFunctionFactory(org.cytoscape.view.vizmap.VisualMappingFunctionFactory) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Example 5 with BasicVisualLexicon

use of org.cytoscape.view.presentation.property.BasicVisualLexicon in project cytoscape-impl by cytoscape.

the class AbstractNetworkReaderTest method setUp.

@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();
    netManager = nts.getNetworkManager();
    rootNetManager = nts.getRootNetworkFactory();
    netTableManager = nts.getNetworkTableManager();
    TableTestSupport tblTestSupport = new TableTestSupport();
    tableFactory = tblTestSupport.getTableFactory();
    tableManager = mock(CyTableManager.class);
    GroupTestSupport groupTestSupport = new GroupTestSupport();
    groupManager = groupTestSupport.getGroupManager();
    groupFactory = groupTestSupport.getGroupFactory();
    properties = new Properties();
    CyProperty<Properties> cyProperties = new SimpleCyProperty<>("Test", properties, Properties.class, SavePolicy.DO_NOT_SAVE);
    NetworkViewTestSupport nvts = new NetworkViewTestSupport();
    setViewThreshold(DEF_THRESHOLD);
    viewFactory = nvts.getNetworkViewFactory();
    readUtil = new ReadUtils(new StreamUtilImpl(serviceRegistrar));
    defRenderer = mock(NetworkViewRenderer.class);
    when(defRenderer.getNetworkViewFactory()).thenReturn(viewFactory);
    lexicon = new BasicVisualLexicon(new NullVisualProperty("MINIMAL_ROOT", "Minimal Root Visual Property"));
    renderingEngineManager = mock(RenderingEngineManager.class);
    when(renderingEngineManager.getDefaultVisualLexicon()).thenReturn(lexicon);
    applicationManager = mock(CyApplicationManager.class);
    when(applicationManager.getDefaultNetworkViewRenderer()).thenReturn(defRenderer);
    serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=cytoscape3.props)")).thenReturn(cyProperties);
    when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(applicationManager);
    when(serviceRegistrar.getService(CyNetworkFactory.class)).thenReturn(netFactory);
    when(serviceRegistrar.getService(CyNetworkViewFactory.class)).thenReturn(viewFactory);
    when(serviceRegistrar.getService(CyNetworkManager.class)).thenReturn(netManager);
    when(serviceRegistrar.getService(CyNetworkTableManager.class)).thenReturn(netTableManager);
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetManager);
    when(serviceRegistrar.getService(CyLayoutAlgorithmManager.class)).thenReturn(layouts);
    when(serviceRegistrar.getService(CyTableManager.class)).thenReturn(tableManager);
    when(serviceRegistrar.getService(CyTableFactory.class)).thenReturn(tableFactory);
    when(serviceRegistrar.getService(CyGroupManager.class)).thenReturn(groupManager);
    when(serviceRegistrar.getService(CyGroupFactory.class)).thenReturn(groupFactory);
    when(serviceRegistrar.getService(RenderingEngineManager.class)).thenReturn(renderingEngineManager);
}
Also used : NullVisualProperty(org.cytoscape.view.presentation.property.NullVisualProperty) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) Properties(java.util.Properties) NetworkViewTestSupport(org.cytoscape.ding.NetworkViewTestSupport) SimpleCyProperty(org.cytoscape.property.SimpleCyProperty) StreamUtilImpl(org.cytoscape.io.internal.util.StreamUtilImpl) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) CyApplicationManager(org.cytoscape.application.CyApplicationManager) TaskIterator(org.cytoscape.work.TaskIterator) CyLayoutAlgorithmManager(org.cytoscape.view.layout.CyLayoutAlgorithmManager) CyTableManager(org.cytoscape.model.CyTableManager) TaskMonitor(org.cytoscape.work.TaskMonitor) TableTestSupport(org.cytoscape.model.TableTestSupport) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) GroupTestSupport(org.cytoscape.group.GroupTestSupport) ReadUtils(org.cytoscape.io.internal.util.ReadUtils) CyNetworkView(org.cytoscape.view.model.CyNetworkView) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer) Before(org.junit.Before)

Aggregations

BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)6 Before (org.junit.Before)6 NullVisualProperty (org.cytoscape.view.presentation.property.NullVisualProperty)5 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)4 NetworkViewTestSupport (org.cytoscape.ding.NetworkViewTestSupport)3 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)3 Paint (java.awt.Paint)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)2 CyEventHelper (org.cytoscape.event.CyEventHelper)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 VisualProperty (org.cytoscape.view.model.VisualProperty)2 VisualMappingFunctionFactory (org.cytoscape.view.vizmap.VisualMappingFunctionFactory)2 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)2 TaskMonitor (org.cytoscape.work.TaskMonitor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 CyGroupManager (org.cytoscape.group.CyGroupManager)1 GroupTestSupport (org.cytoscape.group.GroupTestSupport)1