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