Package org.gephi.data.attributes.type

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


            for (NodeDraftImpl node : nodeMap.values()) {
                AttributeValue[] values = node.getAttributeRow().getValues();
                for (int i = 0; i < values.length; i++) {
                    AttributeValue val = values[i];
                    if (val.getValue() != null && val.getValue() instanceof DynamicType) {   //is Dynamic type
                        DynamicType type = (DynamicType) val.getValue();
                        type = DynamicUtilities.removeOverlapping(type);
                        node.getAttributeRow().setValue(val.getColumn(), type);
                    }
                }
            }
            for (EdgeDraftImpl edge : edgeMap.values()) {
                AttributeValue[] values = edge.getAttributeRow().getValues();
                for (int i = 0; i < values.length; i++) {
                    AttributeValue val = values[i];
                    if (val.getValue() != null && val.getValue() instanceof DynamicType) {   //is Dynamic type
                        DynamicType type = (DynamicType) val.getValue();
                        type = DynamicUtilities.removeOverlapping(type);
                        edge.getAttributeRow().setValue(val.getColumn(), type);
                    }
                }
            }
        }

        //Dynamic attributes bounds
        if (dynamicGraph && (timeIntervalMin != null || timeIntervalMax != null)) {
            for (NodeDraftImpl node : nodeMap.values()) {
                boolean issue = false;
                if (timeIntervalMin != null || timeIntervalMax != null) {
                    if (timeIntervalMin != null && node.getTimeInterval() != null && node.getTimeInterval().getLow() < timeIntervalMin) {
                        node.setTimeInterval((TimeInterval) DynamicUtilities.fitToInterval(node.getTimeInterval(), timeIntervalMin, node.getTimeInterval().getHigh()));
                        issue = true;
                    }
                    if (timeIntervalMax != null && node.getTimeInterval() != null && node.getTimeInterval().getHigh() > timeIntervalMax) {
                        node.setTimeInterval((TimeInterval) DynamicUtilities.fitToInterval(node.getTimeInterval(), node.getTimeInterval().getLow(), timeIntervalMax));
                        issue = true;
                    }
                    if (node.getTimeInterval() == null) {
                        node.setTimeInterval(new TimeInterval(timeIntervalMin, timeIntervalMax));
                    }
                }

                AttributeValue[] values = node.getAttributeRow().getValues();
                for (int i = 0; i < values.length; i++) {
                    AttributeValue val = values[i];
                    if (val.getValue() != null && val.getValue() instanceof DynamicType) {   //is Dynamic type
                        DynamicType type = (DynamicType) val.getValue();
                        if (timeIntervalMin != null && type.getLow() < timeIntervalMin) {
                            if (!Double.isInfinite(type.getLow())) {
                                issue = true;
                            }
                            node.getAttributeRow().setValue(val.getColumn(), DynamicUtilities.fitToInterval(type, timeIntervalMin, type.getHigh()));
                        }
                        if (timeIntervalMax != null && type.getHigh() > timeIntervalMax) {
                            if (!Double.isInfinite(type.getHigh())) {
                                issue = true;
                            }
                            node.getAttributeRow().setValue(val.getColumn(), DynamicUtilities.fitToInterval(type, type.getLow(), timeIntervalMax));
                        }
                    }
                }
                if (issue) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_TimeIntervalVerify_Node_OutOfBound", node.getId()), Level.WARNING));
                }
            }
            for (EdgeDraftImpl edge : edgeMap.values()) {
                boolean issue = false;
                if (timeIntervalMin != null || timeIntervalMax != null) {
                    if (timeIntervalMin != null && edge.getTimeInterval() != null && edge.getTimeInterval().getLow() < timeIntervalMin) {
                        edge.setTimeInterval((TimeInterval) DynamicUtilities.fitToInterval(edge.getTimeInterval(), timeIntervalMin, edge.getTimeInterval().getHigh()));
                        issue = true;
                    }
                    if (timeIntervalMax != null && edge.getTimeInterval() != null && edge.getTimeInterval().getHigh() > timeIntervalMax) {
                        edge.setTimeInterval((TimeInterval) DynamicUtilities.fitToInterval(edge.getTimeInterval(), edge.getTimeInterval().getLow(), timeIntervalMax));
                        issue = true;
                    }
                    if (edge.getTimeInterval() == null) {
                        edge.setTimeInterval(new TimeInterval(timeIntervalMin, timeIntervalMax));
                    }
                }

                AttributeValue[] values = edge.getAttributeRow().getValues();
                for (int i = 0; i < values.length; i++) {
                    AttributeValue val = values[i];
                    if (val.getValue() != null && val.getValue() instanceof DynamicType) {   //is Dynamic type
                        DynamicType type = (DynamicType) val.getValue();
                        if (timeIntervalMin != null && type.getLow() < timeIntervalMin) {
                            if (!Double.isInfinite(type.getLow())) {
                                issue = true;
                            }
                            edge.getAttributeRow().setValue(val.getColumn(), DynamicUtilities.fitToInterval(type, timeIntervalMin, type.getHigh()));
                        }
                        if (timeIntervalMax != null && type.getHigh() > timeIntervalMax) {
                            if (!Double.isInfinite(type.getHigh())) {
                                issue = true;
                            }
                            edge.getAttributeRow().setValue(val.getColumn(), DynamicUtilities.fitToInterval(type, type.getLow(), timeIntervalMax));
                        }
                    }
                }
                if (issue) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImportContainerImpl.class, "ImportContainerException_TimeIntervalVerify_Edge_OutOfBound", edge.getId()), Level.WARNING));
