commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1221138 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java
Date Tue, 20 Dec 2011 08:32:46 GMT
Author: simonetripodi
Date: Tue Dec 20 08:32:45 2011
New Revision: 1221138

URL: http://svn.apache.org/viewvc?rev=1221138&view=rev
Log:
[SANDBOX-346] DotExporter only exports weights that extend Number - patch provided by Claudio
Squarcella

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java?rev=1221138&r1=1221137&r2=1221138&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DotExporter.java
Tue Dec 20 08:32:45 2011
@@ -204,15 +204,20 @@ public final class DotExporter
                 }
                 if ( edge instanceof WeightedEdge )
                 {
-                    printWriter.format( " " );
+                    Object weight = ( (WeightedEdge<?>) edge ).getWeight();
 
-                    if ( !attributesFound )
+                    if( weight instanceof Number )
                     {
-                        printWriter.format( "[" );
-                        attributesFound = true;
-                    }
+                        printWriter.format( " " );
+
+                        if ( !attributesFound )
+                        {
+                            printWriter.format( "[" );
+                            attributesFound = true;
+                        }
 
-                    printWriter.format( "weight=%s", ( (WeightedEdge<?>) edge ).getWeight()
);
+                        printWriter.format( "weight=%f", ( (Number) weight ).doubleValue()
);
+                    }
                 }
 
                 if ( attributesFound )



Mime
View raw message