Use the Diva canvas for any application where you want to create and manipulate persistent Java2D graphics. By creating your own Figure class, you can create an item with arbitrary Java2D graphics that can be positioned on the screen, that redraws itself appropriately, and exhibits complex user interaction behavior.
Use the Diva Canvas if you need a ready-made hierarchical display architecture. By creating your own implementation of CanvasLayer, you can create totally arbitrary Java2D graphics that can then be hierarchically embedded within each other and within other Diva Canvas tools.
The short answer is that Swing is primarily a GUI widget set, while the Diva Canvas is primarily an interactive 2D graphics framework.
What the Diva canvas provides that Swing doesn't provide:
What Swing provides that the Diva canvas doesn't provide:
Several reasons. Swing widgets, in spite of what Sun's marketing machine says, are not particularly light-weight. Figures are small and (given the underlying platform) reasonable fast. We're interested in creating components with a lot of Figures on them, so we took some pains to keep them small. Also, we are interested in doing fairly complex graphics and interaction with Figures, and Swing widgets are design for a different purpose.
Simply put, CanvasPane is not a Swing component, it's a figure. We wrote PaneWrapper as a first attempt at exploring nested "surfaces" by embedding one CanvasPane as a figure within another CanvasPane. We have been wanting to figure out to embed arbitrary swing components within a canvas, but it just hasn't been a priority so far. If you have made custom Swing widgets that work properly with Java2D (particularly in the presence of affine transforms), email us some code!
Fairly early on in the design process, we decided to focus on the 2D graphics for the canvas, since 2D is where our key interests currently lie. There are lots of interesting issues in 2D information representation, which tend to get forgotten with 3D environments. The kind of issues you deal with when you scribble or draw in your notepad, for example. (When was the last time you saw anyone use a 3D sketch-pad?)
On the other hand, there's no particular reason not to construct 3D surfaces or viewers for visualization data, once we get the visualization protocols implemented. This is an independent issue from the canvas, though.
![]() |