Author: [email protected]
Date: Tue Jun 30 14:59:48 2009
New Revision: 5649

Modified:
    trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
    trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java

Log:
Sort and format.

Modified:  
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java
==============================================================================
---  
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java       
 
(original)
+++  
trunk/tools/soyc-vis/src/com/google/gwt/soyc/MakeTopLevelHtmlForPerm.java       
 
Tue Jun 30 14:59:48 2009
@@ -130,8 +130,126 @@
      return escaped;
    }

-  public void makeBreakdownShell(SizeBreakdown breakdown)
-      throws IOException {
+  /**
+   * Adds a header line indicating which breakdown is being analyzed.
+   */
+  private static void addHeaderWithBreakdownContext(SizeBreakdown  
breakdown,
+      final PrintWriter outFile) {
+    outFile.println("<hr>");
+    outFile.println("<b>(Analyzing code subset: " +  
breakdown.getDescription()
+        + ")</b>");
+    outFile.println("<hr>");
+  }
+
+  private static String classesInPackageFileName(SizeBreakdown breakdown,
+      String packageName) {
+    return breakdown.getId() + "_" + packageName + "_Classes.html";
+  }
+
+  /**
+   * Convert a potentially long string into a short file name. The current
+   * implementation simply hashes the long name.
+   */
+  private static String filename(String longFileName) {
+    try {
+      return  
Util.computeStrongName(longFileName.getBytes(Util.DEFAULT_ENCODING));
+    } catch (UnsupportedEncodingException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  /**
+   * Return a {...@link File} object for a file to be emitted into the output
+   * directory.
+   */
+  private static File getOutFile(String localFileName) {
+    File outDir = new File(GlobalInformation.settings.out.get());
+    return new File(outDir, localFileName);
+  }
+
+  private static String makeCodeTypeHtml(SizeBreakdown breakdown,
+      Map<String, CodeCollection> nameToCodeColl) throws IOException {
+    String outFileName = breakdown.getId() + "_codeTypeBreakdown.html";
+    float maxSize = 0f;
+    float sumSize = 0f;
+    TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>(
+        Collections.reverseOrder());
+
+    // TODO(kprobst): turn this into a multimap?
+    // com.google.common.collect.TreeMultimap
+    for (String codeType : nameToCodeColl.keySet()) {
+      float curSize =  
nameToCodeColl.get(codeType).getCumPartialSize(breakdown);
+      sumSize += curSize;
+
+      if (curSize != 0f) {
+        sortedCodeTypes.put(curSize, codeType);
+        if (curSize > maxSize) {
+          maxSize = curSize;
+        }
+      }
+    }
+
+    final PrintWriter outFile = new PrintWriter(getOutFile(outFileName));
+
+    outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
+    outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
+    outFile.println("<html>");
+    outFile.println("<head>");
+    outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
+    outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\"  
media=\"screen\">");
+    outFile.println("</head>");
+    outFile.println("<body>");
+
+    int yOffset = 0;
+    for (Float size : sortedCodeTypes.keySet()) {
+
+      String codeType = sortedCodeTypes.get(size);
+      String drillDownFileName = breakdown.getId() + "_" + codeType
+          + "Classes.html";
+
+      float ratio = (size / maxSize) * 79;
+      float perc = (size / sumSize) * 100;
+
+      if (ratio < 3) {
+        ratio = 3;
+      }
+
+      outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+          + yOffset + "px; left: 110px;\">");
+      outFile.println("<div id=\"lb\">");
+      outFile.println("<div id=\"rb\">");
+      outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+      outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+      outFile.println("<div id=\"content\">");
+      outFile.println("</div>");
+      outFile.println("</div></div></div></div>");
+      outFile.println("</div></div></div></div>");
+      outFile.println("</div>");
+
+      int yOffsetText = yOffset + 8;
+      outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+          + "px; left:5px;\">%.1f</div>\n", size);
+      outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+          + "px; left:70px;\">%.1f", perc);
+      outFile.println("%</div>\n");
+      outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
+          + "px; left:110px;\"><a href=\"" + drillDownFileName
+          + "\" target=\"_top\">" + codeType + "</a></div>");
+
+      yOffset = yOffset + 25;
+    }
+    outFile.println("</body>");
+    outFile.println("</html>");
+    outFile.close();
+
+    return outFileName;
+  }
+
+  private static String shellFileName(SizeBreakdown breakdown) {
+    return breakdown.getId() + "-overallBreakdown.html";
+  }
+
+  public void makeBreakdownShell(SizeBreakdown breakdown) throws  
IOException {
      // this will contain the place holder iframes where the actual  
information
      // is going to go.

@@ -162,7 +280,8 @@
      File outputDir = getOutFile("images");
      copyFileOrDirectory(inputDir, outputDir, classPath, inputFileName,  
true);

-    final PrintWriter outFile = new  
PrintWriter(getOutFile(shellFileName(breakdown)));
+    final PrintWriter outFile = new PrintWriter(
+        getOutFile(shellFileName(breakdown)));
      outFile.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">");
      outFile.println("<html>");
      outFile.println("<head>");
