← Back to team overview

gephi.team team mailing list archive

Re: [Question #109601]: Read positions from dot files

 

Question #109601 on Gephi changed:
https://answers.launchpad.net/gephi/+question/109601

tcb posted a new comment:
Hi,

This is a first attempt at a patch to read positions from DOT files. It
seems to import my dot files with positions just fine. It should work
for 3D as well as 2D- but I have only tested 2D. I don't know how to
handle the error messages- from looking at the rest of the code I added
a new one "importerDOT_error_posunreachable".

The position tag for the nodes should be of the form:

  pos="x, y"

It would be nice to be able to specify the size of the nodes too- I'll
look into that soon.


--- ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterDOT.java.orig	2010-06-15 18:23:46.000000000 +0100
+++ ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterDOT.java	2010-06-15 19:29:33.000000000 +0100
@@ -194,6 +194,33 @@
                     report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_colorunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
                     streamTokenizer.pushBack();
                 }
+            } else if (streamTokenizer.sval.equalsIgnoreCase("pos")) {
+                streamTokenizer.nextToken();
+                if (streamTokenizer.ttype == '=') {
+                    streamTokenizer.nextToken();
+                    if (streamTokenizer.ttype == StreamTokenizer.TT_WORD || streamTokenizer.ttype == '"') {
+                        try{
+                            String[] positions = streamTokenizer.sval.split(",");
+                            if(positions.length == 2) {
+                                nodeDraft.setX(Float.parseFloat(positions[0]));
+                                nodeDraft.setY(Float.parseFloat(positions[1]));
+                            } else if(positions.length == 3) {
+                                nodeDraft.setX(Float.parseFloat(positions[0]));
+                                nodeDraft.setY(Float.parseFloat(positions[1]));
+                                nodeDraft.setZ(Float.parseFloat(positions[2]));
+                            }
+
+                        } catch(Exception e) {
+
+                        }
+                    } else {
+                        report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_posunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
+                        streamTokenizer.pushBack();
+                    }
+                } else {
+                    report.logIssue(new Issue(NbBundle.getMessage(ImporterDOT.class, "importerDOT_error_posunreachable", streamTokenizer.lineno()), Issue.Level.WARNING));
+                    streamTokenizer.pushBack();
+                }
             } else if (streamTokenizer.sval.equalsIgnoreCase("style")) {
                 streamTokenizer.nextToken();
                 if (streamTokenizer.ttype == '=') {

You received this question notification because you are a member of
Gephi Team, which is an answer contact for Gephi.