~raymond-borgan/gephi/0.7alpha4

« back to all changes in this revision

Viewing changes to ImportAPI/src/org/gephi/io/importer/impl/NodeDraftImpl.java

  • Committer: Mathieu Bastian
  • Date: 2010-07-27 10:32:36 UTC
  • Revision ID: mathieu.bastian@gmail.com-20100727103236-pslsvtw6cely2e6t
Debug dynamic attributes parsing and import in ImportAPI. Debug and test ImporterGEXF2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import java.util.List;
27
27
import org.gephi.data.attributes.api.AttributeColumn;
28
28
import org.gephi.data.attributes.api.AttributeRow;
 
29
import org.gephi.data.attributes.api.AttributeType;
 
30
import org.gephi.data.attributes.type.DynamicLong;
29
31
import org.gephi.data.attributes.type.DynamicType;
30
32
import org.gephi.data.attributes.type.Interval;
31
33
import org.gephi.data.attributes.type.TimeInterval;
 
34
import org.gephi.data.attributes.type.TypeConvertor;
32
35
import org.gephi.dynamic.DynamicUtilities;
33
36
import org.gephi.graph.api.Node;
34
37
import org.gephi.io.importer.api.NodeDraft;
201
204
 
202
205
    public void addAttributeValue(AttributeColumn column, Object value) {
203
206
        if (column.getType().isDynamicType() && !(value instanceof DynamicType)) {
 
207
            if (value instanceof String && !column.getType().equals(AttributeType.DYNAMIC_STRING)) {
 
208
                //Value needs to be parsed
 
209
                value = TypeConvertor.getStaticType(column.getType()).parse(value);
 
210
            }
204
211
            //Wrap value in a dynamic type
205
212
            value = DynamicUtilities.createDynamicObject(column.getType(), new Interval(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, value));
206
213
        }
238
245
        if (start == null && end == null) {
239
246
            throw new IllegalArgumentException(NbBundle.getMessage(NodeDraftImpl.class, "ImportContainerException_TimeInterval_Empty"));
240
247
        }
 
248
        if (value instanceof String && !column.getType().equals(AttributeType.DYNAMIC_STRING)) {
 
249
            //Value needs to be parsed
 
250
            AttributeType staticType = TypeConvertor.getStaticType(column.getType());
 
251
            value = staticType.parse((String) value);
 
252
        }
241
253
        Object sourceVal = attributeRow.getValue(column);
242
254
        if (sourceVal != null && sourceVal instanceof DynamicType) {
243
255
            value = DynamicUtilities.createDynamicObject(column.getType(), (DynamicType) sourceVal, new Interval(start, end, value));