Search in sources :

Example 1 with VisualStyleFactory

use of org.cytoscape.view.vizmap.VisualStyleFactory in project cytoscape-impl by cytoscape.

the class VisualStyleSerializerTest method mockVisualStyleFactory.

// MOCKUPS =========================================================================================================
private VisualStyleFactory mockVisualStyleFactory(VisualStyle defStyle) {
    VisualStyleFactory factory = mock(VisualStyleFactory.class);
    when(factory.createVisualStyle(defStyle)).thenAnswer(new Answer<VisualStyle>() {

        public VisualStyle answer(InvocationOnMock invocation) throws Throwable {
            return new DummyVisualStyle((VisualStyle) invocation.getArguments()[0]);
        }
    });
    when(factory.createVisualStyle(anyString())).thenAnswer(new Answer<VisualStyle>() {

        public VisualStyle answer(InvocationOnMock invocation) throws Throwable {
            return new DummyVisualStyle((String) invocation.getArguments()[0]);
        }
    });
    return factory;
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) Matchers.anyString(org.mockito.Matchers.anyString) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory)

Example 2 with VisualStyleFactory

use of org.cytoscape.view.vizmap.VisualStyleFactory 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 3 with VisualStyleFactory

use of org.cytoscape.view.vizmap.VisualStyleFactory in project cytoscape-impl by cytoscape.

the class CopyVisualStyleTask method copyVisualStyle.

// ==[ PRIVATE METHODS ]============================================================================================
private void copyVisualStyle() {
    final VisualStyleFactory vsFactory = servicesUtil.get(VisualStyleFactory.class);
    copiedStyle = vsFactory.createVisualStyle(originalStyle);
    copiedStyle.setTitle(vsName);
    // Save the current visual style first, so it can be set as current again if the action is undone
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    previousCurrentStyle = vmMgr.getCurrentVisualStyle();
    vmMgr.addVisualStyle(copiedStyle);
    vmMgr.setCurrentVisualStyle(copiedStyle);
}
Also used : VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory)

Example 4 with VisualStyleFactory

use of org.cytoscape.view.vizmap.VisualStyleFactory in project cytoscape-impl by cytoscape.

the class CreateNewVisualStyleTask method createVisualStyle.

// ==[ PRIVATE METHODS ]============================================================================================
private void createVisualStyle() {
    final VisualStyleFactory vsFactory = servicesUtil.get(VisualStyleFactory.class);
    newStyle = vsFactory.createVisualStyle(vsName);
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    // Save the current visual style first, so it can be set as current again if the action is undone
    previousCurrentStyle = vmMgr.getCurrentVisualStyle();
    vmMgr.addVisualStyle(newStyle);
    vmMgr.setCurrentVisualStyle(newStyle);
}
Also used : VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory)

Example 5 with VisualStyleFactory

use of org.cytoscape.view.vizmap.VisualStyleFactory in project cytoscape-impl by cytoscape.

the class VisualMappingManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final VisualStyleFactory factory = mock(VisualStyleFactory.class);
    final VisualStyle dummyDefaultStyle = mock(VisualStyle.class);
    when(factory.createVisualStyle(VisualMappingManagerImpl.DEFAULT_STYLE_NAME)).thenReturn(dummyDefaultStyle);
    final CyEventHelper eventHelper = mock(CyEventHelper.class);
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    vmm = new VisualMappingManagerImpl(factory, serviceRegistrar);
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VisualMappingManagerImpl(org.cytoscape.view.vizmap.internal.VisualMappingManagerImpl) VisualStyleFactory(org.cytoscape.view.vizmap.VisualStyleFactory) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Aggregations

VisualStyleFactory (org.cytoscape.view.vizmap.VisualStyleFactory)8 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)5 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)4 CyEventHelper (org.cytoscape.event.CyEventHelper)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)3 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)3 VisualMappingFunctionFactory (org.cytoscape.view.vizmap.VisualMappingFunctionFactory)3 Before (org.junit.Before)2 Paint (java.awt.Paint)1 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 AppManagerAction (org.cytoscape.app.internal.action.AppManagerAction)1 CitationsAction (org.cytoscape.app.internal.action.CitationsAction)1 AppManager (org.cytoscape.app.internal.manager.AppManager)1 UpdateManager (org.cytoscape.app.internal.net.UpdateManager)1 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)1 AddAllowOriginHeader (org.cytoscape.app.internal.net.server.AddAllowOriginHeader)1 AppGetResponder (org.cytoscape.app.internal.net.server.AppGetResponder)1 CyHttpd (org.cytoscape.app.internal.net.server.CyHttpd)1 CyHttpdFactoryImpl (org.cytoscape.app.internal.net.server.CyHttpdFactoryImpl)1