I am am trying to build a user interface for graphical programming. I would like to use JUNG to handle the graph aspects of the drawing. Rather than draw all of my widgets using Graphics2D, I would like to use Swing widgets as often as possible to take advantage of Swing's event architecture.
I would like to be able to pan, zoom, rotate the canvas the graph is drawn on, but still retain the ability to manipulate the Swing widgets as long as they are large enough to see. I also want the widgets to be automatically laid out based on the JUNG layout algorithm I have chosen.
How do I combine Graphics2D drawings and Swing components?
I understand that JComponents take care of drawing themselves using their paint()
methods. What I am having trouble understanding is how to create Swing objects that can be affected by Graphics2D transforms and still retain all of their event handling. I can't just show an image of the component. The component must be live.
I've tried subclassing a widget and adding a AffineTransform to the graphics object that is passed to the parent's paint
method. It rotates the widget, but the clipping appears to be off.
Any suggestions? For the time being, I'd like to avoid adding another library if I can.