Package org.gephi.data.attributes.type

Examples of org.gephi.data.attributes.type.TimeInterval


        }

        public void dynamicModelChanged(DynamicModelEvent event) {
            switch (event.getEventType()) {
                case VISIBLE_INTERVAL:
                    TimeInterval interval = (TimeInterval) event.getData();
                    getProperties()[0].setValue(new Range(interval.getLow(), interval.getHigh(), min, max));
                    break;
            }
        }
View Full Code Here


                node = map.get(id);
            } else if (label != null && map.get(label) != null && labelmatching) {
                node = map.get(label);
            }

            TimeInterval timeInterval = null;
            if (node == null) {
                //Node is new
                node = factory.newNode(draftNode.isAutoId() ? null : draftNode.getId());
                flushToNode(draftNode, node);
                draftNode.setNode(node);
                newNodeCount++;
            } else {
                timeInterval = (TimeInterval) node.getNodeData().getAttributes().getValue(nodeDynamicColumn.getIndex());
                flushToNodeAttributes(draftNode, node);
                draftNode.setNode(node);
            }
            nodesInDraft.add(node);

            //Add Point
            node.getNodeData().getAttributes().setValue(nodeDynamicColumn.getIndex(), addPoint(timeInterval, point));
        }

        //Push nodes in data structure
        for (NodeDraftGetter draftNode : container.getNodes()) {
            Node n = draftNode.getNode();
            NodeDraftGetter[] parents = draftNode.getParents();
            if (parents != null) {
                for (int i = 0; i < parents.length; i++) {
                    Node parent = parents[i].getNode();
                    graph.addNode(n, parent);
                }
            } else {
                graph.addNode(n);
            }
        }

        //Remove point from all nodes not in draft
        for (Node node : graph.getNodes()) {
            if (!nodesInDraft.contains(node)) {
                TimeInterval timeInterval = (TimeInterval) node.getNodeData().getAttributes().getValue(nodeDynamicColumn.getIndex());
                node.getNodeData().getAttributes().setValue(nodeDynamicColumn.getIndex(), removePoint(timeInterval, point));
            }
        }

        //Create all edges and push to data structure
        Set<Edge> edgesInDraft = new HashSet<Edge>();
        int newEdgeCount = 0;
        for (EdgeDraftGetter draftEdge : container.getEdges()) {
            Node source = draftEdge.getSource().getNode();
            Node target = draftEdge.getTarget().getNode();
            Edge edge = graph.getEdge(source, target);
            TimeInterval timeInterval = null;
            if (edge == null) {
                //Edge is new
                switch (container.getEdgeDefault()) {
                    case DIRECTED:
                        edge = factory.newEdge(draftEdge.isAutoId() ? null : draftEdge.getId(), source, target, draftEdge.getWeight(), true);
                        break;
                    case UNDIRECTED:
                        edge = factory.newEdge(draftEdge.isAutoId() ? null : draftEdge.getId(), source, target, draftEdge.getWeight(), false);
                        break;
                    case MIXED:
                        edge = factory.newEdge(draftEdge.isAutoId() ? null : draftEdge.getId(), source, target, draftEdge.getWeight(), draftEdge.getType().equals(EdgeType.UNDIRECTED) ? false : true);
                        break;
                }
                newEdgeCount++;
                graph.addEdge(edge);
                flushToEdge(draftEdge, edge);
            } else {
                timeInterval = (TimeInterval) edge.getEdgeData().getAttributes().getValue(edgeDynamicColumn.getIndex());
                flushToEdgeAttributes(draftEdge, edge);
            }
            edgesInDraft.add(edge);

            //Add Point
            edge.getEdgeData().getAttributes().setValue(edgeDynamicColumn.getIndex(), addPoint(timeInterval, point));
        }

        //Remove point from all edges not in draft
        for (Edge edge : graph.getEdges()) {
            if (!edgesInDraft.contains(edge)) {
                TimeInterval timeInterval = (TimeInterval) edge.getEdgeData().getAttributes().getValue(edgeDynamicColumn.getIndex());
                edge.getEdgeData().getAttributes().setValue(edgeDynamicColumn.getIndex(), removePoint(timeInterval, point));
            }
        }

        System.out.println("# New Nodes loaded: " + newNodeCount + "\n# New Edges loaded: " + newEdgeCount);
View Full Code Here

        }
    }

    private TimeInterval addPoint(TimeInterval source, double point) {
        if (source == null) {
            return new TimeInterval(point, Double.POSITIVE_INFINITY);
        }
        List<Interval<Double[]>> intervals = source.getIntervals(point, point);
        if (intervals.isEmpty()) {
            return new TimeInterval(source, point, Double.POSITIVE_INFINITY);
        }
        return source;
    }
View Full Code Here

                return source;
            }

            Double[] toAdd = new Double[]{toRemove.getLow(), point};

            return new TimeInterval(source, toAdd[0], toAdd[1], toRemove.isLowExcluded(), true, toRemove.getLow(), toRemove.getHigh(), toRemove.isLowExcluded(), toRemove.isHighExcluded());
        }
        return source;
    }
