private void updateNodes(HierarchicalGraph graph) { Modeler nodeInit = engine.getModelClasses()[AbstractEngine.CLASS_NODE].getCurrentModeler(); NodeIterable nodeIterable; nodeIterable = graph.getNodes(); for (Node node : nodeIterable) { Model obj = node.getNodeData().getModel(); if (obj == null) { // Model is null, ADD obj = nodeInit.initModel(node.getNodeData()); engine.addObject(AbstractEngine.CLASS_NODE, (ModelImpl) obj); } else if (!obj.isValid()) { engine.addObject(AbstractEngine.CLASS_NODE, (ModelImpl) obj); } obj.setCacheMarker(cacheMarker); // Modeaction if (modeManager.getMode().equals(ModeManager.AVAILABLE_MODES.HIGHLIGHT)) { ModelImpl impl = (ModelImpl) obj; // if (!node.isVisible()) { // ColorLayer.layerColor(impl, 0.8f, 0.8f, 0.8f); // } } } }
private void updateEdges(HierarchicalGraph graph) { Modeler edgeInit = engine.getModelClasses()[AbstractEngine.CLASS_EDGE].getCurrentModeler(); Modeler arrowInit = engine.getModelClasses()[AbstractEngine.CLASS_ARROW].getCurrentModeler(); EdgeIterable edgeIterable; edgeIterable = graph.getEdges(); float minWeight = Float.POSITIVE_INFINITY; float maxWeight = Float.NEGATIVE_INFINITY; TimeInterval timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel); for (Edge edge : edgeIterable) { if (edge.getSource().getNodeData().getModel() == null || edge.getTarget().getNodeData().getModel() == null) { continue; } float weight = 1f; if (timeInterval == null) { weight = edge.getWeight(); } else { weight = edge.getWeight(timeInterval.getLow(), timeInterval.getHigh()); } minWeight = Math.min(minWeight, weight); maxWeight = Math.max(maxWeight, weight); Edge2dModel obj = (Edge2dModel) edge.getEdgeData().getModel(); if (obj == null) { // Model is null, ADD obj = (Edge2dModel) edgeInit.initModel(edge.getEdgeData()); engine.addObject(AbstractEngine.CLASS_EDGE, obj); if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop()) { Arrow2dModel arrowObj = (Arrow2dModel) arrowInit.initModel(edge.getEdgeData()); engine.addObject(AbstractEngine.CLASS_ARROW, arrowObj); arrowObj.setCacheMarker(cacheMarker); arrowObj.setWeight(weight); obj.setArrow(arrowObj); } } else if (!obj.isValid()) { engine.addObject(AbstractEngine.CLASS_EDGE, obj); if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop()) { Arrow2dModel arrowObj = obj.getArrow(); engine.addObject(AbstractEngine.CLASS_ARROW, arrowObj); arrowObj.setCacheMarker(cacheMarker); arrowObj.setWeight(weight); } } else { if (!undirected && vizConfig.isShowArrows() && !edge.isSelfLoop() && edge.isDirected()) { Arrow2dModel arrowObj = obj.getArrow(); arrowObj.setCacheMarker(cacheMarker); arrowObj.setWeight(weight); } } obj.setWeight(weight); obj.setCacheMarker(cacheMarker); } limits.setMinWeight(minWeight); limits.setMaxWeight(maxWeight); }
public void updatePotatoes(HierarchicalGraph graph) { ModelClass potatoClass = engine.getModelClasses()[AbstractEngine.CLASS_POTATO]; if (potatoClass.isEnabled()) { Modeler potInit = engine.getModelClasses()[AbstractEngine.CLASS_POTATO].getCurrentModeler(); List<ModelImpl> hulls = new ArrayList<ModelImpl>(); Node[] nodes = graph.getNodes().toArray(); for (Node n : nodes) { Node parent = graph.getParent(n); if (parent != null) { Group group = (Group) parent; Model hullModel = group.getGroupData().getHullModel(); if (hullModel != null && hullModel.isCacheMatching(cacheMarker)) { ConvexHull hull = (ConvexHull) hullModel.getObj(); hull.addNode(n); hull.setModel(hullModel); } else if (hullModel != null) { // Its not the first time the hull exist ConvexHullModel model = (ConvexHullModel) hullModel; model.setScale(1f); hullModel.setCacheMarker(cacheMarker); hulls.add((ModelImpl) hullModel); } else { ConvexHull ch = new ConvexHull(); ch.setMetaNode(parent); ch.addNode(n); ModelImpl obj = potInit.initModel(ch); group.getGroupData().setHullModel(obj); obj.setCacheMarker(cacheMarker); hulls.add(obj); } } } for (ModelImpl im : hulls) { ConvexHull hull = (ConvexHull) im.getObj(); hull.recompute(); engine.addObject(AbstractEngine.CLASS_POTATO, im); } } }