Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Print to PDF - Edge connects multiple nodes
Print to PDF - Edge connects multiple nodes [message #1766976] Thu, 29 June 2017 08:27 Go to next message
Du Vu is currently offline Du VuFriend
Messages: 3
Registered: June 2017
Junior Member
Hi all
I posted a question on stackoverflow (complex-gef4-zest-example-print-to-pdf-edge-connects-multiple-nodes) but I think it's better to make it here. Sorry if you already saw it there.

In my code, I use the classes under gef4.graph.* and gef4.zest.fx.*.

So my questions are:
1. Is that possible to connect an edge to multiple nodes, meaning that with a start and an end node, but also via a few other nodes?

2. Is that possible to print the whole graph to PDF file? - to image is already available.

Thanks for your support!
Cheers
Duvu
Re: Print to PDF - Edge connects multiple nodes [message #1767024 is a reply to message #1766976] Thu, 29 June 2017 15:20 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
Hi Du Vu,

1. Not out-of-the-box, but you can simulate such an edge either via way points (located at the intermediary station), or via two edges. Moreover, Zest (as a grey box framework) can be customized, i.e. you can extend EdgePart to fit your needs (e.g. evaluate a custom attribute holding intermediary nodes), or extend GraphPart to fix the Z-order, so that edges with intermediary stations are drawn above these stations.

2. Not out-of-the-box, but from the top of my head, I can think of three solutions:

a) JavaFX offers a PrinterJob [1] that can be used to print a JavaFX Node. You need to configure it correctly for printing to PDF, though. The appearance within the PDF will match the drawing on the display.

b) You can convert the JavaFX image to an AWT BufferedImage and print it using the Java AWT Printing API [2].

c) When Graphviz is available you can delegate to Graphviz for PDF generation. You have to convert the Zest-attributed graph to a Dot-attributed graph (possibly using Zest2DotAttributesConverter, although it is not API), serialize the graph using DotExport#exportDot(Graph), and use Graphviz to generate the PDF. For a code example, you can take a look at DotExecutableUtilsTests#testImageExport(String), which produces a PDF from a Dot input file. Unfortunately, the appearance (colors, thicknesses, etc.) will not be preserved.

[1] https://docs.oracle.com/javase/8/javafx/api/javafx/print/PrinterJob.html
[2] https://docs.oracle.com/javase/tutorial/2d/printing/printable.html

PS: I am checking for questions tagged "eclipse-gef" on SO from time to time, but not on a daily basis. OTOH, many people involved are active in this forum, so you have higher chances of getting responses here.

Best regards,
Matthias
Re: Print to PDF - Edge connects multiple nodes [message #1767106 is a reply to message #1767024] Sat, 01 July 2017 06:34 Go to previous messageGo to next message
Du Vu is currently offline Du VuFriend
Messages: 3
Registered: June 2017
Junior Member
Thanks for your quick support Matthias!
I am going to try to extend the Edge part and try to render the connections in the way that it has connection points at the border of the intermediate node.

The solution of via 2 edges were also thought, but then we still have to render a line inside the intermediate station box to "connect" the 2 edge connecting points with the box, simulating that it's a "one line" from 2 end stations.

I did't get any notification from Eclipse on your approval of my question/your answer! only the one from stackoverflow!

Cheers
Du

[Updated on: Sat, 01 July 2017 06:35]

Report message to a moderator

Re: Print to PDF - Edge connects multiple nodes [message #1767138 is a reply to message #1767106] Sat, 01 July 2017 20:41 Go to previous messageGo to next message
Du Vu is currently offline Du VuFriend
Messages: 3
Registered: June 2017
Junior Member
Hi Matthias, if I use the way points (control points) solution, is there a way to add label at a certain point (meaning if a point "attached" to a label will have it displayed)?
Thanks
Du
Re: Print to PDF - Edge connects multiple nodes [message #1768074 is a reply to message #1767138] Thu, 13 July 2017 12:51 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
Hi Du Vu,

unfortunately, you will have to implement additional labels by yourself. The contents for the labels are generated by GraphPart#doGetContentChildren(). Additional roles need to be specified for the additional labels (e.g. MID_LABEL), and the EdgeLabelPart needs to be subclassed, so that you can adjust the position computation for the new labels, e.g. using the control point location as the label position.

Best regards,
Matthias
Previous Topic:[GEF5] Oxygen target won't load
Next Topic:Edit node and create new connections GEF/ZEST 5
Goto Forum:
  


Current Time: Tue Sep 25 10:40:28 GMT 2018

Powered by FUDForum. Page generated in 0.02537 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top