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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations