Last updated at 12:09 pm UTC on 11 May 2018
Connectors is a package by Ned Konz that turns Morphic into a drawing environment for making connected drawings.
A Connector (NCConnectorMorph) is a Morph that looks like a line and 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
- 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
You can query the connections of a Connector or a Morph, and can generate connections programmatically.
Some interactive documentation can be found in this project (a few years old)
ConnectorsMS-nk.pr and works for example in a squeak 3.6 or 3.7 image.
Screen copies here ot 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
Here's some pictures of what is possible with Connectors 2 as far as decoration:
In a 2006 paper about Etoys, Markus Gaelli et al use Connectors to implement a game, .http://scg.unibe.ch/archive/papers/Gael06aC5.pdf They compare Connectors 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