/** * The centrality value of the given node or edge. * * @param elt * Extract the centrality of this node or edge. * @return The centrality value. */ public double centrality(Element elt) { return elt.getNumber(centralityAttributeName); }
/** * Delete attributes used by this algorithm in elements of a graph * @param it the list of elements */ private void cleanElement(Iterable<? extends Element> it){ for(Element e : it){ if(e.hasAttribute(predAttributeName)) e.removeAttribute(predAttributeName); if(e.hasAttribute(sigmaAttributeName)) e.removeAttribute(sigmaAttributeName); if(e.hasAttribute(distAttributeName)) e.removeAttribute(distAttributeName); if(e.hasAttribute(deltaAttributeName)) e.removeAttribute(deltaAttributeName); } }
/** * * @param source * @param target */ public static void copyAttributes(Element source, Element target) { for (String key : source.getAttributeKeySet()) { Object value = source.getAttribute(key); value = checkedArrayOrCollectionCopy(value); target.setAttribute(key, value); } }
public boolean isAvailable(T e) { return e.hasAttribute(key) && (value == null ? e.getAttribute(key) == null : value .equals(e.getAttribute(key))); } }
private void attributeDiff(ElementType type, Element e1, Element e2) { if (e1 == null && e2 == null) return; else if (e1 == null) { for (String key : e2.getAttributeKeySet()) events.add(new AttributeAdded(type, e2.getId(), key, e2 .getAttribute(key))); } else if (e2 == null) { for (String key : e1.getAttributeKeySet()) events.add(new AttributeRemoved(type, e1.getId(), key, e1 .getAttribute(key))); } else { for (String key : e2.getAttributeKeySet()) { if (e1.hasAttribute(key)) { Object o1 = e1.getAttribute(key); Object o2 = e2.getAttribute(key); if (!(o1 == null ? o2 == null : o1.equals(o2))) events.add(new AttributeChanged(type, e1.getId(), key, o2, o1)); } else events.add(new AttributeAdded(type, e1.getId(), key, e2 .getAttribute(key))); } for (String key : e1.getAttributeKeySet()) { if (!e2.hasAttribute(key)) events.add(new AttributeRemoved(type, e1.getId(), key, e1 .getAttribute(key))); } } }
protected String outputAttributes(Element e) { if (e.getAttributeCount() == 0) return ""; StringBuilder buffer = new StringBuilder("["); boolean first = true; for (String key : e.getEachAttributeKey()) { boolean quote = true; Object value = e.getAttribute(key); if (value instanceof Number) quote = false; buffer.append(String.format("%s\"%s\"=%s%s%s", first ? "" : ",", key, quote ? "\"" : "", value, quote ? "\"" : "")); first = false; } return buffer.append(']').toString(); } }
id = String.format("egde-%s", e.getId()); style = svgStyles.get(groups.getStyleFor((Edge) e)); } else if (e instanceof Node) { id = String.format("node-%s", e.getId()); style = svgStyles.get(groups.getStyleFor((Node) e)); transform = String.format(Locale.ROOT, "translate(%f,%f)", out.close(); if (e.hasLabel("label")) writeElementText(out, (String) e.getAttribute("label"), e, style.group);
/** * Set the centrality of the given node or edge. * * @param elt * The node or edge to modify. * @param centrality * The centrality to store on the node. */ public void setCentrality(Element elt, double centrality) { elt.setAttribute(centralityAttributeName, centrality); }
public boolean hasAttribute(String key) { boolean b; attributeLock.lock(); b = wrappedElement.hasAttribute(key); attributeLock.unlock(); return b; }
/** * Detach the sprite from the element it is attached to (if any). */ public void detach() { if (attachment != null) { attachment.removeAttribute(completeId); attachment = null; } }
public <T> T getAttribute(String key) { T o; attributeLock.lock(); o = wrappedElement.getAttribute(key); attributeLock.unlock(); return o; }
GEXFAttributeMap(String type, Graph g) { this.type = type; Iterable<? extends Element> iterable; if (type.equals("node")) iterable = (Iterable<? extends Element>) g.getNodeSet(); else iterable = (Iterable<? extends Element>) g.getEdgeSet(); for (Element e : iterable) { for (String key : e.getAttributeKeySet()) { Object value = e.getAttribute(key); check(key, value); } } }
public void addAttribute(String attribute, Object... values) { attributeLock.lock(); wrappedElement.addAttribute(attribute, values); attributeLock.unlock(); }
public void changeAttribute(String attribute, Object... values) { attributeLock.lock(); wrappedElement.changeAttribute(attribute, values); attributeLock.unlock(); }
public Object[] getArray(String key) { Object[] o; attributeLock.lock(); o = wrappedElement.getArray(key); attributeLock.unlock(); return o; }
public void addAttributes(Map<String, Object> attributes) { attributeLock.lock(); wrappedElement.addAttributes(attributes); attributeLock.unlock(); }
public void clearAttributes() { attributeLock.lock(); wrappedElement.clearAttributes(); attributeLock.unlock(); }
private void attributeDiff(ElementType type, Element e1, Element e2) { if (e1 == null && e2 == null) return; else if (e1 == null) { for (String key : e2.getAttributeKeySet()) events.add(new AttributeAdded(type, e2.getId(), key, e2 .getAttribute(key))); } else if (e2 == null) { for (String key : e1.getAttributeKeySet()) events.add(new AttributeRemoved(type, e1.getId(), key, e1 .getAttribute(key))); } else { for (String key : e2.getAttributeKeySet()) { if (e1.hasAttribute(key)) { Object o1 = e1.getAttribute(key); Object o2 = e2.getAttribute(key); if (!(o1 == null ? o2 == null : o1.equals(o2))) events.add(new AttributeChanged(type, e1.getId(), key, o2, o1)); } else events.add(new AttributeAdded(type, e1.getId(), key, e2 .getAttribute(key))); } for (String key : e1.getAttributeKeySet()) { if (!e2.hasAttribute(key)) events.add(new AttributeRemoved(type, e1.getId(), key, e1 .getAttribute(key))); } } }