Search in sources :

Example 1 with Dependency

use of org.cytoscape.io.internal.util.vizmap.model.Dependency in project cytoscape-impl by cytoscape.

the class CalculatorConverter method setDependency.

private void setDependency(VisualStyle vs, String sValue) {
    Dependency d = new Dependency();
    d.setName(visualPropertyId);
    d.setValue(new Boolean(sValue.trim()));
    if (targetType == CyNetwork.class) {
        vs.getNetwork().getDependency().add(d);
    } else if (targetType == CyNode.class) {
        vs.getNode().getDependency().add(d);
    } else if (targetType == CyEdge.class) {
        vs.getEdge().getDependency().add(d);
    }
}
Also used : CyNode(org.cytoscape.model.CyNode) Dependency(org.cytoscape.io.internal.util.vizmap.model.Dependency)

Example 2 with Dependency

use of org.cytoscape.io.internal.util.vizmap.model.Dependency in project cytoscape-impl by cytoscape.

the class VisualStyleSerializer method restoreDependencies.

private void restoreDependencies(final VisualStyle visualStyle, org.cytoscape.io.internal.util.vizmap.model.VisualStyle vsModel) {
    final Node nodeSection = vsModel.getNode();
    final Edge edgeSection = vsModel.getEdge();
    final Network networkSection = vsModel.getNetwork();
    final Set<Dependency> dependencyStates = new HashSet<>();
    if (nodeSection != null)
        dependencyStates.addAll(nodeSection.getDependency());
    if (edgeSection != null)
        dependencyStates.addAll(edgeSection.getDependency());
    if (networkSection != null)
        dependencyStates.addAll(networkSection.getDependency());
    final Set<VisualPropertyDependency<?>> availableDependencies = visualStyle.getAllVisualPropertyDependencies();
    for (final Dependency dep : dependencyStates) {
        final String depName = dep.getName();
        final Boolean enabled = dep.isValue();
        for (final VisualPropertyDependency<?> vsDependency : availableDependencies) {
            if (vsDependency.getIdString().equalsIgnoreCase(depName))
                vsDependency.setDependency(enabled);
        }
    }
}
Also used : CyNode(org.cytoscape.model.CyNode) Node(org.cytoscape.io.internal.util.vizmap.model.Node) CyNetwork(org.cytoscape.model.CyNetwork) Network(org.cytoscape.io.internal.util.vizmap.model.Network) VisualPropertyDependency(org.cytoscape.view.vizmap.VisualPropertyDependency) VisualPropertyDependency(org.cytoscape.view.vizmap.VisualPropertyDependency) Dependency(org.cytoscape.io.internal.util.vizmap.model.Dependency) Edge(org.cytoscape.io.internal.util.vizmap.model.Edge) CyEdge(org.cytoscape.model.CyEdge) HashSet(java.util.HashSet)

Example 3 with Dependency

use of org.cytoscape.io.internal.util.vizmap.model.Dependency in project cytoscape-impl by cytoscape.

the class VisualStyleSerializer method createDependencies.

private void createDependencies(final VisualStyle visualStyle, org.cytoscape.io.internal.util.vizmap.model.VisualStyle vsModel) {
    // Create serializable Dependency
    final Set<VisualPropertyDependency<?>> dependencies = visualStyle.getAllVisualPropertyDependencies();
    final List<Dependency> nodeDep = vsModel.getNode().getDependency();
    final List<Dependency> edgeDep = vsModel.getEdge().getDependency();
    final List<Dependency> networkDep = vsModel.getNetwork().getDependency();
    Collection<VisualProperty<?>> nodeVisualProperties = lexicon.getAllDescendants(BasicVisualLexicon.NODE);
    Collection<VisualProperty<?>> edgeVisualProperties = lexicon.getAllDescendants(BasicVisualLexicon.EDGE);
    for (VisualPropertyDependency<?> vpDep : dependencies) {
        try {
            final Dependency newDependency = new Dependency();
            newDependency.setName(vpDep.getIdString());
            newDependency.setValue(vpDep.isDependencyEnabled());
            final VisualProperty<?> parent = vpDep.getParentVisualProperty();
            if (nodeVisualProperties.contains(parent))
                nodeDep.add(newDependency);
            else if (edgeVisualProperties.contains(parent))
                edgeDep.add(newDependency);
            else
                networkDep.add(newDependency);
        } catch (final Exception e) {
            logger.error("Cannot save dependency: " + (vpDep != null ? vpDep.getDisplayName() : ""), e);
        }
    }
}
Also used : VisualPropertyDependency(org.cytoscape.view.vizmap.VisualPropertyDependency) VisualProperty(org.cytoscape.view.model.VisualProperty) VisualPropertyDependency(org.cytoscape.view.vizmap.VisualPropertyDependency) Dependency(org.cytoscape.io.internal.util.vizmap.model.Dependency)

Aggregations

Dependency (org.cytoscape.io.internal.util.vizmap.model.Dependency)3 CyNode (org.cytoscape.model.CyNode)2 VisualPropertyDependency (org.cytoscape.view.vizmap.VisualPropertyDependency)2 HashSet (java.util.HashSet)1 Edge (org.cytoscape.io.internal.util.vizmap.model.Edge)1 Network (org.cytoscape.io.internal.util.vizmap.model.Network)1 Node (org.cytoscape.io.internal.util.vizmap.model.Node)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNetwork (org.cytoscape.model.CyNetwork)1 VisualProperty (org.cytoscape.view.model.VisualProperty)1