Swankguy I've been in a flurry of work on the Swank canvas widget lately (to support features I need in software that uses it). Before I release the next version of Swank I wanted to organize my thoughts (and get feedback). This page summarizes some of the differences between this widget and the canvas widget in Tk (at least as compared to the last time I used it). Some, but not all of these features are in the current release.
The image below illustrates some, but not all of the differences. The image is from the program NMRViewJ, written in Java and using Jacl and Swank. The NMR spectra are in custom canvas items, not part of the normal Swank distribution.
Colors
Gradients: Some canvas items, such as rectangles, support gradient fills. The spectra in the example are basically transparent, but are here configured with gradient fills. Example: -gradient "0 0 red 1 0 orange"
Textures: Some canvas items, such as rectangles, support textures (with images).
Colors can be transparent. Example, -fill "255 255 0 128" (yellow with 50% opacity
Line End Points
Lines can have a different style of endpoint at each end (arrow, square, circle, diamond, none).
Text
In addition to normal text items, there are htext items. These support many HTML tags and some CSS styles (as implemented by Java Swing HTML endowed text widgets). The image shows one text item with an H2 header, superscripts, bold and italic text. The table item is a htext item layed out using HTML table tags.
Affine Transforms
Item Transforms: All items can have an Affine transform associated with them. In the example below, the custom spectrum widgets generate what I refer to as "world" and "fractional" transforms. The transparent blue (looks purple on the red spectrum) rectangle has a "-transform world0" configuration. The coordinates are thereby set in terms of the internal coordinate system of the red spectrum. The green rectangle has a "-transform frac1" configuration. No matter where you move the red and orange spectrum items on the canvas the blue and green ones will stay in the same relative position.
Zoom:the whole canvas has an Affine Transform associated with it, the scale of which is changed with the canvas "zoom" subcommand. This allows one to zoom the view in or out.
shapexy and invshapexy subcommands can be used to transform between coordinates used by a specified shape and pixel positions of the canvas.
-rotate: All canvas items support a -rotate configuration (in degrees).
Charts
Charts: Charts are implemented using JFreeChart [L1 ]. In the Swank implementation they are essentially just another item that can be placed on the canvas. The chart shown, for example, is not implemented by using a bunch of individual canvas items, as would be done in Tk, but is instead a single chart item.
Handle Selection
hselect command: All items can be selected using an "hselect" subcommand. Any items that are selected are displayed with selection handles (see the text item on example).
Cursor indication: When the mouse enters a handle the cursor is changed to an "appropriate" resize cursor.
Handles are not implemented as separate canvas items, but are fundamentally displayed by the underlying Java code. Moving and resizing selected items is the responsibility of "user code" and is not currently part of Swank (but is easily implemented).
Tags: Items selected with "hselect" have an effective "hselect" tag.
Also see Swank Canvas Widget Geometric Items where the additional canvas items symbols and segments are illustrated. Also this page shows that rectangles (and also, but not shown, ovals) can have text associated with them.