Package org.gephi.data.attributes.api

Examples of org.gephi.data.attributes.api.AttributeColumn


                if (colorHex != -1) {
                    node.setColor(new Color(colorHex));
                }
            } else {
                AttributeTable nodeClass = container.getAttributeModel().getNodeTable();
                AttributeColumn column = null;
                if ((column = nodeClass.getColumn(key)) == null) {
                    column = nodeClass.addColumn(key, AttributeType.STRING);
                    report.log("Node attribute " + column.getTitle() + " (" + column.getType() + ")");
                }
                node.addAttributeValue(column, value.toString());
            }
        }
        return ret;
View Full Code Here


                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGML.class, "importerGML_error_directedparse", edge.toString()), Issue.Level.WARNING));
                }
            } else {
                AttributeTable edgeClass = container.getAttributeModel().getEdgeTable();
                AttributeColumn column = null;
                if ((column = edgeClass.getColumn(key)) == null) {
                    column = edgeClass.addColumn(key, AttributeType.STRING);
                    report.log("Edge attribute " + column.getTitle() + " (" + column.getType() + ")");
                }
                edge.addAttributeValue(column, value.toString());
            }
        }
        return ret;
View Full Code Here

        }
    }

    private void mergeAttributes(AttributeRow srcRow, AttributeRow dstRow) {
        for (AttributeValue v : srcRow.getValues()) {
            AttributeColumn col = v.getColumn();
            if (!col.getOrigin().equals(AttributeOrigin.PROPERTY)) {
                Object existingVal = dstRow.getValue(col.getIndex());
                if (v.getValue() != null && existingVal == null) {
                    dstRow.setValue(col.getIndex(), existingVal);
                }
            }
        }
    }
View Full Code Here

                NodeProperties p = properties.getNodeProperty(columnName);
                if (p != null) {
                    injectNodeProperty(p, rs, i + 1, node);
                } else {
                    //Inject node attributes
                    AttributeColumn col = nodeClass.getColumn(columnName);
                    injectNodeAttribute(rs, i + 1, col, node);
                }
            }
            container.addNode(node);
            ++count;
View Full Code Here

                EdgeProperties p = properties.getEdgeProperty(columnName);
                if (p != null) {
                    injectEdgeProperty(p, rs, i + 1, edge);
                } else {
                    //Inject edge attributes
                    AttributeColumn col = edgeClass.getColumn(columnName);
                    injectEdgeAttribute(rs, i + 1, col, edge);
                }
            }

            container.addEdge(edge);
View Full Code Here

        assertNotNull(n7);
        assertNotNull(n8);
        assertNotNull(n9);

        ContainerUnloader unloader = container.getUnloader();
        AttributeColumn col0 = unloader.getAttributeModel().getNodeTable().getColumn("0");
        AttributeColumn col1 = unloader.getAttributeModel().getNodeTable().getColumn("1");
        AttributeColumn col2 = unloader.getAttributeModel().getNodeTable().getColumn("2");
        AttributeColumn col3 = unloader.getAttributeModel().getNodeTable().getColumn("3");
        AttributeColumn col4 = unloader.getAttributeModel().getNodeTable().getColumn("4");

        try {
            assertEquals("Node 1", n1.getLabel());
            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[0]));
            assertEquals("2000-12-31", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[1]));

            AttributeValue[] values1 = n1.getAttributeRow().getValues();
            assertEquals("0", values1[col0.getIndex()].getColumn().getId());
            assertEquals("3", values1[col3.getIndex()].getColumn().getId());
            assertEquals("Author", ((DynamicType) values1[col0.getIndex()].getValue()).getValue());
            assertEquals(new Float(1), ((DynamicType) values1[col3.getIndex()].getValue()).getValue());

            AttributeValue[] values2 = n2.getAttributeRow().getValues();
            assertEquals("0", values2[col0.getIndex()].getColumn().getId());
            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]));
View Full Code Here

            public void attributesChanged(AttributeEvent event) {
                switch (event.getEventType()) {
                    case ADD_COLUMN:
                        AttributeColumn[] addedColumns = event.getData().getAddedColumns();
                        for (int i = 0; i < addedColumns.length; i++) {
                            AttributeColumn col = addedColumns[i];
                            if (col.getType().isDynamicType() && attUtils.isNodeColumn(col)) {
                                nodeDynamicColumns.add(col);
                            } else if (col.getType().isDynamicType() && attUtils.isEdgeColumn(col)) {
                                edgeDynamicColumns.add(col);
                            }
                        }
                        break;
                    case REMOVE_COLUMN:
                        AttributeColumn[] removedColumns = event.getData().getRemovedColumns();
                        for (int i = 0; i < removedColumns.length; i++) {
                            AttributeColumn col = removedColumns[i];
                            if (col.getType().isDynamicType() && attUtils.isNodeColumn(col)) {
                                nodeDynamicColumns.remove(col);
                            } else if (col.getType().isDynamicType() && attUtils.isEdgeColumn(col)) {
                                edgeDynamicColumns.remove(col);
                            }
                        }
                        break;
                    case SET_VALUE:
                        AttributeValue[] values = event.getData().getTouchedValues();
                        for (int i = 0; i < values.length; i++) {
                            AttributeValue val = values[i];
                            if (val.getValue() != null) {
                                AttributeColumn col = values[i].getColumn();
                                if (col.getType().isDynamicType()) {
                                    DynamicType<?> dynamicType = (DynamicType) val.getValue();
                                    for (Interval interval : dynamicType.getIntervals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)) {
                                        timeIntervalIndex.add(interval);
                                    }
                                }
View Full Code Here

                nodeColumns[i - 1] = new GDFColumn(GDFColumn.NodeGuessColumn.LABELVISIBLE);
                report.log("Node property found: labelvisible");
            } else {
                AttributeTable nodeClass = container.getAttributeModel().getNodeTable();
                if (!nodeClass.hasColumn(columnName)) {
                    AttributeColumn newColumn = nodeClass.addColumn(columnName, type);
                    nodeColumns[i - 1] = new GDFColumn(newColumn);
                    report.log("Node attribute " + columnName + " (" + type.getTypeString() + ")");
                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGDF.class, "importerGDF_error_dataformat8", columnName), Issue.Level.SEVERE));
                }
View Full Code Here

                edgeColumns[i - 2] = new GDFColumn(GDFColumn.EdgeGuessColumn.LABELVISIBLE);
                report.log("Edge property found: labelvisible");
            } else {
                AttributeTable edgeClass = container.getAttributeModel().getEdgeTable();
                if (!edgeClass.hasColumn(columnName)) {
                    AttributeColumn newColumn = edgeClass.addColumn(columnName, type);
                    edgeColumns[i - 2] = new GDFColumn(newColumn);
                    report.log("Edge attribute " + columnName + " (" + type.getTypeString() + ")");
                } else {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGDF.class, "importerGDF_error_dataformat9", columnName), Issue.Level.SEVERE));
                }
View Full Code Here

                }
                return;
            }

            //Data attribute value
            AttributeColumn column = container.getAttributeModel().getNodeTable().getColumn(fore);
            if (column != null) {
                try {
                    Object val = column.getType().parse(value);
                    node.addAttributeValue(column, val);
                } catch (Exception e) {
                    report.logIssue(new Issue(NbBundle.getMessage(ImporterGraphML.class, "importerGraphML_error_datavalue", fore, node, column.getTitle()), Issue.Level.SEVERE));
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.gephi.data.attributes.api.AttributeColumn

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.