i'd like to know if it is possible to adjust the image export plugin to export the content of TreeView like editors also. For example i'd would be nice to be able to render PDF images from the content of the Ecore sample editor, or the GMF model editors also.
Best reagrds,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Thomas, good question. Thinking about it for a minute, my first answer is "probably not". I'd guess the tree views use SWT (or JFace, for that matter) tree widgets. The Image Export Plugin, however, uses org.eclipse.draw2d.Graphics objects to redirect the (Draw2D) standard IFigure painting. However, I haven't really hacked a TreeView-like editor, yet, so I'll dive into the GEF sources on the weekend to check. If you got any information regarding TreeViews and the SWT render machinery, please let me know.
Cheers, Thomas
P.S.: Are you using Eclipse 3.5? I only migrated my workspace to 3.5 a few days ago and haven't checked any farther than compile erros as yet (there weren't any). Does the plugin work on 3.5?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes the plugin is working on Eclipse 3.5.1. Unfortunately i also don't have a clue about the SWT render machinery. I checked the simple iText tutorial, and i saw that it is possible to usw java.awt.Graphics2D for PDF output… Though i have no idea yet, how to transform a Tree which is the content of the TreeViewer into a Graphics2D…
My first idea is the following:
GC gc = new GC(selectedViewer.getTree());
final Image image =
new Image(selectedViewer.getTree().getDisplay(), bounds.x, bounds.y);
gc.copyArea(image, 0, 0);
gc.dispose();
gc.drawImage(image, 0, 0);
g2.dispose();
But don't know if it works… There's a bug somehow in my export wizard, so i don't reach this code yet ^^
Regards,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i managed to get it running and successfully exported the content of a TreeViewer to a PDF document. Currently it is working for editors containing a TreeView that i wrote. If i'm not too busy with my PhD during the next weeks, i will try to find a more general solution.
Bye,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the late reply, I had to hack other projects. Plus I preferred to get at least a _bit_ social on the weekend :).
Good to know it works on 3.5.1, thanks!
If you use copyArea, however, of course all you get is a bitmap. I was hoping for something like "tell some SWT paint method to use some sort of Graphics2D adapter and paint the editor contents" to get at least some scalable text and lines into the PDF. Any idea about that? I have just opened some SWT source code in my Eclipse and will spend some time digging around to check whether that's doable.
Are you working on your own export plugin or are you working on a patch for the Image Export Plugin?
Cheers, Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
While I was digging on http://www.eclipse.org/swt/snippets/#gc and seeing your code snippet there ;) and after having thought about it for another minute, I guess my idea cannot work, because SWT uses native widgets instead of painting them itself. Which is the whole point of SWT of course :). So copying the bitmap is probably the only way to go if you don't want to use a screenshot utility or type Command-Shift-4 and do some mouse fiddling ;). What if the widget is only partially visible? Is the whole widget copied? That would be a real advantage, compared to just convenience :).
Good night for now, Thomas.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i implemented a 2nd solution, which always dumps the whole Tree to the PDF file. The tree is traversed and for each item the image and the text is rendered to the pdf. This solution provides a much better quality escpecially for text entries.
Bye,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
i'd like to know if it is possible to adjust the image export plugin to export the content of TreeView like editors also. For example i'd would be nice to be able to render PDF images from the content of the Ecore sample editor, or the GMF model editors also.
Best reagrds,
Thomas
Hi Thomas, good question. Thinking about it for a minute, my first answer is "probably not". I'd guess the tree views use SWT (or JFace, for that matter) tree widgets. The Image Export Plugin, however, uses org.eclipse.draw2d.Graphics objects to redirect the (Draw2D) standard IFigure painting. However, I haven't really hacked a TreeView-like editor, yet, so I'll dive into the GEF sources on the weekend to check. If you got any information regarding TreeViews and the SWT render machinery, please let me know.
Cheers, Thomas
P.S.: Are you using Eclipse 3.5? I only migrated my workspace to 3.5 a few days ago and haven't checked any farther than compile erros as yet (there weren't any). Does the plugin work on 3.5?
Hi Thomas,
yes the plugin is working on Eclipse 3.5.1. Unfortunately i also don't have a clue about the SWT render machinery. I checked the simple iText tutorial, and i saw that it is possible to usw java.awt.Graphics2D for PDF output… Though i have no idea yet, how to transform a Tree which is the content of the TreeViewer into a Graphics2D…
My first idea is the following:
GC gc = new GC(selectedViewer.getTree());
final Image image =
new Image(selectedViewer.getTree().getDisplay(), bounds.x, bounds.y);
gc.copyArea(image, 0, 0);
gc.dispose();
gc.drawImage(image, 0, 0);
g2.dispose();
But don't know if it works… There's a bug somehow in my export wizard, so i don't reach this code yet ^^
Regards,
Thomas
Hi,
i managed to get it running and successfully exported the content of a TreeViewer to a PDF document. Currently it is working for editors containing a TreeView that i wrote. If i'm not too busy with my PhD during the next weeks, i will try to find a more general solution.
Bye,
Thomas
Sorry for the late reply, I had to hack other projects. Plus I preferred to get at least a _bit_ social on the weekend :).
Good to know it works on 3.5.1, thanks!
If you use copyArea, however, of course all you get is a bitmap. I was hoping for something like "tell some SWT paint method to use some sort of Graphics2D adapter and paint the editor contents" to get at least some scalable text and lines into the PDF. Any idea about that? I have just opened some SWT source code in my Eclipse and will spend some time digging around to check whether that's doable.
Are you working on your own export plugin or are you working on a patch for the Image Export Plugin?
Cheers, Thomas
While I was digging on http://www.eclipse.org/swt/snippets/#gc and seeing your code snippet there ;) and after having thought about it for another minute, I guess my idea cannot work, because SWT uses native widgets instead of painting them itself. Which is the whole point of SWT of course :). So copying the bitmap is probably the only way to go if you don't want to use a screenshot utility or type Command-Shift-4 and do some mouse fiddling ;). What if the widget is only partially visible? Is the whole widget copied? That would be a real advantage, compared to just convenience :).
Good night for now, Thomas.
Good Morning ;)
i implemented a 2nd solution, which always dumps the whole Tree to the PDF file. The tree is traversed and for each item the image and the text is rendered to the pdf. This solution provides a much better quality escpecially for text entries.
Bye,
Thomas