protected void removeElementFromReverseSearch(Element element) {
   if (element instanceof Node) {
     byNodeIdGroups.remove(element.getId());
   } else if (element instanceof Edge) {
     byEdgeIdGroups.remove(element.getId());
   } else if (element instanceof GraphicSprite) {
     bySpriteIdGroups.remove(element.getId());
   } else if (element instanceof Graph) {
     byGraphIdGroups.remove(element.getId());
   } else {
     throw new RuntimeException("What ?");
   }
 }
 protected void addElementToReverseSearch(Element element, String groupId) {
   if (element instanceof Node) {
     byNodeIdGroups.put(element.getId(), groupId);
   } else if (element instanceof Edge) {
     byEdgeIdGroups.put(element.getId(), groupId);
   } else if (element instanceof GraphicSprite) {
     bySpriteIdGroups.put(element.getId(), groupId);
   } else if (element instanceof Graph) {
     byGraphIdGroups.put(element.getId(), groupId);
   } else {
     throw new RuntimeException("What ?");
   }
 }
 /**
  * Retrieve the group identifier of an element knowing the element identifier.
  *
  * @param element The element to search for.
  * @return Identifier of the group containing the element.
  */
 public String getElementGroup(Element element) {
   if (element instanceof Node) {
     return byNodeIdGroups.get(element.getId());
   } else if (element instanceof Edge) {
     return byEdgeIdGroups.get(element.getId());
   } else if (element instanceof GraphicSprite) {
     return bySpriteIdGroups.get(element.getId());
   } else if (element instanceof Graph) {
     return byGraphIdGroups.get(element.getId());
   } else {
     throw new RuntimeException("What ?");
   }
 }
Exemple #4
0
    /**
     * Get the rules that match a given element. The rules are returned in a given order. The array
     * always contain the "main" rule that matches the element. This rule is either a default rule
     * for the kind of element given or the rule that matches its identifier if there is one. Then
     * class rules the element has can be appended to this array in order.
     *
     * @return an array of rules that match the element, with the main rule at index 0.
     */
    protected ArrayList<Rule> getRulesFor(Element element) {
      Rule rule = byId.get(element.getId());
      ArrayList<Rule> rules = new ArrayList<Rule>();

      if (rule != null) rules.add(rule);
      else rules.add(defaultRule);

      getClassRules(element, rules);

      if (rules.isEmpty()) rules.add(defaultRule);

      return rules;
    }
Exemple #5
0
    public boolean isAvailable(Element e) {
      if (e instanceof Edge) return e.getId().matches(edgePattern);

      return e.getId().matches(nodePattern);
    }