Package org.gephi.data.attributes.api

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


                    final Object propertyValue = edge.getProperty(propertyKey);
                    AttributeColumn attributeColumn;
                    if (attributeModel.getEdgeTable().hasColumn(propertyKey)) {
                        attributeColumn = attributeModel.getEdgeTable().getColumn(propertyKey);
                    } else {
                        final AttributeType attributeType = AttributeTypeMapper.map(propertyValue);
                        attributeColumn = attributeModel.getEdgeTable().addColumn(propertyKey, attributeType);
                    }
                    gephiEdge.addAttributeValue(attributeColumn, propertyValue);
                    report.log(NbBundle.getMessage(GraphDbImporter.class,
                            "Report_RelAttributeAdded", propertyKey, propertyValue));
View Full Code Here


    public void readColumn(XMLStreamReader reader, AttributeTableImpl table) throws XMLStreamException {

        int index = 0;
        String id = "";
        String title = "";
        AttributeType type = AttributeType.STRING;
        AttributeOrigin origin = AttributeOrigin.DATA;
        String defaultValue = "";

        boolean end = false;
        String name = null;
        while (reader.hasNext() && !end) {
            int t = reader.next();

            switch (t) {
                case XMLStreamReader.START_ELEMENT:
                    name = reader.getLocalName();
                    break;
                case XMLStreamReader.CHARACTERS:
                    if (!reader.isWhiteSpace()) {
                        if (ELEMENT_COLUMN_INDEX.equalsIgnoreCase(name)) {
                            index = Integer.parseInt(reader.getText());
                        } else if (ELEMENT_COLUMN_ID.equalsIgnoreCase(name)) {
                            id += reader.getText();
                        } else if (ELEMENT_COLUMN_TITLE.equalsIgnoreCase(name)) {
                            title += reader.getText();
                        } else if (ELEMENT_COLUMN_TYPE.equalsIgnoreCase(name)) {
                            type = AttributeType.valueOf(reader.getText());
                        } else if (ELEMENT_COLUMN_ORIGIN.equalsIgnoreCase(name)) {
                            origin = AttributeOrigin.valueOf(reader.getText());
                        } else if (ELEMENT_COLUMN_DEFAULT.equalsIgnoreCase(name)) {
                            if (!reader.getText().isEmpty()) {
                                defaultValue += reader.getText();
                            }
                        }
                    }
                    break;
                case XMLStreamReader.END_ELEMENT:
                    if (ELEMENT_COLUMN.equalsIgnoreCase(reader.getLocalName())) {
                        end = true;
                    }
                    break;
            }
        }
        Object defaultVal = !defaultValue.isEmpty() ? type.parse(defaultValue) : null;
        if (!table.hasColumn(title)) {
            table.addColumn(id, title, type, origin, defaultVal);
        } else {
            table.replaceColumn(table.getColumn(title), id, title, type, origin, defaultVal);
        }
View Full Code Here

        AttributeColumn attributeColumn = attributeTable.getColumn(column);
        if (attributeColumn != null) {
            setValue(attributeColumn, value);
        } else {
            //add column
            AttributeType type = AttributeType.parse(value);
            //System.out.println("parsed value type: " + value.getClass());
            if (type != null) {
                attributeColumn = attributeTable.addColumn(column, type);
                setValue(attributeColumn, value);
            }
View Full Code Here

            return new AttributeValueImpl((AttributeColumnImpl) column, null);
        }
       
        //If the column is not a delegate (wrong type value allowed), try to convert value to correct type if necessary
        if(!column.getOrigin().equals(AttributeOrigin.DELEGATE)){
            AttributeType targetType = column.getType();
            if (!value.getClass().equals(targetType.getType())) {
                try {
                    value = targetType.parse(value.toString());//Try to convert to target type
                } catch (Exception ex) {
                    return new AttributeValueImpl((AttributeColumnImpl) column, null);//Could not parse
                }
            }
        }
View Full Code Here

    @Override
    public boolean areAllColumnsOfSameType(AttributeColumn[] columns) {
        if (columns.length == 0) {
            return false;
        }
        AttributeType type = columns[0].getType();
        return areAllColumnsOfType(columns, type);
    }
View Full Code Here

        return true;
    }

    @Override
    public boolean isNumberColumn(AttributeColumn column) {
        AttributeType attributeType = column.getType();
        return Number.class.isAssignableFrom(attributeType.getType());
    }
View Full Code Here

        return true;
    }

    @Override
    public boolean isNumberListColumn(AttributeColumn column) {
        AttributeType attributeType = column.getType();
        return NumberList.class.isAssignableFrom(attributeType.getType());
    }
View Full Code Here

                case XMLStreamReader.END_ELEMENT:
                    if (ELEMENT_NODE_ROW.equalsIgnoreCase(reader.getLocalName()) || ELEMENT_EDGE_ROW.equalsIgnoreCase(reader.getLocalName())) {
                        end = true;
                    }
                    if (!value.isEmpty() && index != null) {
                        AttributeType type = table.getColumn(index).getType();
                        Object v = type.parse(value);
                        if (v != null) {
                            v = model.getManagedValue(v, type);
                        } else {
                            Logger.getLogger(AttributeRowSerializer.class.getName()).log(Level.WARNING, "Unable to parse \"{0}\" as type {1}", new Object[]{value, type.toString()});
                        }
                        row.setValue(index, v);
                    }
                    value = "";
                    index = null;
View Full Code Here

    public boolean isNumberColumn(AttributeColumn column) {
        return AttributeUtils.getDefault().isNumberColumn(column);
    }

    public boolean isStringColumn(AttributeColumn column) {
        AttributeType type = column.getType();
        if (type == AttributeType.STRING) {
            return true;
        }
        return false;
    }
View Full Code Here

                if (multipleNodes) {
                    wrap = new MultipleRowsAttributeValueWrapper(nodes, value.getColumn(),currentTimeFormat);
                } else {
                    wrap = new SingleRowAttributeValueWrapper(nodes[0], value.getColumn(),currentTimeFormat);
                }
                AttributeType type = value.getColumn().getType();
                Property p;
                if (ac.canChangeColumnData(value.getColumn())) {
                    //Editable column, provide "set" method:
                    if (!EditWindowUtils.NotSupportedTypes.contains(type)) {//The AttributeType can be edited by default:
                        p = new PropertySupport.Reflection(wrap, type.getType(), "getValue" + type.getType().getSimpleName(), "setValue" + type.getType().getSimpleName());
                    } else {//Use the AttributeType as String:
                        p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString");
                    }
                } else {
                    //Not editable column, do not provide "set" method:
                    if (!EditWindowUtils.NotSupportedTypes.contains(type)) {//The AttributeType can be edited by default:
                        p = new PropertySupport.Reflection(wrap, type.getType(), "getValue" + type.getType().getSimpleName(), null);
                    } else {//Use the AttributeType as String:
                        p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
                    }
                }
                p.setDisplayName(value.getColumn().getTitle());
View Full Code Here

TOP

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

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.