Skip to content

Commit

Permalink
Now displays two versions of the main relationships graph: a smaller …
Browse files Browse the repository at this point in the history
…'compact' version and a large full-size version. The compact version should make it easier to get a 'big picture' view of the relationships.
  • Loading branch information
johncurrier committed Aug 31, 2005
1 parent 2511dec commit 8739bd9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 19 deletions.
75 changes: 57 additions & 18 deletions src/net/sourceforge/schemaspy/view/HtmlGraphFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,37 @@ public boolean write(Table table, File graphDir, WriteStats stats, LineWriter ht
}

public boolean write(Database db, File graphDir, String dotBaseFilespec, boolean hasOrphans, boolean hasImpliedRelationships, LineWriter html) throws IOException {
File relationshipsDotFile = new File(graphDir, dotBaseFilespec + ".real.dot");
File relationshipsGraphFile = new File(graphDir, dotBaseFilespec + ".real.png");
File impliedDotFile = new File(graphDir, dotBaseFilespec + ".implied.dot");
File impliedGraphFile = new File(graphDir, dotBaseFilespec + ".implied.png");
File compactRelationshipsDotFile = new File(graphDir, dotBaseFilespec + ".real.compact.dot");
File compactRelationshipsGraphFile = new File(graphDir, dotBaseFilespec + ".real.compact.png");
File largeRelationshipsDotFile = new File(graphDir, dotBaseFilespec + ".real.large.dot");
File largeRelationshipsGraphFile = new File(graphDir, dotBaseFilespec + ".real.large.png");
File compactImpliedDotFile = new File(graphDir, dotBaseFilespec + ".implied.compact.dot");
File compactImpliedGraphFile = new File(graphDir, dotBaseFilespec + ".implied.compact.png");
File largeImpliedDotFile = new File(graphDir, dotBaseFilespec + ".implied.large.dot");
File largeImpliedGraphFile = new File(graphDir, dotBaseFilespec + ".implied.large.png");

try {
Dot dot = getDot();
if (dot == null)
return false;

dot.generateGraph(relationshipsDotFile, relationshipsGraphFile);
writeRelationshipsHeader(db, relationshipsGraphFile, impliedGraphFile, "Relationships Graph", hasOrphans, hasImpliedRelationships, html);
html.writeln(" <a name='graph'><img src='graphs/summary/" + relationshipsGraphFile.getName() + "' usemap='#relationshipsGraph' id='relationships' border='0' alt=''></a>");
dot.writeMap(relationshipsDotFile, html);
dot.generateGraph(compactRelationshipsDotFile, compactRelationshipsGraphFile);
System.out.print(".");
dot.generateGraph(largeRelationshipsDotFile, largeRelationshipsGraphFile);
System.out.print(".");
writeRelationshipsHeader(db, compactRelationshipsGraphFile, largeRelationshipsGraphFile, compactImpliedGraphFile, largeImpliedGraphFile, "Relationships Graph", hasOrphans, hasImpliedRelationships, html);
html.writeln(" <a name='graph'><img src='graphs/summary/" + compactRelationshipsGraphFile.getName() + "' usemap='#compactRelationshipsGraph' id='relationships' border='0' alt=''></a>");
dot.writeMap(compactRelationshipsDotFile, html);
dot.writeMap(largeRelationshipsDotFile, html);

if (hasImpliedRelationships) {
dot.generateGraph(impliedDotFile, impliedGraphFile);
dot.writeMap(impliedDotFile, html);
dot.generateGraph(compactImpliedDotFile, compactImpliedGraphFile);
dot.writeMap(compactImpliedDotFile, html);
System.out.print(".");

dot.generateGraph(largeImpliedDotFile, largeImpliedGraphFile);
dot.writeMap(largeImpliedDotFile, html);
System.out.print(".");
}

writeFooter(html);
Expand Down Expand Up @@ -164,7 +177,7 @@ public boolean writeOrphans(Database db, List orphanTables, boolean hasRelations
}
}

private void writeRelationshipsHeader(Database db, File relationshipsGraphFile, File impliedGraphFile, String title, boolean hasOrphans, boolean hasImpliedRelationships, LineWriter html) throws IOException {
private void writeRelationshipsHeader(Database db, File compactRelationshipsGraphFile, File largeRelationshipsGraphFile, File compactImpliedGraphFile, File largeImpliedGraphFile, String title, boolean hasOrphans, boolean hasImpliedRelationships, LineWriter html) throws IOException {
writeHeader(db, null, title, html);
html.writeln("<table width='100%'><tr><td class='tableHolder' align='left' valign='top'>");
html.write("<br/><a href='index.html'>Tables</a>&nbsp;&nbsp;");
Expand All @@ -173,17 +186,43 @@ private void writeRelationshipsHeader(Database db, File relationshipsGraphFile,
html.write("<a href='constraints.html' title='Useful for diagnosing error messages that just give constraint name or number'>Constraints</a>&nbsp;&nbsp;");
html.writeln("<a href='anomalies.html' title=\"Things that aren't quite right\">Anomalies</a>");

// this is some UGLY code!
html.writeln("<p/><form name='options' action=''>");
html.write(" <input type='checkbox' id='compact' checked onclick=\"");
html.write("if (this.checked) {");
if (hasImpliedRelationships) {
html.writeln("<p/><form name='options' action=''>");
html.write(" <input type='checkbox' id='graphType' onclick=\"");
html.write("if (!this.checked)");
html.write(" selectGraph('graphs/summary/" + relationshipsGraphFile.getName() + "', '#relationshipsGraph'); ");
html.write(" if (document.options.implied.checked)");
html.write(" selectGraph('graphs/summary/" + compactImpliedGraphFile.getName() + "', '#compactImpliedRelationshipsGraph'); ");
html.write("else");
html.write(" selectGraph('graphs/summary/" + impliedGraphFile.getName() + "', '#impliedRelationshipsGraph');");
html.write("\">");
}
html.write(" selectGraph('graphs/summary/" + compactRelationshipsGraphFile.getName() + "', '#compactRelationshipsGraph'); ");
html.write("} else {");
if (hasImpliedRelationships) {
html.write(" if (document.options.implied.checked) ");
html.write(" selectGraph('graphs/summary/" + largeImpliedGraphFile.getName() + "', '#largeImpliedRelationshipsGraph'); ");
html.write(" else");
}
html.write(" selectGraph('graphs/summary/" + largeRelationshipsGraphFile.getName() + "', '#largeRelationshipsGraph'); ");
html.write("}\">");
html.writeln("Compact");

// more butt-ugly 'code' follows
if (hasImpliedRelationships) {
html.write(" <input type='checkbox' id='implied' onclick=\"");
html.write("if (this.checked) {");
html.write(" if (document.options.compact.checked)");
html.write(" selectGraph('graphs/summary/" + compactImpliedGraphFile.getName() + "', '#compactImpliedRelationshipsGraph');");
html.write(" else ");
html.write(" selectGraph('graphs/summary/" + largeImpliedGraphFile.getName() + "', '#largeImpliedRelationshipsGraph'); ");
html.write("} else {");
html.write(" if (document.options.compact.checked)");
html.write(" selectGraph('graphs/summary/" + compactRelationshipsGraphFile.getName() + "', '#compactRelationshipsGraph'); ");
html.write(" else ");
html.write(" selectGraph('graphs/summary/" + largeRelationshipsGraphFile.getName() + "', '#largeRelationshipsGraph'); ");
html.write("}\">");
html.writeln("Include implied relationships");
html.writeln("</form>");
}
html.writeln("</form>");

html.writeln("<td class='tableHolder' align='right' valign='top'>");
writeLegend(false, html);
Expand Down
7 changes: 6 additions & 1 deletion src/net/sourceforge/schemaspy/view/JavaScriptFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public static void write(LineWriter out) throws IOException {
out.writeln(" cb.checked=true;");
out.writeln(" cb.click();");
out.writeln(" }");
out.writeln(" cb = options.graphType;");
out.writeln(" cb = options.compact;");
out.writeln(" if (cb && !cb.checked) {");
out.writeln(" cb.checked=true;");
out.writeln(" cb.click();");
out.writeln(" }");
out.writeln(" cb = options.implied;");
out.writeln(" if (cb && cb.checked) {");
out.writeln(" cb.checked=false;");
out.writeln(" cb.click();");
Expand Down

0 comments on commit 8739bd9

Please sign in to comment.