src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java

changeset 766
90af8d87741f
parent 554
9d9f26857129
child 798
4868a36f6fd8
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Tue Nov 30 09:38:48 2010 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java	Wed Dec 01 11:02:38 2010 -0800
     1.3 @@ -25,11 +25,12 @@
     1.4  
     1.5  package com.sun.tools.doclets.formats.html;
     1.6  
     1.7 -import com.sun.tools.doclets.internal.toolkit.util.*;
     1.8 -
     1.9 -import com.sun.javadoc.*;
    1.10  import java.io.*;
    1.11  import java.util.*;
    1.12 +import com.sun.tools.doclets.internal.toolkit.util.*;
    1.13 +import com.sun.tools.doclets.internal.toolkit.*;
    1.14 +import com.sun.tools.doclets.formats.html.markup.*;
    1.15 +import com.sun.javadoc.*;
    1.16  
    1.17  /**
    1.18   * Abstract class to print the class hierarchy page for all the Classes. This
    1.19 @@ -46,6 +47,8 @@
    1.20       */
    1.21      protected final ClassTree classtree;
    1.22  
    1.23 +    private static final String LI_CIRCLE  = "circle";
    1.24 +
    1.25      /**
    1.26       * Constructor initilises classtree variable. This constructor will be used
    1.27       * while generating global tree file "overview-tree.html".
    1.28 @@ -87,55 +90,64 @@
    1.29      }
    1.30  
    1.31      /**
    1.32 -     * Generate each level of the class tree. For each sub-class or
    1.33 +     * Add each level of the class tree. For each sub-class or
    1.34       * sub-interface indents the next level information.
    1.35 -     * Recurses itself to generate subclasses info.
    1.36 -     * To iterate is human, to recurse is divine - L. Peter Deutsch.
    1.37 +     * Recurses itself to add subclasses info.
    1.38       *
    1.39 -     * @param parent the superclass or superinterface of the list.
    1.40 -     * @param list list of the sub-classes at this level.
    1.41 -     * @param isEnum true if we are generating a tree for enums.
    1.42 +     * @param parent the superclass or superinterface of the list
    1.43 +     * @param list list of the sub-classes at this level
    1.44 +     * @param isEnum true if we are generating a tree for enums
    1.45 +     * @param contentTree the content tree to which the level information will be added
    1.46       */
    1.47 -    protected void generateLevelInfo(ClassDoc parent, List<ClassDoc> list,
    1.48 -            boolean isEnum) {
    1.49 -        if (list.size() > 0) {
    1.50 -            ul();
    1.51 -            for (int i = 0; i < list.size(); i++) {
    1.52 +    protected void addLevelInfo(ClassDoc parent, List<ClassDoc> list,
    1.53 +            boolean isEnum, Content contentTree) {
    1.54 +        int size = list.size();
    1.55 +        if (size > 0) {
    1.56 +            Content ul = new HtmlTree(HtmlTag.UL);
    1.57 +            for (int i = 0; i < size; i++) {
    1.58                  ClassDoc local = list.get(i);
    1.59 -                printPartialInfo(local);
    1.60 -                printExtendsImplements(parent, local);
    1.61 -                generateLevelInfo(local, classtree.subs(local, isEnum),
    1.62 -                    isEnum);   // Recurse
    1.63 +                HtmlTree li = new HtmlTree(HtmlTag.LI);
    1.64 +                li.addAttr(HtmlAttr.TYPE, LI_CIRCLE);
    1.65 +                addPartialInfo(local, li);
    1.66 +                addExtendsImplements(parent, local, li);
    1.67 +                addLevelInfo(local, classtree.subs(local, isEnum),
    1.68 +                        isEnum, li);   // Recurse
    1.69 +                ul.addContent(li);
    1.70              }
    1.71 -            ulEnd();
    1.72 +            contentTree.addContent(ul);
    1.73          }
    1.74      }
    1.75  
    1.76      /**
    1.77 -     * Generate the heading for the tree depending upon tree type if it's a
    1.78 -     * Class Tree or Interface tree and also print the tree.
    1.79 +     * Add the heading for the tree depending upon tree type if it's a
    1.80 +     * Class Tree or Interface tree.
    1.81       *
    1.82       * @param list List of classes which are at the most base level, all the
    1.83 -     * other classes in this run will derive from these classes.
    1.84 -     * @param heading Heading for the tree.
    1.85 +     * other classes in this run will derive from these classes
    1.86 +     * @param heading heading for the tree
    1.87 +     * @param div the content tree to which the tree will be added
    1.88       */
    1.89 -    protected void generateTree(List<ClassDoc> list, String heading) {
    1.90 +    protected void addTree(List<ClassDoc> list, String heading, Content div) {
    1.91          if (list.size() > 0) {
    1.92              ClassDoc firstClassDoc = list.get(0);
    1.93 -            printTreeHeading(heading);
    1.94 -            generateLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
    1.95 -                list,
    1.96 -                list == classtree.baseEnums());
    1.97 +            Content headingContent = getResource(heading);
    1.98 +            div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
    1.99 +                    headingContent));
   1.100 +            addLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
   1.101 +                    list, list == classtree.baseEnums(), div);
   1.102          }
   1.103      }
   1.104  
   1.105      /**
   1.106 -     * Print the information regarding the classes which this class extends or
   1.107 +     * Add information regarding the classes which this class extends or
   1.108       * implements.
   1.109       *
   1.110 -     * @param cd The classdoc under consideration.
   1.111 +     * @param parent the parent class of the class being documented
   1.112 +     * @param cd the classdoc under consideration
   1.113 +     * @param contentTree the content tree to which the information will be added
   1.114       */
   1.115 -    protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) {
   1.116 +    protected void addExtendsImplements(ClassDoc parent, ClassDoc cd,
   1.117 +            Content contentTree) {
   1.118          ClassDoc[] interfaces = cd.interfaces();
   1.119          if (interfaces.length > (cd.isInterface()? 1 : 0)) {
   1.120              Arrays.sort(interfaces);
   1.121 @@ -148,53 +160,43 @@
   1.122                      }
   1.123                      if (counter == 0) {
   1.124                          if (cd.isInterface()) {
   1.125 -                            print(" (" + configuration.getText("doclet.also") + " extends ");
   1.126 +                            contentTree.addContent(" (");
   1.127 +                            contentTree.addContent(getResource("doclet.also"));
   1.128 +                            contentTree.addContent(" extends ");
   1.129                          } else {
   1.130 -                            print(" (implements ");
   1.131 +                            contentTree.addContent(" (implements ");
   1.132                          }
   1.133                      } else {
   1.134 -                        print(", ");
   1.135 +                        contentTree.addContent(", ");
   1.136                      }
   1.137 -                    printPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
   1.138 -                        interfaces[i]);
   1.139 +                    addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
   1.140 +                            interfaces[i], contentTree);
   1.141                      counter++;
   1.142                  }
   1.143              }
   1.144              if (counter > 0) {
   1.145 -                println(")");
   1.146 +                contentTree.addContent(")");
   1.147              }
   1.148          }
   1.149      }
   1.150  
   1.151      /**
   1.152 -     * Print information about the class kind, if it's a "class" or "interface".
   1.153 +     * Add information about the class kind, if it's a "class" or "interface".
   1.154       *
   1.155 -     * @param cd classdoc.
   1.156 +     * @param cd the class being documented
   1.157 +     * @param contentTree the content tree to which the information will be added
   1.158       */
   1.159 -    protected void printPartialInfo(ClassDoc cd) {
   1.160 -        li("circle");
   1.161 -        printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
   1.162 +    protected void addPartialInfo(ClassDoc cd, Content contentTree) {
   1.163 +        addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree);
   1.164      }
   1.165  
   1.166      /**
   1.167 -     * Print the heading for the tree.
   1.168 +     * Get the tree label for the navigation bar.
   1.169       *
   1.170 -     * @param heading Heading for the tree.
   1.171 +     * @return a content tree for the tree label
   1.172       */
   1.173 -    protected void printTreeHeading(String heading) {
   1.174 -        h2();
   1.175 -        println(configuration.getText(heading));
   1.176 -        h2End();
   1.177 -    }
   1.178 -
   1.179 -    /**
   1.180 -     * Highlight "Tree" word in the navigation bar, since this is the tree page.
   1.181 -     */
   1.182 -    protected void navLinkTree() {
   1.183 -        navCellRevStart();
   1.184 -        fontStyle("NavBarFont1Rev");
   1.185 -        strongText("doclet.Tree");
   1.186 -        fontEnd();
   1.187 -        navCellEnd();
   1.188 +    protected Content getNavLinkTree() {
   1.189 +        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
   1.190 +        return li;
   1.191      }
   1.192  }

mercurial