View Full Code Here


    @Test
    public void testCreateDynamicObjectMethods() {
        System.out.println("createDynamicObject(AttributeType, Interval)");
        AttributeType type = AttributeType.DYNAMIC_DOUBLE;
        Interval<Double> in = new Interval(1.0, 2.0, 3.0);
        DynamicType result = DynamicUtilities.createDynamicObject(type, in);
        DynamicType expResult = new DynamicDouble(new Interval<Double>(1.0, 2.0, 3.0));
        assertEquals(expResult, result);
        System.out.println("result:    " + result.toString());
        System.out.println("expResult: " + expResult.toString());
        System.out.println();
    }
View Full Code Here

    }

    @Test
    public void testFitToInterval() {
        System.out.println("fitToInterval(DynamicType, double, double)");
        DynamicType expResult = new DynamicDouble(new Interval<Double>(1.0, 2.0, 0.0));
        DynamicType result = DynamicUtilities.fitToInterval(
                new DynamicDouble(new Interval<Double>(1.0, 3.0, 0.0)),
                1.0, 2.0);
        assertEquals(expResult, result);
        System.out.println("result:    " + result.toString());
        System.out.println("expResult: " + expResult.toString());
        System.out.println();
    }
View Full Code Here

            assertEquals("2", values2[col2.getIndex()].getColumn().getId());
            assertEquals("Author", ((DynamicType) values2[col0.getIndex()].getValue()).getValue());
            assertEquals(new StringList("String1, String2, String 3"), values2[col2.getIndex()].getValue());

            AttributeValue[] values3 = n3.getAttributeRow().getValues();
            DynamicType val4 = (DynamicType) values3[col4.getIndex()].getValue();
            double low = DynamicUtilities.getDoubleFromXMLDateString("2009-01-01");
            double high = DynamicUtilities.getDoubleFromXMLDateString("2009-12-31");
            assertEquals(new Float(3f), val4.getValue(low, high));

            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2000-01-15", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[1]));
            assertEquals("2001-01-30", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[0]));
            assertEquals("2001-02-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[1]));
View Full Code Here

        return null;
    }

    public static Object getDynamicValue(Object value, double low, double high) {
        if (value != null && value instanceof DynamicType) {
            DynamicType dynamicType = (DynamicType) value;
            Estimator estimator = Estimator.FIRST;
            if (Number.class.isAssignableFrom(dynamicType.getUnderlyingType())) {
                estimator = Estimator.AVERAGE;
            }
            return dynamicType.getValue(low, high, estimator);
        }
        return value;
    }
View Full Code Here

        return false;
    }

    public Object getDynamicValue(Object attributeValue) {
        if (attributeValue != null && attributeValue instanceof DynamicType) {
            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

    private ArrayList<Number> getDynamicNumberColumnNumbers(Attributes row, AttributeColumn column) {
        if (!AttributeUtils.getDefault().isDynamicNumberColumn(column)) {
            throw new IllegalArgumentException("Column must be a dynamic number column");
        }
        ArrayList<Number> numbers = new ArrayList<Number>();
        DynamicType dynamicList = (DynamicType) row.getValue(column.getIndex());
        if (dynamicList == null) {
            return numbers;
        }
        Number[] dynamicNumbers;
        dynamicNumbers = (Number[]) dynamicList.getValues().toArray(new Number[0]);
        Number n;
        for (int i = 0; i < dynamicNumbers.length; i++) {
            n = (Number) dynamicNumbers[i];
            if (n != null) {
                numbers.add((Number) n);
View Full Code Here

                Object draftValue = nodeDraft.getAttributeRow().getValue(col.getId());
                if (col.getType().isDynamicType()) {
                    if (draftValue == null && val != null) {
                        removePoint(col.getType(), (DynamicType) val, point);
                    } else if (draftValue != null) {
                        DynamicType dynamicValue = addPoint(col.getType(), (DynamicType) val, draftValue, point);
                        row.setValue(col.getIndex(), dynamicValue);
                    }
                } else if (draftValue != null && !col.getOrigin().equals(AttributeOrigin.PROPERTY)) {
                    row.setValue(col.getIndex(), draftValue);
                }
View Full Code Here

                }
                if (col.getType().isDynamicType()) {
                    if (draftValue == null && val != null) {
                        removePoint(col.getType(), (DynamicType) val, point);
                    } else if (draftValue != null) {
                        DynamicType dynamicValue = addPoint(col.getType(), (DynamicType) val, draftValue, point);
                        row.setValue(col.getIndex(), dynamicValue);
                    }
                } else if (draftValue != null && !col.getOrigin().equals(AttributeOrigin.PROPERTY)) {
                    row.setValue(col.getIndex(), draftValue);
                }
View Full Code Here

            throw new RuntimeException("DynamicProcessor doesn't support overlapping intervals.");
        } else {
            Interval<?> toRemove = intervals.get(0);
            if (!toRemove.getValue().equals(value)) {
                Interval toAdd = new Interval(toRemove.getLow(), point, toRemove.isLowExcluded(), true, toRemove.getValue());
                DynamicType updated = DynamicUtilities.createDynamicObject(type, source, toAdd, toRemove);
                toAdd = new Interval(point, Double.POSITIVE_INFINITY, value);
                updated = DynamicUtilities.createDynamicObject(type, updated, toAdd);
                return updated;
            }
        }
View Full Code Here

TOP

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

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.