@@ -343,6 +462,95 @@
      }
    }

+  public void makeDependenciesHtml(Map<String, ArrayList<String>>  
dependencies)
+      throws IOException {
+
+    String origOutFileName = "methodDependencies-";
+    PrintWriter outFile = null;
+    String curPackageName = "";
+    String curClassName = "";
+
+    for (String method : dependencies.keySet()) {
+      // this key set is already in alphabetical order
+      // get the package of this method, i.e., everything up to .[A-Z]
+
+      String packageName = method;
+      packageName = packageName.replaceAll("\\.\\p{Upper}.*", "");
+
+      String className = method;
+      className = className.replaceAll("::.*", "");
+
+      if ((curPackageName.compareTo("") == 0)
+          || (curPackageName.compareTo(packageName) != 0)) {
+
+        curPackageName = packageName;
+        if (outFile != null) {
+          // finish up the current file
+          outFile.println("</table>");
+          outFile.println("<center>");
+
+          outFile.println("</div>");
+          outFile.println("</body>");
+          outFile.println("</html>");
+          outFile.close();
+        }
+
+        String outFileName = origOutFileName + filename(curPackageName)
+            + ".html";
+        outFile = new PrintWriter(getOutFile(outFileName));
+
+        outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
+        outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
+        outFile.println("<html>");
+        outFile.println("<head>");
+        outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
+        outFile.println("<title>Method Dependencies</title>");
+        outFile.println("</head>");
+
+        outFile.println("<style type=\"text/css\">");
+        outFile.println("body {background-color: #728FCE}");
+        outFile.println("h2 {background-color: transparent}");
+        outFile.println("p {background-color: fuchsia}");
+        outFile.println("</style>");
+
+        outFile.println("<body>");
+        outFile.println("<center>");
+        outFile.println("<h2>Method Dependencies for package " +  
curPackageName
+            + "</h2>");
+        outFile.println("</center>");
+        outFile.println("<hr>");
+
+        outFile.println("<center>");
+        outFile.println("<table border=\"1\" width=\"80%\"  
style=\"font-size: 11pt;\" bgcolor=\"white\">");
+      }
+      outFile.println("<tr>");
+      if (curClassName.compareTo(className) != 0) {
+        outFile.println("<td width=\"80%\"><a name=\"" + className + "\">"
+            + "<a name=\"" + method + "\">" + method
+            + "</a></a><font color=\"green\"> called by</font></td>");
+        curClassName = className;
+      } else {
+        outFile.println("<td width=\"80%\"><a name=\"" + method + "\">"
+            + method + "</a><font color=\"green\"> called by</font></td>");
+      }
+      outFile.println("</tr>");
+
+      for (int i = 0; i < dependencies.get(method).size(); i++) {
+        String depMethod = dependencies.get(method).get(i);
+
+        outFile.println("<tr>");
+        outFile.println("<td width=\"20%\"></td>");
+        if (i != dependencies.get(method).size() - 1) {
+          outFile.println("<td width=\"60%\">" + depMethod
+              + "<font color=\"green\"> called by</font></td>");
+        } else {
+          outFile.println("<td width=\"60%\">" + depMethod + "</td>");
+        }
+        outFile.println("</tr>");
+      }
+    }
+  }
+
    public void makeLiteralsClassesTableHtmls(SizeBreakdown breakdown)
        throws IOException {
      Map<String, LiteralsCollection> nameToLitColl =  
breakdown.nameToLitColl;
@@ -377,14 +585,15 @@
        outFile.println("<table border=\"1\" width=\"80%\"  
style=\"font-size: 11pt;\" bgcolor=\"white\">");

        for (String literal :  
nameToLitColl.get(literalType).literalToLocations.keySet()) {
-
-        if ((literalType.compareTo("string") != 0)|| 
(nameToLitColl.get("string").stringLiteralToType.get(literal).compareTo("otherStrings")
 !=  
0)){
-
-
+
+        if ((literalType.compareTo("string") != 0)
+            ||  
(nameToLitColl.get("string").stringLiteralToType.get(literal).compareTo(
+                "otherStrings") != 0)) {
+
            if (literal.trim().compareTo("") == 0) {
              literal = "[whitespace only string]";
            }
-
+
            String newLiteral = "";
            if (literal.length() > 80) {
              int i;
@@ -398,22 +607,22 @@
            } else {
              newLiteral = literal;
            }
-
+
            String escliteral = escapeXml(newLiteral);
-
+
            outFile.println("<tr>");
            outFile.println("<td width=\"40%\">" + escliteral + "</td>");
-
+
            int ct = 0;
            if ((nameToLitColl.containsKey(literalType))
                &&  
(nameToLitColl.get(literalType).literalToLocations.containsKey(literal))) {
              for (String location :  
nameToLitColl.get(literalType).literalToLocations.get(literal)) {
-
+
                if (ct > 0) {
                  outFile.println("<tr>");
                  outFile.println("<td width=\"40%\"> </td>");
                }
-
+
                String newLocation = "";
                if (location.length() > 80) {
                  int i;
@@ -427,9 +636,9 @@
                } else {
                  newLocation = location;
                }
-
+
                outFile.println("<td width=\"40%\">" + newLocation  
+ "</td>");
-
+
                if (ct > 0) {
                  outFile.println("</tr>");
                }
@@ -439,11 +648,11 @@
              System.err.println("either literalType " + literalType
                  + " not known, or no location for literal " + literal);
            }
-
+
            outFile.println("</tr>");
          }
        }
-
+
        outFile.println("</table>");
        outFile.println("<center>");

@@ -454,54 +663,193 @@
      }
    }

-  public void makeStringLiteralsClassesTableHtmls(SizeBreakdown breakdown)
+  /**
+   * Make size breakdowns for each package for one code collection.
+   */
+  public void makePackageClassesHtmls(SizeBreakdown breakdown)
        throws IOException {
-    Map<String, LiteralsCollection> nameToLitColl =  
breakdown.nameToLitColl;
+    for (String packageName : GlobalInformation.packageToClasses.keySet())  
{

-    for (String literalType :  
nameToLitColl.get("string").stringTypeToSize.keySet()) {
-      String outFileName = literalType + "Strings.html";
-      final PrintWriter outFile = new  
PrintWriter(getOutFile(breakdown.getId()
-          + "_" + outFileName));
+      TreeMap<Float, String> sortedClasses = new TreeMap<Float, String>(
+          Collections.reverseOrder());
+      float maxSize = 0f;

-      outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
-      outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
-      outFile.println("<html>");
-      outFile.println("<head>");
-      outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
-      outFile.println("<title>Literals of type \"" + literalType  
+ "\"</title>");
-      outFile.println("</head>");
+      int maxDepCount = 1;

-      outFile.println("<style type=\"text/css\">");
-      outFile.println("body {background-color: #728FCE}");
-      outFile.println("h2 {background-color: transparent}");
-      outFile.println("p {background-color: fuchsia}");
-      outFile.println("</style>");
+      for (String className :  
GlobalInformation.packageToClasses.get(packageName)) {

-      outFile.println("<body>");
-      outFile.println("<center>");
-      outFile.println("<h2>Literals of type \"" + literalType + "\"</h2>");
-      addHeaderWithBreakdownContext(breakdown, outFile);
-      outFile.println("</center>");
-
-      if (literalType.compareTo("otherStrings") == 0){
-        outFile.println("<center>");
-        outFile.println("(JavaScript variable names are not displayed.)");
+        float curSize = 0f;
+        if (!breakdown.classToPartialSize.containsKey(className)) {
+          // This class not present in this code collection
+        } else {
+          curSize = breakdown.classToPartialSize.get(className);
+        }
+
+        int depCount = 0;
+        if  
(GlobalInformation.classToWhatItDependsOn.containsKey(className)) {
+          depCount =  
GlobalInformation.classToWhatItDependsOn.get(className).size();
+        }
+
+        if (curSize != 0f) {
+
+          sortedClasses.put(curSize, className);
+          if (curSize > maxSize) {
+            maxSize = curSize;
+          }
+          if (depCount > maxDepCount) {
+            maxDepCount = depCount;
+          }
+        }
+      }
+
+      PrintWriter outFile = new PrintWriter(
+          getOutFile(classesInPackageFileName(breakdown, packageName)));
+
+      outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
+      outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
+      outFile.println("<html>");
+      outFile.println("<head>");
+      outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
+      outFile.println("<link rel=\"stylesheet\" href=\"classLevel.css\"  
media=\"screen\">");
+      outFile.println("<title>Classes in package \"" + packageName
+          + "\"</title>");
+      outFile.println("</head>");
+      outFile.println("<body>");
+
+      outFile.println("<center>");
+      outFile.println("<h2>Classes in package \"" + packageName  
+ "\"</h2>");
+      addHeaderWithBreakdownContext(breakdown, outFile);
+      outFile.println("</center>");
+
+      outFile.println("<div style=\"width:90%; height:80%;  
overflow-y:auto; overflow-x:auto; top: 120px; left:70px; position:absolute;  
background-color:white\"");
+
+      int yOffset = 0;
+      for (Float size : sortedClasses.keySet()) {
+
+        String className = sortedClasses.get(size);
+
+        // TODO(kprobst): switch out the commented/uncommented lines below  
when
+        // showing dependencies
+        // float ratio = (size / maxSize) * 45;
+        float ratio = (size / maxSize) * 85;
+
+        if (ratio < 3) {
+          ratio = 3;
+        }
+
+        // TODO(kprobst): not currently used, but will be for dependencies
+        // get the dependency count
+        int depCount = 0;
+        if  
(GlobalInformation.classToWhatItDependsOn.containsKey(className)) {
+          depCount =  
GlobalInformation.classToWhatItDependsOn.get(className).size();
+        }
+        float depRatio = ((float) depCount / (float) maxDepCount) * 45f;
+        if (depRatio < 3.0) {
+          depRatio = 3;
+        }
+
+        outFile.println("<div class=\"box\" style=\"width:" + ratio
+            + "%; top: " + yOffset + "px; left: 60px;\">");
+        outFile.println("<div id=\"lb\">");
+        outFile.println("<div id=\"rb\">");
+        outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
+        outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
+        outFile.println("<div id=\"content\">");
+        outFile.println("</div>");
+        outFile.println("</div></div></div></div>");
+        outFile.println("</div></div></div></div>");
+        outFile.println("</div>");
+
+        // TODO(kprobst): not currently used, but will be for dependencies
+        /*
+         * outFile.println("<div class=\"box-right\" style=\"width:" +  
depRatio
+         * + "%; top: " + yOffset + "px; left: 50%\">");
+         * outFile.println("<div id=\"lb\">");
+         * outFile.println("<div id=\"rb\">");
+         * outFile.println("<div id=\"bb\"><div id=\"blc\"><div  
id=\"brc\">");
+         * outFile.println("<div id=\"tb\"><div id=\"tlc\"><div  
id=\"trc\">");
+         * outFile.println("<div id=\"content\">");  
outFile.println("</div>");
+         * outFile.println("</div></div></div></div>");
+         * outFile.println("</div></div></div></div>");
+         * outFile.println("</div>");
+         */
+
+        int yOffsetText = yOffset + 8;
+        outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+            + "px; left:5px;\">%.1f</div>\n", size);
+        if (GlobalInformation.displayDependencies == true) {
+          outFile.println("<div class=\"barlabel\" style=\"top:" +  
yOffsetText
+              + "px; left:70px;\"><a href=\"methodDependencies-"
+              + filename(packageName) + ".html#" + className + "\">"
+              + className + "</a></div>");
+        } else {
+          outFile.println("<div class=\"barlabel\" style=\"top:" +  
yOffsetText
+              + "px; left:70px;\">" + className + "</div>");
+        }
+        /*
+         * //TODO(kprobst) make this a link String drillDownFileName =  
className
+         * + "Deps.html"; outFile.println("<div class=\"barlabel\"  
style=\"top:"
+         * + yOffsetText + "px; left:50%;\"><a href=\"" +  
drillDownFileName +
+         * "\" target=\"_top\">Dependencies: " + depCount + "</a></div>");
+         */
+        yOffset = yOffset + 25;
+      }
+
+      outFile.println("</div>");
+      outFile.println("</body>");
+      outFile.println("</html>");
+      outFile.close();
+    }
+  }
+
+  public void makeStringLiteralsClassesTableHtmls(SizeBreakdown breakdown)
+      throws IOException {
+    Map<String, LiteralsCollection> nameToLitColl =  
breakdown.nameToLitColl;
+
+    for (String literalType :  
nameToLitColl.get("string").stringTypeToSize.keySet()) {
+      String outFileName = literalType + "Strings.html";
+      final PrintWriter outFile = new  
PrintWriter(getOutFile(breakdown.getId()
+          + "_" + outFileName));
+
+      outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
+      outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
+      outFile.println("<html>");
+      outFile.println("<head>");
+      outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
+      outFile.println("<title>Literals of type \"" + literalType  
+ "\"</title>");
+      outFile.println("</head>");
+
+      outFile.println("<style type=\"text/css\">");
+      outFile.println("body {background-color: #728FCE}");
+      outFile.println("h2 {background-color: transparent}");
+      outFile.println("p {background-color: fuchsia}");
+      outFile.println("</style>");
+
+      outFile.println("<body>");
+      outFile.println("<center>");
+      outFile.println("<h2>Literals of type \"" + literalType + "\"</h2>");
+      addHeaderWithBreakdownContext(breakdown, outFile);
+      outFile.println("</center>");
+
+      if (literalType.compareTo("otherStrings") == 0) {
+        outFile.println("<center>");
+        outFile.println("(JavaScript variable names are not displayed.)");
          outFile.println("</center>");
        }

-      else{
+      else {
          outFile.println("<center>");
          outFile.println("<table border=\"1\" width=\"80%\"  
style=\"font-size: 11pt;\" bgcolor=\"white\">");
-
+
          for (String literal :  
nameToLitColl.get("string").stringLiteralToType.keySet()) {
-
+
            if  
(nameToLitColl.get("string").stringLiteralToType.get(literal).compareTo(
                literalType) == 0) {
-
+
              if (literal.trim().compareTo("") == 0) {
                literal = "[whitespace only string]";
              }
-
+
              String newLiteral = "";
              if (literal.length() > 80) {
                int i;
@@ -515,26 +863,33 @@
              } else {
                newLiteral = literal;
              }
-
+
              String escliteral = escapeXml(newLiteral);
-
+
              outFile.println("<tr>");
              outFile.println("<td width=\"40%\">" + escliteral + "</td>");
-
+
              int ct = 0;
-
+
              if  
(nameToLitColl.get("string").literalToLocations.containsKey(literal)) {
-
+
                for (String location :  
nameToLitColl.get("string").literalToLocations.get(literal)) {
-
-                if ((location.indexOf("Line 0") ==  
-1)&&(location.compareTo(GlobalInformation.backupLocation) != 0)){ //i.e.,  
if we actually know the location
+
+                if ((location.indexOf("Line 0") == -1)
+                    &&  
(location.compareTo(GlobalInformation.backupLocation) != 0)) { // i.e.,
+                                                                               
        
//  
if
+                                                                               
        
//  
we
+                                                                               
        
//  
actually
+                                                                               
        
//  
know
+                                                                               
        
//  
the
+                                                                               
        
//  
location
                    if (ct > 0) {
                      outFile.println("<tr>");
                      outFile.println("<td width=\"40%\"> </td>");
                    }
-
+
                    String newLocation = "";
-                  if (location.length() > 80){
+                  if (location.length() > 80) {
                      int i;
                      for (i = 80; i < location.length(); i = i + 80) {
                        String part1 = location.substring(i - 80, i);
@@ -546,17 +901,19 @@
                    } else {
                      newLocation = location;
                    }
-
-                  outFile.println("<td width=\"40%\"> " + newLocation + "  
</td>");
-
+
+                  outFile.println("<td width=\"40%\"> " + newLocation
+                      + " </td>");
+
                    if (ct > 0) {
                      outFile.println("</tr>");
                    }
                    ct++;
                  }
                }
-              if (ct == 0){
-                outFile.println("<td width=\"40%\"> " +  
GlobalInformation.backupLocation + " </td>");
+              if (ct == 0) {
+                outFile.println("<td width=\"40%\"> "
+                    + GlobalInformation.backupLocation + " </td>");
                }
              } else {
                System.err.println("no location given for string literal: "
@@ -565,11 +922,11 @@
              outFile.println("</tr>");
            }
          }
-
+
          outFile.println("</table>");
          outFile.println("<center>");
        }
-
+
        outFile.println("</div>");
        outFile.println("</body>");
        outFile.println("</html>");
@@ -648,125 +1005,15 @@
        float size;
        if (i >= 0) {
          size = GlobalInformation.fragmentToPartialSize.get(i);
-      } else {
-        size = GlobalInformation.totalCodeBreakdown.sizeAllCode;
-      }
-      float ratio = (size / maxSize) * 79;
-      if (ratio < 3) {
-        ratio = 3;
-      }
-
-      outFile.println("<div id=\"box\" style=\"width: " + ratio + "%;  
top: "
-          + yOffset + "px; left: 110px;\">");
-      outFile.println("<div id=\"lb\">");
-      outFile.println("<div id=\"rb\">");
-      outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
-      outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
-      outFile.println("<div id=\"content\">");
-      outFile.println("</div>");
-      outFile.println("</div></div></div></div>");
-      outFile.println("</div></div></div></div>");
-      outFile.println("</div>");
-
-      int yOffsetText = yOffset + 8;
-      outFile.printf("<div class=\"barlabel\" style=\"top: " + yOffsetText
-          + "px; left:5px;\">%.1f</div>\n", size);
-      outFile.println("<div class=\"barlabel\" style=\"top: " + yOffsetText
-          + "px; left:120px;\"><a href=\"" + drillDownFileName
-          + "\" target=\"_top\">" + splitPointDescription + "</a></div>");
-
-      yOffset = yOffset + 25;
-    }
-    outFile.println("</div>");
-    outFile.println("</body></html>");
-    outFile.close();
-  }
-
-  /**
-   * Adds a header line indicating which breakdown is being analyzed.
-   */
-  private static void addHeaderWithBreakdownContext(SizeBreakdown  
breakdown,
-      final PrintWriter outFile) {
-    outFile.println("<hr>");
-    outFile.println("<b>(Analyzing code subset: " +  
breakdown.getDescription()
-        + ")</b>");
-    outFile.println("<hr>");
-  }
-
-  private static String classesInPackageFileName(SizeBreakdown breakdown,
-      String packageName) {
-    return breakdown.getId() + "_" + packageName + "_Classes.html";
-  }
-
-  /**
-   * Convert a potentially long string into a short file name. The current
-   * implementation simply hashes the long name.
-   */
-  private static String filename(String longFileName) {
-    try {
-      return  
Util.computeStrongName(longFileName.getBytes(Util.DEFAULT_ENCODING));
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  /**
-   * Return a {...@link File} object for a file to be emitted into the output
-   * directory.
-   */
-  private static File getOutFile(String localFileName) {
-    File outDir = new File(GlobalInformation.settings.out.get());
-    return new File(outDir, localFileName);
-  }
-
-  private static String makeCodeTypeHtml(SizeBreakdown breakdown,
-      Map<String, CodeCollection> nameToCodeColl) throws IOException {
-    String outFileName = breakdown.getId() + "_codeTypeBreakdown.html";
-    float maxSize = 0f;
-    float sumSize = 0f;
-    TreeMap<Float, String> sortedCodeTypes = new TreeMap<Float, String>(
-        Collections.reverseOrder());
-
-    // TODO(kprobst): turn this into a multimap?
-    // com.google.common.collect.TreeMultimap
-    for (String codeType : nameToCodeColl.keySet()) {
-      float curSize =  
nameToCodeColl.get(codeType).getCumPartialSize(breakdown);
-      sumSize += curSize;
-
-      if (curSize != 0f) {
-        sortedCodeTypes.put(curSize, codeType);
-        if (curSize > maxSize) {
-          maxSize = curSize;
-        }
-      }
-    }
-
-    final PrintWriter outFile = new PrintWriter(getOutFile(outFileName));
-
-    outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"");
-    outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
-    outFile.println("<html>");
-    outFile.println("<head>");
-    outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
-    outFile.println("<link rel=\"stylesheet\" href=\"roundedCorners.css\"  
media=\"screen\">");
-    outFile.println("</head>");
-    outFile.println("<body>");
-
-    int yOffset = 0;
-    for (Float size : sortedCodeTypes.keySet()) {
-
-      String codeType = sortedCodeTypes.get(size);
-      String drillDownFileName = breakdown.getId() + "_" + codeType
-          + "Classes.html";
-
+      } else {
+        size = GlobalInformation.totalCodeBreakdown.sizeAllCode;
+      }
        float ratio = (size / maxSize) * 79;
-      float perc = (size / sumSize) * 100;
-
        if (ratio < 3) {
          ratio = 3;
        }

-      outFile.println("<div id=\"box\" style=\"width:" + ratio + "%; top: "
+      outFile.println("<div id=\"box\" style=\"width: " + ratio + "%;  
top: "
            + yOffset + "px; left: 110px;\">");
        outFile.println("<div id=\"lb\">");
        outFile.println("<div id=\"rb\">");
@@ -779,22 +1026,17 @@
        outFile.println("</div>");

        int yOffsetText = yOffset + 8;
-      outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
+      outFile.printf("<div class=\"barlabel\" style=\"top: " + yOffsetText
            + "px; left:5px;\">%.1f</div>\n", size);
-      outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
-          + "px; left:70px;\">%.1f", perc);
-      outFile.println("%</div>\n");
-      outFile.println("<div class=\"barlabel\" style=\"top:" + yOffsetText
-          + "px; left:110px;\"><a href=\"" + drillDownFileName
-          + "\" target=\"_top\">" + codeType + "</a></div>");
+      outFile.println("<div class=\"barlabel\" style=\"top: " + yOffsetText
+          + "px; left:120px;\"><a href=\"" + drillDownFileName
+          + "\" target=\"_top\">" + splitPointDescription + "</a></div>");

        yOffset = yOffset + 25;
      }
-    outFile.println("</body>");
-    outFile.println("</html>");
+    outFile.println("</div>");
+    outFile.println("</body></html>");
      outFile.close();
-
-    return outFileName;
    }

    private String makeLiteralsHtml(SizeBreakdown breakdown,
@@ -1028,237 +1270,5 @@
      outFile.close();

      return outFileName;
-  }
-
-  private static String shellFileName(SizeBreakdown breakdown) {
-    return breakdown.getId() + "-overallBreakdown.html";
-  }
-
-  public void makeDependenciesHtml(Map<String, ArrayList<String>>  
dependencies)
-      throws IOException {
-
-    String origOutFileName = "methodDependencies-";
-    PrintWriter outFile = null;
-    String curPackageName = "";
-    String curClassName = "";
-
-    for (String method : dependencies.keySet()) {
-      // this key set is already in alphabetical order
-      // get the package of this method, i.e., everything up to .[A-Z]
-
-      String packageName = method;
-      packageName = packageName.replaceAll("\\.\\p{Upper}.*", "");
-
-      String className = method;
-      className = className.replaceAll("::.*", "");
-
-      if ((curPackageName.compareTo("") == 0)
-          || (curPackageName.compareTo(packageName) != 0)) {
-
-        curPackageName = packageName;
-        if (outFile != null) {
-          // finish up the current file
-          outFile.println("</table>");
-          outFile.println("<center>");
-
-          outFile.println("</div>");
-          outFile.println("</body>");
-          outFile.println("</html>");
-          outFile.close();
-        }
-
-        String outFileName = origOutFileName + filename(curPackageName)
-            + ".html";
-        outFile = new PrintWriter(getOutFile(outFileName));
-
-        outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
-        outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
-        outFile.println("<html>");
-        outFile.println("<head>");
-        outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
-        outFile.println("<title>Method Dependencies</title>");
-        outFile.println("</head>");
-
-        outFile.println("<style type=\"text/css\">");
-        outFile.println("body {background-color: #728FCE}");
-        outFile.println("h2 {background-color: transparent}");
-        outFile.println("p {background-color: fuchsia}");
-        outFile.println("</style>");
-
-        outFile.println("<body>");
-        outFile.println("<center>");
-        outFile.println("<h2>Method Dependencies for package " +  
curPackageName
-            + "</h2>");
-        outFile.println("</center>");
-        outFile.println("<hr>");
-
-        outFile.println("<center>");
-        outFile.println("<table border=\"1\" width=\"80%\"  
style=\"font-size: 11pt;\" bgcolor=\"white\">");
-      }
-      outFile.println("<tr>");
-      if (curClassName.compareTo(className) != 0) {
-        outFile.println("<td width=\"80%\"><a name=\"" + className + "\">"
-            + "<a name=\"" + method + "\">" + method
-            + "</a></a><font color=\"green\"> called by</font></td>");
-        curClassName = className;
-      } else {
-        outFile.println("<td width=\"80%\"><a name=\"" + method + "\">"
-            + method + "</a><font color=\"green\"> called by</font></td>");
-      }
-      outFile.println("</tr>");
-
-      for (int i = 0; i < dependencies.get(method).size(); i++) {
-        String depMethod = dependencies.get(method).get(i);
-
-        outFile.println("<tr>");
-        outFile.println("<td width=\"20%\"></td>");
-        if (i != dependencies.get(method).size() - 1) {
-          outFile.println("<td width=\"60%\">" + depMethod
-              + "<font color=\"green\"> called by</font></td>");
-        } else {
-          outFile.println("<td width=\"60%\">" + depMethod + "</td>");
-        }
-        outFile.println("</tr>");
-      }
-    }
-  }
-
-  /**
-   * Make size breakdowns for each package for one code collection.
-   */
-  public void makePackageClassesHtmls(SizeBreakdown breakdown)
-      throws IOException {
-    for (String packageName : GlobalInformation.packageToClasses.keySet())  
{
-
-      TreeMap<Float, String> sortedClasses = new TreeMap<Float, String>(
-          Collections.reverseOrder());
-      float maxSize = 0f;
-
-      int maxDepCount = 1;
-
-      for (String className :  
GlobalInformation.packageToClasses.get(packageName)) {
-
-        float curSize = 0f;
-        if (!breakdown.classToPartialSize.containsKey(className)) {
-          // This class not present in this code collection
-        } else {
-          curSize = breakdown.classToPartialSize.get(className);
-        }
-
-        int depCount = 0;
-        if  
(GlobalInformation.classToWhatItDependsOn.containsKey(className)) {
-          depCount =  
GlobalInformation.classToWhatItDependsOn.get(className).size();
-        }
-
-        if (curSize != 0f) {
-
-          sortedClasses.put(curSize, className);
-          if (curSize > maxSize) {
-            maxSize = curSize;
-          }
-          if (depCount > maxDepCount) {
-            maxDepCount = depCount;
-          }
-        }
-      }
-
-      PrintWriter outFile = new PrintWriter(
-          getOutFile(classesInPackageFileName(breakdown, packageName)));
-
-      outFile.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML  
4.01//EN\"");
-      outFile.println("\"http://www.w3.org/TR/html4/strict.dtd\";>");
-      outFile.println("<html>");
-      outFile.println("<head>");
-      outFile.println("<meta http-equiv=\"content-type\"  
content=\"text/html;charset=ISO-8859-1\">");
-      outFile.println("<link rel=\"stylesheet\" href=\"classLevel.css\"  
media=\"screen\">");
-      outFile.println("<title>Classes in package \"" + packageName
-          + "\"</title>");
-      outFile.println("</head>");
-      outFile.println("<body>");
-
-      outFile.println("<center>");
-      outFile.println("<h2>Classes in package \"" + packageName  
+ "\"</h2>");
-      addHeaderWithBreakdownContext(breakdown, outFile);
-      outFile.println("</center>");
-
-      outFile.println("<div style=\"width:90%; height:80%;  
overflow-y:auto; overflow-x:auto; top: 120px; left:70px; position:absolute;  
background-color:white\"");
-
-      int yOffset = 0;
-      for (Float size : sortedClasses.keySet()) {
-
-        String className = sortedClasses.get(size);
-
-        // TODO(kprobst): switch out the commented/uncommented lines below  
when
-        // showing dependencies
-        // float ratio = (size / maxSize) * 45;
-        float ratio = (size / maxSize) * 85;
-
-        if (ratio < 3) {
-          ratio = 3;
-        }
-
-        // TODO(kprobst): not currently used, but will be for dependencies
-        // get the dependency count
-        int depCount = 0;
-        if  
(GlobalInformation.classToWhatItDependsOn.containsKey(className)) {
-          depCount =  
GlobalInformation.classToWhatItDependsOn.get(className).size();
-        }
-        float depRatio = ((float) depCount / (float) maxDepCount) * 45f;
-        if (depRatio < 3.0) {
-          depRatio = 3;
-        }
-
-        outFile.println("<div class=\"box\" style=\"width:" + ratio
-            + "%; top: " + yOffset + "px; left: 60px;\">");
-        outFile.println("<div id=\"lb\">");
-        outFile.println("<div id=\"rb\">");
-        outFile.println("<div id=\"bb\"><div id=\"blc\"><div id=\"brc\">");
-        outFile.println("<div id=\"tb\"><div id=\"tlc\"><div id=\"trc\">");
-        outFile.println("<div id=\"content\">");
-        outFile.println("</div>");
-        outFile.println("</div></div></div></div>");
-        outFile.println("</div></div></div></div>");
-        outFile.println("</div>");
-
-        // TODO(kprobst): not currently used, but will be for dependencies
-        /*
-         * outFile.println("<div class=\"box-right\" style=\"width:" +  
depRatio
-         * + "%; top: " + yOffset + "px; left: 50%\">");
-         * outFile.println("<div id=\"lb\">");
-         * outFile.println("<div id=\"rb\">");
-         * outFile.println("<div id=\"bb\"><div id=\"blc\"><div  
id=\"brc\">");
-         * outFile.println("<div id=\"tb\"><div id=\"tlc\"><div  
id=\"trc\">");
-         * outFile.println("<div id=\"content\">");  
outFile.println("</div>");
-         * outFile.println("</div></div></div></div>");
-         * outFile.println("</div></div></div></div>");
-         * outFile.println("</div>");
-         */
-
-        int yOffsetText = yOffset + 8;
-        outFile.printf("<div class=\"barlabel\" style=\"top:" + yOffsetText
-            + "px; left:5px;\">%.1f</div>\n", size);
-        if (GlobalInformation.displayDependencies == true) {
-          outFile.println("<div class=\"barlabel\" style=\"top:" +  
yOffsetText
-              + "px; left:70px;\"><a href=\"methodDependencies-"
-              + filename(packageName) + ".html#" + className + "\">"
-              + className + "</a></div>");
-        } else {
-          outFile.println("<div class=\"barlabel\" style=\"top:" +  
yOffsetText
-              + "px; left:70px;\">" + className + "</div>");
-        }
-        /*
-         * //TODO(kprobst) make this a link String drillDownFileName =  
className
-         * + "Deps.html"; outFile.println("<div class=\"barlabel\"  
style=\"top:"
-         * + yOffsetText + "px; left:50%;\"><a href=\"" +  
drillDownFileName +
-         * "\" target=\"_top\">Dependencies: " + depCount + "</a></div>");
-         */
-        yOffset = yOffset + 25;
-      }
-
-      outFile.println("</div>");
-      outFile.println("</body>");
-      outFile.println("</html>");
-      outFile.close();
-    }
    }
  }

Modified: trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java
==============================================================================
--- trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java      
(original)
+++ trunk/tools/soyc-vis/src/com/google/gwt/soyc/SoycDashboard.java     Tue Jun 
 
30 14:59:48 2009
@@ -380,7 +380,7 @@
          if (curFragment == 0) {
            breakdowns.add(GlobalInformation.initialCodeBreakdown);
          }
-        if (curFragment == (GlobalInformation.numSplitPoints+1)) {
+        if (curFragment == (GlobalInformation.numSplitPoints + 1)) {
            breakdowns.add(GlobalInformation.leftoversBreakdown);
          }
          if (curFragment >= 1 && curFragment <=  
GlobalInformation.numSplitPoints) {

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to