use of org.cytoscape.view.model.VisualLexiconNode in project cytoscape-api by cytoscape.
the class BasicVisualLexicon method getChildNodes.
private Set<VisualProperty<?>> getChildNodes(VisualProperty<?> prop) {
final VisualLexiconNode node = visualPropertyMap.get(prop);
final Set<VisualProperty<?>> children = new HashSet<>();
// if this is a leaf node, return empty set
if (node.getChildren().size() == 0)
return children;
Collection<VisualLexiconNode> currentChildren = node.getChildren();
for (VisualLexiconNode nd : currentChildren) children.add(nd.getVisualProperty());
for (VisualLexiconNode nd : currentChildren) children.addAll(getChildNodes(nd.getVisualProperty()));
return children;
}
use of org.cytoscape.view.model.VisualLexiconNode in project cytoscape-api by cytoscape.
the class BasicVisualLexicon method addVisualProperty.
/**
* Insert a {@link VisualProperty} to the tree.
*
* @param vp
* the VisualProperty to insert in the tree.
* @param parent
* the parent of the VisualProperty to insert.
*/
protected final void addVisualProperty(final VisualProperty<?> vp, final VisualProperty<?> parent) {
if (this.visualPropertyMap.containsKey(vp))
throw new IllegalStateException("The key " + vp.getIdString() + " already exists in the lexicon.");
if (parent == null)
throw new NullPointerException("Parent cannot be null.");
final VisualLexiconNode parentNode = this.visualPropertyMap.get(parent);
if (parentNode == null)
throw new IllegalArgumentException("Parent does not exist in the lexicon: " + parent.getDisplayName());
final VisualLexiconNode newNode = new VisualLexiconNode(vp, parentNode);
this.visualPropertyMap.put(vp, newNode);
addIdentifierMapping(vp.getTargetDataType(), vp.getIdString(), vp);
}
Aggregations