Search in sources :

Example 31 with VisualStyle

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);
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyEventHelper(org.cytoscape.event.CyEventHelper) VisualStyleSetEvent(org.cytoscape.view.vizmap.events.VisualStyleSetEvent) VisualStyle(org.cytoscape.view.vizmap.VisualStyle)

Example 32 with VisualStyle

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;
}
Also used : VisualStyle(org.cytoscape.view.vizmap.VisualStyle)

Example 33 with VisualStyle

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;
}
Also used : VisualStyle(org.cytoscape.view.vizmap.VisualStyle)

Example 34 with VisualStyle

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);
}
Also used : VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyNetworkView(org.cytoscape.view.model.CyNetworkView) View(org.cytoscape.view.model.View) CyEdge(org.cytoscape.model.CyEdge)

Example 35 with VisualStyle

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

Aggregations

VisualStyle (org.cytoscape.view.vizmap.VisualStyle)100 CyNetworkView (org.cytoscape.view.model.CyNetworkView)42 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)37 CyNetwork (org.cytoscape.model.CyNetwork)35 CyNode (org.cytoscape.model.CyNode)30 CyEdge (org.cytoscape.model.CyEdge)24 CyEventHelper (org.cytoscape.event.CyEventHelper)14 HashSet (java.util.HashSet)13 VisualProperty (org.cytoscape.view.model.VisualProperty)12 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)12 Paint (java.awt.Paint)11 HashMap (java.util.HashMap)11 CyApplicationManager (org.cytoscape.application.CyApplicationManager)11 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)11 Color (java.awt.Color)10 ArrayList (java.util.ArrayList)10 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)9 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)9 ContinuousMapping (org.cytoscape.view.vizmap.mappings.ContinuousMapping)9 View (org.cytoscape.view.model.View)8