The new version of HotDraw has changed several things
from the previous, constraint’s version. Several seldom used, complex features
were removed, methods have been renamed, and tool creation is done differently.
Depending on how much your application used these features, you may not
want to update your application to the new HotDraw. This file describes most of
changes from the previous version.
- Several methods have been renamed to match their VisualWorks
counterparts. For example, #displayBox is now #bounds. The original version
of HotDraw was created before these messages existed in VisualWorks, so
their names were different than the VisualWorks versions.
- Layers have been removed. I didn’t know of anyone using them,
so I removed them. If you want them, it shouldn’t be too difficult to add
back.
- The constraint system has been removed. Nobody could understand
how to use them. Even if they did get them to "work", they would do strange,
unpredictable things. Constraints in the new HotDraw are created using
the standard dependency mechanisms from VisualWorks. There are two predefined
constraint classes: PositionConstraint - to attach to a specific point
of a figure and BoundaryConstraint - to attach to any point on the boundary
of a filled figure.
- The tool bar has been updated so that it looks more like
other applications.
- Common figure attributes (line width/color and fill color)
have been pulled into a FigureAttributes class. All figures have these
attributes, but some will "inherit" their attributes from their container
(when their attributes are nil). This should help memory consumption for
large drawings in which most figures don’t specialize these attributes.
Figures also have flags for transparent/opaque, visible/invisible, selected,
etc. See the "attribute accessing" protocol for the complete list of attributes.
- The InvisibilityWrapper has been replaced by an visible flag
in Figure. As a result, the displayOn: in Figure now sends displayFigureOn:
if it is visible. Also, Figure sends displaySelectedFigureOn: if it is
selected, and should be displayed (this allows you to display the figure
differently when selected).
- Several methods have been added to Figure to control when/where/how
connections are made to and from a figure. See the "connection" protocol.
- Arbitrary views can be inserted into drawings using the ViewAdapterFigure.
Tools can also be configured to send input to the view or capture all input.
- LineFigures now have annotations that can be put on the starting/ending
points of the line. Current annotations are arrows, circles, and diamonds.
- Added a RoundedRectangleFigure.
- Removed the ManhattanLineFigure class. I just haven’t gotten
around to adding it yet. If someone wants to add it, please send me the code
so that it can be integrated back into HotDraw.
- Removed the GroupFigure. Use a CompositeFigure instead. Originally
GroupFigures were created to speed up redraw, but with today’s 32bit displays
and fast graphics adapters, they were slower than CompositeFigures (for
most composites).
- Separated the animation part of the Drawing into an AnimatedDrawing
class. If your drawing uses animation make it a subclass of AnimatedDrawing.
- Merged the DrawingView, Drawing, and ConstraintDrawing classes.
The DrawingView didn’t add to much to the old Drawing class and the ConstraintDrawing
class was only needed for the complex constraint system.
- Completely redid tools resulting in the removal of the Reader
and Command classes. Tools are now defined by state machines. This allows
you to control all aspects of the tools (not only the mouse down stuff).
Since Commands have been removed, the "undo" feature has been removed (it
didn’t work well anyway).
To create a new tool, you can evaluate "ToolStateMachineEditor
open". This will create a window such as:
To add new states to the drawing, use the "add state" menu option from
the popup menu. Once you have added a new state, you can rename
it, change what it does on entry, specify that it is a end state (one that
after execution causes the tool to return to its initial state), or specify
that this state is defined in another drawing. All of these options available
from the state's pop-up menu.
Dragging the connection handle from one state to another will create
a transition from that state to the other state, whenever an event occurs.
You can change what type of event causes the transition to occur from the
transition figure's popup menu.
Once you have finished editing your tool's state machine, you will
need to compile the changes by selecting "compile" from the drawing's menu.
This will prompt you for a method name. This method will be compiled into
the "tool states" protocol of the Tool class. To reedit this tool, you
can simply browse the compiled method. At the top of this method will be
a comment that when evaluated rebuilds the drawing.
Here's a picture of the completed state machine for the polyline and
spline tools:
The "Menu" and "Cancel Figure Creation" states are defined by some
other drawing, and the "Line Tool End State" is the ending state for the
state machine. Whenever it is entered, it executes its command, and then
returns back to the initial state.
The commands for each state are entered through the command editor:
and must evaluate to a two argument block. The first argument is the
tool that contains the state, and the second argument is the event that
caused the transition. If this is an initial state for the tool, then the
event may be nil. The picture above shows the command for the "Add Point
to Line (Tool)" state. It first gets the figure that was set in the "Pressed
Line Tool" state, and then adds a point at the current cursor position.
- Changed the way the DrawingEditor specifies its Drawing and Tools. See the DrawingEditor "drawing description" protocol
to see the available methods for specializing for your drawing editor.