Last updated at 5:02 am UTC on 27 June 2018
Connectors is a package by Ned Konz that turns Morphic into a drawing environment for making connected drawings.
- A Connector (NCAAConnectorMorph, marked blue in the diagram) is a Morph that looks like a line.
- The NCAAConnectorMorph object has a constraint on either end that keeps the ends attached to some other Morph (usually).
- Connectors work with any Morph.
The package also comes with several goodies that improve the drawing environment, including:
- Smart labels that position themselves to stay out of the way of whatever they're attached to
- Maker Buttons that save prototypes of Morphs and generate copies of them when pressed (example)
- A button bar that holds Maker Buttons
- A tool to adjust the attachment points on a Morph
- Several other shapes that share a common yellow-button context menu
Load the package through SqueakMap (head version).
After loading the connectors package execute
to get a flap for creating connectors.
You can also generate connections programmatically.
| green red |
green := Morph new
color: Color green;
red := Morph new
color: Color red;
connectStartTo: green ;
connectFinishTo: red ;
You can as well query the connections of a Connector or a Morph
TODO: add small example here ...
Some interactive documentation can be found in this project (2004)
ConnectorsMS-nk.pr and works for example in a squeak 3.6 or 3.7 image.
Screen copies here of it here: http://squeak.pbwiki.com/Connector%20Tutorial
This project has been ported to Squeak 4.x by Chris Muller, and the updated code is available at SqueakSource
Current and old versions are available at SqueakMap!
Connectors 2 has added:
- Antialiased drawing
- Bitmap and gradient fills
- Bezier curves replace the cubic splines
- Vertex management (drag an end and the other vertices get moved appropriately)
- Auto-straightening on disconnection (optional)
- EToy scripting support
- Arrows can be arbitrary TrueType glyphs
- Better integration with Genie
- More configurable for your own applications
In a 2006 paper about Etoys, Markus Gaelli et al use Connectors to implement a game, PetitPetri.
Download of the paper:
Connectors is compared with HotDraw: "connectors and their connected elements can be programmed directly: Whereas in Hotdraw one usually duplicates the topology of some graph by representing the graph both graphically and as a model, connectors invite the developer to directly manipulate the nodes and edges. Connectors e.g., provide expressions to send some messages to all incoming or to all outgoing nodes."
Question February 20, 2004 Hans Baveco: I am trying to adapt Connectors (1.9) to my needs - connecting only morphs of a certain class. I found out how to connect correctly when creating a new connector (an instance of a subclass of NCConnectorMorph I defined). However, how to proceed when disconnecting and reconnecting an existing morph? I want the blue handles to appear only on morphs that are allowed to be connected by my connector and can't figure out how to do this (currently the morphs in my application don't even show these handles, so one question is what determines whether the handles appear? I may have overridden some mouse event code or...?).
I guess the general question is "can one make connectors choosy?": with handles that show up only on the preferred morphs and only these preferred morph being connectable?
Answer Ned Konz Which handles do you mean? There are two things that I can think of:
I suspect you're talking about the second one. What you need to look at is:
- The curve vertex handles on the Connectors themselves, which can be turned on from the menu or a shift-click, and
- The connection highlighting that appears on potential connection destinations when you're dragging a Connector end. These show the potential attachment points on the morph.
Morph>>wantsAttachmentFromEnd: index ofConnector: aConnector
NCConnectorMorph>>wantsToAttachEnd: index toMorph: aMorph
NCConnectorMorph>>wantsToDetachEnd: index fromMorph: aMorph
Different types of decoration are possible in Connectors 2: