Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Connectors
Last updated at 12:29 pm UTC on 18 October 2012
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:

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 squeak3.6 image.

Here is a great tutorial: 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

Older versions are available at SqueakMap!

Connectors 2 has added:


Here's some pictures of what is possible with Connectors 2 as far as decoration:

Uploaded Image: Ends.jpg
Uploaded Image: C2.jpg

In a 2006 paper about Etoys, Markus Gaelli et al use Connectors to implement a game,
PetriPetri: 
.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:
Morph>>wantsAttachmentFromEnd: index ofConnector: aConnector
and
NCConnectorMorph>>wantsToAttachEnd: index toMorph: aMorph
NCConnectorMorph>>wantsToDetachEnd: index fromMorph: aMorph