dspinellis / UMLGraph

Declarative specification and drawing of UML diagrams
http://www.spinellis.gr/umlgraph
BSD 3-Clause "New" or "Revised" License
343 stars 92 forks source link

Allow UmlGraphDoc Doclet to generate non-scaling SVG #44

Open robross0606 opened 7 years ago

robross0606 commented 7 years ago

When generating graphs in JavaDoc, the doclet automatically makes the graphs scale with the window. On large graphs, this renders them almost useless since the window cannot be scaled large enough to see anything. Is there an option to stop the SVG from scaling to the screen size and allow scrolling instead?

dspinellis commented 7 years ago

This cannot/should not be done at the level of UMLGraph. Instead, the corresponding page's CSS should adjusted accordingly.

robross0606 commented 7 years ago

It happens on EVERY page. Is there a specific CSS selector I can use to target every graph on every page of a package containing over 15,000 classes?

robross0606 commented 7 years ago

With all due respect, if you're going to say it should be done in CSS then you should be doing it in CSS too. I took a look at the code and the height/width values are set: <object width="100%" height="100%" type="image/svg+xml" data="AbstractApplicationModel.svg" alt="Package class diagram package AbstractApplicationModel" border="0"></object> How does one override these values from CSS when they're specifically set on the Object? Not to mention that the object itself doesn't have a selector ID or class.

dspinellis commented 7 years ago

You're right. This is output generated by GraphViz, so there's not much that can be done in UMLGraph, right? Maybe try setting GraphViz options? For example, I get different output from GraphViz.

$ echo 'digraph {}' | dot -Tsvg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.36.0 (20140111.2315)
 -->
<!-- Title: %3 Pages: 1 -->
<svg width="8pt" height="8pt"
 viewBox="0.00 0.00 8.00 8.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 4)">
<title>%3</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-4 4,-4 4,4 -4,4"/>
</g>
</svg>
robross0606 commented 7 years ago

I get same as you for the svg tag. The object tag is an outer element of what you just posted.

robross0606 commented 7 years ago

I found in your code where you are specifically setting this. UmlGraphDoc.java line 165. Recommend changing:

private static final String UML_DIV_TAG = "<div align=\"center\">" + "<object width=\"100%%\" height=\"100%%\" type=\"image/svg+xml\" data=\"%1$s.svg\" alt=\"Package class diagram package %1$s\" border=0></object>" + "</div>";

to:

private static final String UML_DIV_TAG = "<div align=\"center\">" + "<object type=\"image/svg+xml\" data=\"%1$s.svg\" alt=\"Package class diagram package %1$s\" border=0></object>" + "</div>";

If you want it to be 100% then, as you said, this should be done in CSS with the selector div.uml > object. Ideally, this could be an additional command-line parameter. After all, if something easily done in CSS like -bgcolor is a command line parameter, then why not this?

robross0606 commented 7 years ago

I have patched your code with a new -autosize doclet parameter. It defaults to true so existing functionality won't change. It does not yet address the use of CSS versus height and width usage. It does also fix a bug with your use of ! negated boolean parameters since they wouldn't match the valid option check. Let me know if/how you want to proceed.

dspinellis commented 7 years ago

This is great, thank you! Would you like to contribute two pull requests? One for the new feature (also please add a line in the documentation and usage info) and one on the fixed bug?

robross0606 commented 7 years ago

One pull request is fine with me as long as it is fine with you since it is intermingled in the same file. I did add a line in the documentation and usage info, but didn't add anything to the version documentation.

dspinellis commented 7 years ago

OK, let's do it like that.