/* * @(#)TreeWriter.java 1.18 98/04/21 * * Copyright 1997, 1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */ package com.sun.tools.doclets.standard; import com.sun.tools.doclets.*; import com.sun.javadoc.*; import java.io.*; import java.lang.*; import java.util.*; /** * Generate Class Hierarchy page for all the Classes. Use ClassTree for * getting the Tree. * * @see java.util.HashMap * @see java.util.List * @see com.sun.javadoc.Type * @see com.sun.javadoc.ClassDoc * @author Atul M Dambalkar */ public class TreeWriter extends AbstractTreeWriter { private PackageDoc[] packages; private boolean classesonly; /** * Constructor. * * @param file String filename */ public TreeWriter(String filename, ClassTree classtree, RootDoc root) throws IOException, DocletAbortException { super(filename, classtree); packages = root.specifiedPackages(); classesonly = packages.length == 0; Arrays.sort(packages); } /** * Static method to be called by the Standard doclet. */ public static void generate(ClassTree classtree, RootDoc root) throws DocletAbortException { TreeWriter treegen; String filename = "tree.html"; try { treegen = new TreeWriter(filename, classtree, root); treegen.generateTreeFile(); treegen.close(); } catch (IOException exc) { Standard.configuration().standardmessage. error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Generate the Tree File Contents. */ public void generateTreeFile() throws IOException { printHeader(getText("doclet.Class_Hierarchy")); printTreeHeader(); printPageHeading(); printPackageTreeLinks(); generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy"); generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy"); printTreeFooter(); } /** * Generate the links to all the package tree files. */ protected void printPackageTreeLinks() { if (!classesonly) { dl(); dt(); boldText("doclet.Package_Hierarchies"); dd(); for (int i = 0; i < packages.length; i++) { String filename = DirectoryManager. createPathString(packages[i]) + fileseparator + "tree.html"; printHyperLink(filename, "", packages[i].name()); if (i < packages.length - 1) { print(", "); } } dlEnd(); hr(); } } /** * Print the navigation bar links at the top. */ protected void printTreeHeader() { navLinks(true); hr(); } /** * Print the navigation bar links at the bottom. */ protected void printTreeFooter() { hr(); navLinks(false); printBottom(); printFooter(); } protected void printPageHeading() { center(); h2(); printText("doclet.Hierarchy_For_All_Packages"); h2End(); centerEnd(); } }