Package org.gephi.data.attributes.type

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


        this.high = high;

        if (low != Double.NEGATIVE_INFINITY || high != Double.POSITIVE_INFINITY) {
            Graph vgraph = model.getGraph(currentView);
            for (Node n : vgraph.getNodes().toArray()) {
                TimeInterval ti = (TimeInterval) n.getNodeData().getAttributes().getValue(
                        DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti != null && !ti.isInRange(low, high)) {
                    vgraph.removeNode(n);
                }
            }
            for (Edge e : vgraph.getEdges().toArray()) {
                TimeInterval ti = (TimeInterval) e.getEdgeData().getAttributes().getValue(
                        DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti != null && !ti.isInRange(low, high)) {
                    vgraph.removeEdge(e);
                }
            }
        }
    }
View Full Code Here


        graph.writeLock();

        if (attributeModel.getNodeTable().hasColumn(DynamicModel.TIMEINTERVAL_COLUMN)) {
            for (Node n : graph.getNodes().toArray()) {
                TimeInterval ti = (TimeInterval) n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti == null && !vgraph.contains(n)) {
                    vgraph.addNode(n);
                } else if (ti != null) {
                    boolean isInRange = ti.isInRange(interval);
                    boolean isInGraph = vgraph.contains(n);
                    if (!isInRange && isInGraph) {
                        vgraph.removeNode(n);
                    } else if (isInRange && !isInGraph) {
                        vgraph.addNode(n);
                    }
                }
            }
        }
        if (attributeModel.getEdgeTable().hasColumn(DynamicModel.TIMEINTERVAL_COLUMN)) {
            for (Edge e : graph.getEdges().toArray()) {
                TimeInterval ti = (TimeInterval) e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti == null && !vgraph.contains(e)
                        && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                    vgraph.addEdge(e);
                } else if (ti != null) {
                    boolean isInRange = ti.isInRange(interval);
                    boolean isInGraph = vgraph.contains(e);
                    if (!isInRange && isInGraph) {
                        vgraph.removeEdge(e);
                    } else if (isInRange && !isInGraph && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                        vgraph.addEdge(e);
View Full Code Here

    @Override
    public Graph getStrongSnapshotGraph(Interval interval) {
        Graph graph = model.getGraph(sourceView);
        Graph vgraph = model.getGraph(currentView);
        for (Node n : graph.getNodes().toArray()) {
            TimeInterval ti = (TimeInterval) n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
            if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(n)) {
                vgraph.removeNode(n);
            } else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(n)) {
                vgraph.addNode(n);
            }
        }
        for (Edge e : graph.getEdges().toArray()) {
            TimeInterval ti = (TimeInterval) e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
            if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(e)) {
                vgraph.removeEdge(e);
            } else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(e)
                    && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                vgraph.addEdge(e);
            }
        }
        return vgraph;
View Full Code Here

        return model.getGraph();
    }

    @Override
    public TimeInterval getInterval() {
        return new TimeInterval(low, high);
    }
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

            DynamicType dynamicValue = (DynamicType) attributeValue;
            Estimator estimator = dynamicModel == null ? Estimator.FIRST : dynamicModel.getEstimator();
            if (Number.class.isAssignableFrom(dynamicValue.getUnderlyingType())) {
                estimator = dynamicModel == null ? Estimator.AVERAGE : dynamicModel.getNumberEstimator();
            }
            TimeInterval timeInterval = new TimeInterval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
            if (dynamic) {
                timeInterval = dynamicModel.getVisibleInterval();
            }
            return dynamicValue.getValue(timeInterval.getLow(), timeInterval.getHigh(), estimator);
        }
        return attributeValue;
    }
View Full Code Here

        return attributeValue;
    }

    public float getEdgeWeight(Edge edge) {
        if (dynamic) {
            TimeInterval timeInterval = dynamicModel.getVisibleInterval();
            return edge.getWeight(timeInterval.getLow(), timeInterval.getHigh());
        }
        return edge.getWeight();
    }
View Full Code Here

        public boolean evaluate(Graph graph, Node node) {
            if (nodeColumn != null) {
                Object obj = node.getNodeData().getAttributes().getValue(nodeColumn.getIndex());
                if (obj != null) {
                    TimeInterval timeInterval = (TimeInterval) obj;
                    return timeInterval.isInRange(visibleInterval.getLow(), visibleInterval.getHigh());
                }
                return keepNull;
            }
            return true;
        }
View Full Code Here

        public boolean evaluate(Graph graph, Edge edge) {
            if (edgeColumn != null) {
                Object obj = edge.getEdgeData().getAttributes().getValue(edgeColumn.getIndex());
                if (obj != null) {
                    TimeInterval timeInterval = (TimeInterval) obj;
                    return timeInterval.isInRange(visibleInterval.getLow(), visibleInterval.getHigh());
                }
                return keepNull;
            }
            return true;
        }
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.