JHotDraw Pattern Language

Customising Selection Behaviour


Selection is the action of identifying figures in the drawing. When a figure is selected in JHotDraw (via the selection tool) only those operations that are applicable should be displayed in the user interface (i.e. there is no point trying to edit text on a figure with no text!).

The DrawingView is responsible for maintaining the current selection. It has methods to add figures to and remove figures from the selection etc. When these events occur they trigger a sequence interaction to update the state of the GUI.

The major action that occurs on a change of selection is the invocation of the DrawApplication’s selectionChanged(DrawingView view) method this checks specific menus to determine which of their menu items will be executable on the figures in the current selection. If the menu item can work then it is enabled, if it cannot then it is disabled.

Tools are responsible for their own checks to ensure that they are operating on a valid figure, Handles on the other hand are always okay because they are displayed as a consequence of figure selection (in fact they are used to indicate selection).

   


Copyright Douglas Kirk