Fix active class shape broken by commit 1b4c9763 + add test.

This was easy to break, because of a non-obvious logic.

Instead we now use the hack of just using a too large rowspan.
This commit is contained in:
Erich Schubert 2018-10-26 01:32:31 +02:00
parent bca0ceae17
commit a29ba21580
5 changed files with 36 additions and 22 deletions

View File

@ -416,18 +416,7 @@ class ClassGraph {
externalTableStart(opt, c.qualifiedName(), classToUrl(c, rootClass));
// Calculate the number of innerTable rows we will emmit
int nRows = 1;
if (showMembers) {
if (opt.showAttributes)
nRows++;
else if(!c.isEnum() && (opt.showConstructors || opt.showOperations))
nRows++;
else if (c.isEnum() && opt.showEnumConstants)
nRows++;
}
firstInnerTableStart(opt, nRows);
firstInnerTableStart(opt);
if (c.isInterface())
tableLine(Align.CENTER, guilWrap(opt, "interface"));
if (c.isEnum())
@ -448,7 +437,7 @@ class ClassGraph {
tableLine(Align.CENTER, escape(qualifiedName), opt, font);
}
tagvalue(opt, c);
firstInnerTableEnd(opt, nRows);
firstInnerTableEnd(opt);
/*
* Warning: The boolean expressions guarding innerTableStart()
@ -1111,10 +1100,9 @@ class ClassGraph {
/**
* Start the first inner table of a class.
* @param nRows the total number of rows in this table.
*/
private void firstInnerTableStart(Options opt, int nRows) {
w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn(nRows) +
private void firstInnerTableStart(Options opt) {
w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn() +
"<td><table border=\"0\" cellspacing=\"0\" " +
"cellpadding=\"1\">" + linePostfix);
}
@ -1125,11 +1113,10 @@ class ClassGraph {
/**
* End the first inner table of a class.
* @param nRows the total number of rows in this table.
*/
private void firstInnerTableEnd(Options opt, int nRows) {
private void firstInnerTableEnd(Options opt) {
w.print(linePrefix + linePrefix + "</table></td>" +
opt.shape.extraColumn(nRows) + "</tr>" + linePostfix);
opt.shape.extraColumn() + "</tr>" + linePostfix);
}
private void tableLine(Align align, String text) {

View File

@ -86,8 +86,8 @@ public class Shape {
}
/** Return the table border required for the shape */
String extraColumn(int nRows) {
return name.equals("activeclass") ? ("<td rowspan=\"" + nRows + "\"></td>") : "";
String extraColumn() {
return name.equals("activeclass") ? ("<td rowspan=\"10\"></td>") : "";
}
/** Return the cell border required for the shape */

View File

@ -1,2 +1 @@
*.dot
*.png

15
testdata/dot-ref/active.dot vendored Normal file
View File

@ -0,0 +1,15 @@
#!/usr/local/bin/dot
#
# Class diagram
# Generated by UMLGraph version R5_7_2-54-gbca0ce (http://www.spinellis.gr/umlgraph/)
#
digraph G {
edge [fontname="Helvetica",fontsize=10,labelfontname="Helvetica",labelfontsize=10];
node [fontname="Helvetica",fontsize=10,shape=plaintext];
nodesep=0.25;
ranksep=0.5;
// Active
c32 [label=<<table title="Active" border="0" cellborder="1" cellspacing="0" cellpadding="2" port="p"><tr><td rowspan="10"></td><td><table border="0" cellspacing="0" cellpadding="1"><tr><td align="center" balign="center"> Active </td></tr></table></td><td rowspan="10"></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="1"><tr><td align="left" balign="left"> </td></tr></table></td></tr><tr><td><table border="0" cellspacing="0" cellpadding="1"><tr><td align="left" balign="left"> run() </td></tr></table></td></tr></table>>, URL="null", fontname="Helvetica", fontcolor="black", fontsize=10.0];
}

13
testdata/java/active.java vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Active classes
*
* @opt operations
* @opt shape activeclass
* @hidden
*/
class UMLOptions {}
class Active {
protected int hidden;
public void run() {};
}