Search in sources :

Example 11 with VisualLexiconNode

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;
}
Also used : VisualLexiconNode(org.cytoscape.view.model.VisualLexiconNode) VisualProperty(org.cytoscape.view.model.VisualProperty) HashSet(java.util.HashSet)

Example 12 with VisualLexiconNode

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

Aggregations

VisualLexiconNode (org.cytoscape.view.model.VisualLexiconNode)12 VisualProperty (org.cytoscape.view.model.VisualProperty)6 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)3 VisualLexicon (org.cytoscape.view.model.VisualLexicon)3 Map (java.util.Map)2 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 Collator (java.text.Collator)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1