1 /*
2  * Manage the GraphViz interface for node shapes
3  *
4  * (C) Copyright 2007 Diomidis Spinellis
5  *
6  * Permission to use, copy, and distribute this software and its
7  * documentation for any purpose and without fee is hereby granted,
8  * provided that the above copyright notice appear in all copies and that
9  * both that copyright notice and this permission notice appear in
10  * supporting documentation.
11  *
12  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
13  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
14  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  *
17  */
18 
19 package org.umlgraph.doclet;
20 
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 import com.sun.javadoc.ClassDoc;
27 import com.sun.javadoc.Doc;
28 import com.sun.javadoc.LanguageVersion;
29 import com.sun.javadoc.RootDoc;
30 
31 /**
32  * Properties of node shapes
33  *
34  * @version $Revision$
35  * @author <a href="http://www.spinellis.gr">Diomidis Spinellis</a>
36  */
37 public class Shape {
38 
39     /** Shape's UMLGraph name */
40     private String name;
41 
42     /** Construct a default (class) Shape */
Shape()43     public Shape() {
44 	name = "class";
45     }
46 
47     /** Construct a Shape through the specified UMLGraph name */
Shape(String n)48     public Shape(String n) {
49 	name = n;
50 	if (graphvizAttribute() == null) {
51 	    System.err.println("Ignoring invalid shape " + n);
52 	    name = "class";
53 	}
54     }
55 
56     /**
57      * Return the GraphViz shape name corresponding to the shape
58      */
graphvizAttribute()59     public String graphvizAttribute() {
60 	if (name.equals("class"))
61 	    return "";		// Default; plaintext
62 	else if (name.equals("note"))
63 	    return ", shape=note";
64 	else if (name.equals("node"))
65 	    return ", shape=box3d";
66 	else if (name.equals("component"))
67 	    return ", shape=component";
68 	else if (name.equals("package"))
69 	    return ", shape=tab";
70 	else if (name.equals("collaboration"))
71 	    return ", shape=ellipse, style=dashed";
72 	else if (name.equals("usecase"))
73 	    return ", shape=ellipse";
74 	else if (name.equals("activeclass"))
75 	    return "";		// Default; plaintext
76 	else
77 	    return null;
78     }
79 
80     /** Return the shape's GraphViz landing port */
landingPort()81     String landingPort() {
82 	if (name.equals("class") || name.equals("activeclass"))
83 	    return ":p";
84 	else
85 	    return "";
86     }
87 
88     /** Return the table border required for the shape */
extraColumn(int nRows)89     String extraColumn(int nRows) {
90 	return name.equals("activeclass") ? ("<td rowspan=\"" + nRows + "\"></td>") : "";
91     }
92 
93     /** Return the cell border required for the shape */
cellBorder()94     String cellBorder() {
95 	return (name.equals("class") || name.equals("activeclass")) ? "1" : "0";
96     }
97 }
98