use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VisualMappingManagerImpl method setVisualStyle.
@Override
public void setVisualStyle(final VisualStyle vs, final CyNetworkView nv) {
if (nv == null)
throw new NullPointerException("Network view is null.");
boolean changed = false;
synchronized (lock) {
if (vs == null) {
changed = network2VisualStyleMap.remove(nv) != null;
} else {
final VisualStyle previousStyle = network2VisualStyleMap.put(nv, vs);
changed = !vs.equals(previousStyle);
}
if (this.visualStyles.contains(vs) == false)
this.visualStyles.add(vs);
}
if (changed) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(new VisualStyleSetEvent(this, vs, nv));
final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
if (appManager != null && nv.equals(appManager.getCurrentNetworkView()))
setCurrentVisualStyle(vs);
}
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VisualMappingManagerImpl method buildGlobalDefaultStyle.
private VisualStyle buildGlobalDefaultStyle(final VisualStyleFactory factory) {
final VisualStyle defStyle = factory.createVisualStyle(DEFAULT_STYLE_NAME);
defStyle.setDefaultValue(BasicVisualLexicon.NETWORK_BACKGROUND_PAINT, NETWORK_COLOR);
defStyle.setDefaultValue(BasicVisualLexicon.NODE_FILL_COLOR, NODE_COLOR);
defStyle.setDefaultValue(BasicVisualLexicon.NODE_LABEL_COLOR, NODE_LABEL_COLOR);
defStyle.setDefaultValue(BasicVisualLexicon.NODE_WIDTH, NODE_WIDTH);
defStyle.setDefaultValue(BasicVisualLexicon.NODE_HEIGHT, NODE_HEIGHT);
defStyle.setDefaultValue(BasicVisualLexicon.EDGE_WIDTH, EDGE_WIDTH);
defStyle.setDefaultValue(BasicVisualLexicon.EDGE_PAINT, EDGE_COLOR);
defStyle.setDefaultValue(BasicVisualLexicon.EDGE_LABEL_COLOR, EDGE_LABEL_COLOR);
return defStyle;
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VisualStyleFactoryImpl method createVisualStyle.
@Override
public VisualStyle createVisualStyle(final VisualStyle original) {
final VisualStyle copy = new VisualStyleImpl(original.getTitle(), serviceRegistrar);
copyDefaultValues(original, copy);
copyMappingFunctions(original, copy);
copyDependencies(original, copy);
return copy;
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class ClearAllEdgeBendsTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
tm.setTitle("Clear All Edge Bends");
tm.setProgress(0.0);
final VisualMappingManager vmManager = serviceRegistrar.getService(VisualMappingManager.class);
int count = 1;
int total = networkViews.size();
for (CyNetworkView nv : networkViews) {
tm.setStatusMessage(count + " of " + total + ": " + DataUtils.getViewTitle(nv) + "...");
tm.setProgress((float) count / total);
nv.setViewDefault(BasicVisualLexicon.EDGE_BEND, null);
VisualStyle vs = vmManager.getVisualStyle(nv);
vs.setDefaultValue(BasicVisualLexicon.EDGE_BEND, null);
vs.removeVisualMappingFunction(BasicVisualLexicon.EDGE_BEND);
final Collection<View<CyEdge>> edgeViews = nv.getEdgeViews();
for (final View<CyEdge> ev : edgeViews) {
ev.setVisualProperty(BasicVisualLexicon.EDGE_BEND, null);
ev.clearValueLock(BasicVisualLexicon.EDGE_BEND);
}
nv.updateView();
count++;
}
tm.setProgress(1.0);
}
use of org.cytoscape.view.vizmap.VisualStyle 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;
}
Aggregations