Ejemplo n.º 1
0
 /** Print classes that were parts of relationships, but not parsed by javadoc */
 public void printExtraClasses(RootDoc root) {
   Set<String> names = new HashSet<String>(classnames.keySet());
   for (String className : names) {
     ClassInfo info = getClassInfo(className);
     if (!info.nodePrinted) {
       ClassDoc c = root.classNamed(className);
       if (c != null) {
         printClass(c, false);
       } else {
         Options opt = optionProvider.getOptionsFor(className);
         if (opt.matchesHideExpression(className)) continue;
         w.println("\t// " + className);
         w.print("\t" + info.name + "[label=");
         externalTableStart(opt, className, classToUrl(className));
         innerTableStart();
         int idx = className.lastIndexOf(".");
         if (opt.postfixPackage && idx > 0 && idx < (className.length() - 1)) {
           String packageName = className.substring(0, idx);
           String cn = className.substring(idx + 1);
           tableLine(Align.CENTER, escape(cn), opt, Font.CLASS);
           tableLine(Align.CENTER, packageName, opt, Font.PACKAGE);
         } else {
           tableLine(Align.CENTER, escape(className), opt, Font.CLASS);
         }
         innerTableEnd();
         externalTableEnd();
         if (className == null || className.length() == 0)
           w.print(", URL=\"" + classToUrl(className) + "\"");
         nodeProperties(opt);
       }
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * Builds the views according to the parameters on the command line
   *
   * @param opt The options
   * @param srcRootDoc The RootDoc for the source classes
   * @param viewRootDoc The RootDoc for the view classes (may be different, or may be the same as
   *     the srcRootDoc)
   */
  public static View[] buildViews(Options opt, RootDoc srcRootDoc, RootDoc viewRootDoc) {
    if (opt.viewName != null) {
      ClassDoc viewClass = viewRootDoc.classNamed(opt.viewName);
      if (viewClass == null) {
        System.out.println(
            "View " + opt.viewName + " not found! Exiting without generating any output.");
        return null;
      }
      if (viewClass.tags("view").length == 0) {
        System.out.println(viewClass + " is not a view!");
        return null;
      }
      if (viewClass.isAbstract()) {
        System.out.println(viewClass + " is an abstract view, no output will be generated!");
        return null;
      }
      return new View[] {buildView(srcRootDoc, viewClass, opt)};
    } else if (opt.findViews) {
      List<View> views = new ArrayList<View>();
      ClassDoc[] classes = viewRootDoc.classes();

      // find view classes
      for (int i = 0; i < classes.length; i++)
        if (classes[i].tags("view").length > 0 && !classes[i].isAbstract())
          views.add(buildView(srcRootDoc, classes[i], opt));

      return views.toArray(new View[views.size()]);
    } else return new View[0];
  }
Ejemplo n.º 3
0
  /**
   * Create a new ClassGraph.
   *
   * <p>The packages passed as an argument are the ones specified on the command line.
   *
   * <p>Local URLs will be generated for these packages.
   *
   * @param root The root of docs as provided by the javadoc API
   * @param optionProvider The main option provider
   * @param contextDoc The current context for generating relative links, may be a ClassDoc or a
   *     PackageDoc (used by UMLDoc)
   */
  public ClassGraph(RootDoc root, OptionProvider optionProvider, Doc contextDoc) {
    this.optionProvider = optionProvider;
    this.collectionClassDoc = root.classNamed("java.util.Collection");
    this.mapClassDoc = root.classNamed("java.util.Map");
    this.contextDoc = contextDoc;

    // to gather the packages containing specified classes, loop thru them and gather
    // package definitions. User root.specifiedPackages is not safe, since the user
    // may specify just a list of classes (human users usually don't, but automated tools do)
    rootClasses = new HashSet<String>();
    for (ClassDoc classDoc : root.classes()) {
      rootClasses.add(classDoc.qualifiedName());
      rootClassdocs.put(classDoc.qualifiedName(), classDoc);
    }

    Options opt = optionProvider.getGlobalOptions();
    if (opt.compact) {
      linePrefix = "";
      linePostfix = "";
    } else {
      linePrefix = "\t";
      linePostfix = "\n";
    }
  }