View Full Code Here

            graph = graphModel.getHierarchicalGraphVisible();
        } else {
            graph = graphModel.getHierarchicalGraph();
        }
        DynamicModel dynamicModel = workspace.getLookup().lookup(DynamicModel.class);
        visibleInterval = dynamicModel != null && exportVisible ? dynamicModel.getVisibleInterval() : new TimeInterval();
        try {
            exportData(createDocument(), graph, attributeModel);
        } catch (Exception e) {
            graph.readUnlockAll();
            throw new RuntimeException(e);
View Full Code Here

        final boolean isEndColumnNumeric = endColumn != null ? AttributeUtils.getDefault().isNumberColumn(endColumn) : false;

        AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
        Object value;
        double start, end;
        TimeInterval timeInterval;
        for (Attributes row : ac.getTableAttributeRows(table)) {
            if (startColumnIndex != -1) {
                value = row.getValue(startColumnIndex);
                if (value != null) {
                    if (isStartColumnNumeric) {
                        start = ((Number) value).doubleValue();
                    } else {
                        start = parseDouble(value.toString(), defaultStart);
                    }
                } else {
                    start = defaultStart;
                }
            } else {
                start = defaultStart;
            }
            if (endColumnIndex != -1) {
                value = row.getValue(endColumnIndex);
                if (value != null) {
                    if (isEndColumnNumeric) {
                        end = ((Number) value).doubleValue();
                    } else {
                        end = parseDouble(value.toString(), defaultEnd);
                    }
                } else {
                    end = defaultEnd;
                }
            } else {
                end = defaultEnd;
            }
            if (!Double.isInfinite(start) && !Double.isInfinite(end) && start > end) {
                //When start>end, check what column was provided and keep its value. If both columns were provided, set an infinite interval:
                if (startColumnIndex == -1) {
                    start = Double.NEGATIVE_INFINITY;
                } else if (endColumnIndex == -1) {
                    end = Double.POSITIVE_INFINITY;
                } else {
                    start = Double.NEGATIVE_INFINITY;
                    end = Double.POSITIVE_INFINITY;
                }
            }
            timeInterval = new TimeInterval(start, end);
            row.setValue(timeIntervalColumnIndex, timeInterval);
        }
        Lookup.getDefault().lookup(DynamicController.class).setTimeFormat(DynamicModel.TimeFormat.DOUBLE);
        return timeIntervalColumn;
    }
View Full Code Here

        double defaultEnd = parseDateToDouble(dateFormat, defaultEndDate, Double.POSITIVE_INFINITY);

        AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
        Object value;
        double start, end;
        TimeInterval timeInterval;
        for (Attributes row : ac.getTableAttributeRows(table)) {
            if (startColumnIndex != -1) {
                value = row.getValue(startColumnIndex);
                start = parseDateToDouble(dateFormat, value != null ? value.toString() : null, defaultStart);
            } else {
                start = defaultStart;
            }
            if (endColumnIndex != -1) {
                value = row.getValue(endColumnIndex);
                end = parseDateToDouble(dateFormat, value != null ? value.toString() : null, defaultEnd);
            } else {
                end = defaultEnd;
            }
            if (!Double.isInfinite(start) && !Double.isInfinite(end) && start > end) {
                //When start>end, check what column was provided and keep its value. If both columns were provided, set an infinite interval:
                if (startColumnIndex == -1) {
                    start = Double.NEGATIVE_INFINITY;
                } else if (endColumnIndex == -1) {
                    end = Double.POSITIVE_INFINITY;
                } else {
                    start = Double.NEGATIVE_INFINITY;
                    end = Double.POSITIVE_INFINITY;
                }
            }
            timeInterval = new TimeInterval(start, end);
            row.setValue(timeIntervalColumnIndex, timeInterval);
        }
        Lookup.getDefault().lookup(DynamicController.class).setTimeFormat(DynamicModel.TimeFormat.DATE);
        return timeIntervalColumn;
    }
View Full Code Here

        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) {
View Full Code Here

        Modeler arrowInit = engine.getModelClasses()[AbstractEngine.CLASS_ARROW].getCurrentModeler();

        float minWeight = Float.POSITIVE_INFINITY;
        float maxWeight = Float.NEGATIVE_INFINITY;

        TimeInterval timeInterval = DynamicUtilities.getVisibleInterval(dynamicModel);

        for (Edge edge : graph.getMetaEdges()) {
            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) {
View Full Code Here

            xmlWriter.writeAttribute("xsi:schemaLocation", GEXF_NAMESPACE_LOCATION);

            if (exportDynamic) {
                DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
                dynamicModel = dynamicController != null ? dynamicController.getModel(workspace) : null;
                visibleInterval = dynamicModel == null ? null : exportVisible ? dynamicModel.getVisibleInterval() : new TimeInterval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
            }

            writeMeta(xmlWriter);
            writeGraph(xmlWriter, graph);
View Full Code Here

TOP

Related Classes of org.gephi.data.attributes.type.TimeInterval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.