I'm currently trying to dump a graph within java for yEd. I've been trying to use graphml for the format, but I've found it to be very cumbersome. Particularly, the size of the nodes will not resize for the size of the label, so most of the time the label will be bigger than the actual file.
Is there anything I can do to remedy this without actually going in and specifying each 开发者_开发知识库node's width and height?
Thanks
There is a way, although that way uses unofficial API and may not work in any release but the current one (3.9.2 as of writing).
In the GraphML add the following key on the graph level:
<g:key id="ppkey" for="graph" yfiles.type="postprocessors"/>
<g:graph id="G" edgedefault="directed">
<g:data key="ppkey">
<y:Postprocessors>
<y:Processor class="A.A.A.A.A">
<y:Option name="IGNORE_WIDTHS" value="false"/>
<y:Option name="IGNORE_HEIGHTS" value="true"/>
<y:Option name="ADAPT_TO_MAXIMUM_NODE" value="false"/>
</y:Processor>
</y:Postprocessors>
</g:data>
</g:graph>
As you can see "A.A.A.A.A" obviously is an obfuscated class name and that may change between builds and in a way break your script.
The reason for this inconvenience is actually quite simple: yEd is not supposed to be used in an automated way (the license even explicitly forbids the purely automatic use case) and thus is optimized for interactive use. So clicking on the button is in fact intended. Why? Because yEd is a free product based on a powerful commercial library and it is only free because power users buy a license for the library and thus in a way sponsor yEd's development and support. If you really need to programmatically leverage that power you should take a look at licensing the library directly.
That said, you could also try the Excel import - it will automatically perform this step for you, however you will have to create an excel file to start from.
精彩评论