protected void refreshDynamic(ElementIterable<? extends Element> iterable) { double minN = Double.POSITIVE_INFINITY; double maxN = Double.NEGATIVE_INFINITY; for (Element el : iterable) { TimeMap timeMap = (TimeMap) el.getAttribute(column); if (timeMap != null) { double numMin = ((Number) timeMap.get(graph.getView().getTimeInterval(), Estimator.MIN)).doubleValue(); double numMax = ((Number) timeMap.get(graph.getView().getTimeInterval(), Estimator.MAX)).doubleValue(); if (numMin < minN) { minN = numMin; } if (numMax > maxN) { maxN = numMax; } } } min = minN; max = maxN; }
void checkViewExist(final GraphView view) { graphStore.viewStore.checkNonNullViewObject(view); if (!view.isMainView()) { graphStore.viewStore.checkViewExist((GraphViewImpl) view); } }
private FunctionsModel refreshFunctions(Graph graph) { synchronized (functionLock) { FunctionsModel m; if (graph.getView().isMainView()) { m = functionsMain; } else { m = functions.get(graph); if (m == null) { m = new FunctionsModel(graph); functions.put(graph, m); } } //Check and detroy old for (Iterator<Map.Entry<Graph, FunctionsModel>> it = functions.entrySet().iterator(); it.hasNext();) { Map.Entry<Graph, FunctionsModel> entry = it.next(); if (entry.getKey().getView().isDestroyed()) { it.remove(); } } return m; } }
if (currentView.isMainView()) { bounds = graphModel.getTimeBounds(); } else { bounds = currentView.getTimeInterval();
Graph mainGraph = graph.getView().getGraphModel().getGraph();
Interval bounds = statistics.getBounds(); if (bounds == null) { if (currentView.isMainView()) { bounds = graphModel.getTimeBounds(); } else { bounds = currentView.getTimeInterval();
@Override public Graph filter(Subgraph[] graphs) { if (graphs.length > 1) { throw new IllegalArgumentException("Not Filter accepts a single graph in parameter"); } Graph graph = graphs[0]; Graph mainGraph = graph.getView().getGraphModel().getGraph(); for (Edge e : mainGraph.getEdges()) { Node source = e.getSource(); Node target = e.getTarget(); if (graph.contains(source) && graph.contains(target)) { Edge edgeInGraph = graph.getEdge(source, target, e.getType()); if (edgeInGraph == null) { //The edge is not in graph graph.addEdge(e); } else { //The edge is in the graph graph.removeEdge(edgeInGraph); } } } return graph; }
public UndirectedSubgraph getUndirectedGraph(GraphView view) { checkNonNullViewObject(view); if (view.isMainView()) { return graphStore.undirectedDecorator; } return ((GraphViewImpl) view).getUndirectedGraph(); }
@Override public Object getValue(Element element, Graph gr) { if (graph != null) { TimeMap val = (TimeMap) element.getAttribute(column); if (val != null) { return val.get(gr.getView().getTimeInterval(), Estimator.FIRST); } return null; } return element.getAttribute(column); }
@Override public Graph filter(Subgraph[] graphs) { if (graphs.length > 1) { throw new IllegalArgumentException("Not Filter accepts a single graph in parameter"); } Graph graph = graphs[0]; Graph mainGraph = graph.getView().getGraphModel().getGraph(); for (Node n : mainGraph.getNodes().toArray()) { if (!graph.contains(n)) { //The node n is not in graph graph.addNode(n); } else { //The node n is in graph graph.removeNode(n); } } for (Edge e : mainGraph.getEdges()) { Node source = e.getSource(); Node target = e.getTarget(); if (graph.contains(source) && graph.contains(target)) { Edge edgeInGraph = graph.getEdge(source, target, e.getType()); if (edgeInGraph == null) { graph.addEdge(e); } } } return graph; }
@Override public TimeIndex<Node> getNodeTimeIndex(GraphView view) { TimeIndexStore timeIndexStore = store.timeStore.nodeIndexStore; if (timeIndexStore != null) { if (view.isMainView()) { return timeIndexStore.getIndex(store); } return timeIndexStore.getIndex(((GraphViewImpl) view).directedDecorator); } return null; }
@Override protected void refresh() { if (graph.getEdgeCount() > 0) { double minV = Double.MAX_VALUE; double maxV = Double.MIN_VALUE; for (Edge e : graph.getEdges()) { if (e.hasDynamicWeight()) { TimeMap timeMap = (TimeMap) e.getAttribute("weight"); if (timeMap != null) { Double numMin = (Double) timeMap.get(graph.getView().getTimeInterval(), Estimator.MIN); Double numMax = (Double) timeMap.get(graph.getView().getTimeInterval(), Estimator.MAX); minV = Math.min(numMin, minV); maxV = Math.max(numMax, maxV); } } else { minV = Math.min(e.getWeight(), minV); maxV = Math.max(e.getWeight(), maxV); } } min = minV; max = maxV; } } }
@Override public Index getNodeIndex(GraphView view) { IndexStore<Node> indexStore = store.nodeTable.store.indexStore; if (indexStore != null) { if (view.isMainView()) { return indexStore.getIndex(store); } return indexStore.getIndex(((GraphViewImpl) view).directedDecorator); } return null; }
@Override public double getWeight(GraphView view) { synchronized (this) { Object value = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (value instanceof TimeMap) { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); TimeMap dynamicValue = (TimeMap) value; Estimator estimator = getColumnStore().getColumnByIndex(GraphStoreConfiguration.EDGE_WEIGHT_INDEX) .getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } Double doubleVal = (Double) dynamicValue.get(interval, estimator); return doubleVal != null ? doubleVal : DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else if (value == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else { // Must be double return (Double) value; } } }
@Override public Index getEdgeIndex(GraphView view) { IndexStore<Edge> indexStore = store.edgeTable.store.indexStore; if (indexStore != null) { if (view.isMainView()) { return indexStore.getIndex(store); } return indexStore.getIndex(((GraphViewImpl) view).directedDecorator); } return null; }
@Override public double getWeight(GraphView view) { synchronized (this) { Object value = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (value instanceof TimeMap) { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); TimeMap dynamicValue = (TimeMap) value; Estimator estimator = getColumnStore().getColumnByIndex(GraphStoreConfiguration.EDGE_WEIGHT_INDEX) .getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } Double doubleVal = (Double) dynamicValue.get(interval, estimator); return doubleVal != null ? doubleVal : DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else if (value == null) { return DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING; } else { // Must be double return (Double) value; } } }
@Override public TimeIndex<Edge> getEdgeTimeIndex(GraphView view) { TimeIndexStore timeIndexStore = store.timeStore.edgeIndexStore; if (timeIndexStore != null) { if (view.isMainView()) { return timeIndexStore.getIndex(store); } return timeIndexStore.getIndex(((GraphViewImpl) view).directedDecorator); } return null; }
@Override public Object getAttribute(Column column, GraphView view) { checkColumn(column); if (!column.isDynamic()) { return getAttribute(column); } else { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null && !dynamicValue.isEmpty()) { Estimator estimator = column.getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } return dynamicValue.get(interval, estimator); } } } return null; }
public void deleteViewIndex(Graph graph) { if (graph.getView().isMainView()) { throw new IllegalArgumentException("Can't delete a view index for the main view"); } TimeIndexImpl index = viewIndexes.remove(graph.getView()); if (index != null) { index.clear(); } }
@Override public Object getAttribute(Column column, GraphView view) { checkColumn(column); if (!column.isDynamic()) { return getAttribute(column); } else { Interval interval = view.getTimeInterval(); checkViewExist((GraphView) view); int index = column.getIndex(); synchronized (this) { TimeMap dynamicValue = null; if (index < attributes.length) { dynamicValue = (TimeMap) attributes[index]; } if (dynamicValue != null && !dynamicValue.isEmpty()) { Estimator estimator = column.getEstimator(); if (estimator == null) { estimator = GraphStoreConfiguration.DEFAULT_ESTIMATOR; } return dynamicValue.get(interval, estimator); } } } return null; }