hi, i think there are some similar problems but i couldn't get smart of them.
This is the problem:
I have a Rectangle on my Diagram
@Override
public PictogramElement add(IAddContext context) {
Shape ladder = createLadderGraphic(context);
getDiagram().eResource().getContents()
.add((EObject) context.getNewObject());
link(ladder, context.getNewObject());
return ladder;
}
private Shape createLadderGraphic(IAddContext context) {
Diagram targetDiagram = (Diagram) context.getTargetContainer();
IGaService gaService = Graphiti.getGaService();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
Ladder bo = (Ladder) context.getNewObject();
// 1 containershape
ContainerShape containerShape = peCreateService.createContainerShape(
targetDiagram, true);
Rectangle rectangle = gaService.createRectangle(containerShape);
rectangle.setBackground(manageColor(StyleUtil.COLOR_BLACK));
rectangle.setFilled(true);
gaService.setLocationAndSize(rectangle, context.getX(), context.getY(),
context.getWidth(), context.getHeight());
return containerShape;
}
Works 
Now this what i am trying....
Creating a Connection from the location i clicked in the shape to the target.
I hooked into attach
@Override
public void attachedToSource(final ICreateConnectionContext context) {
final Object bo = getBusinessObjectForPictogramElement(context
.getSourcePictogramElement());
// create fix anchor for connection on ladder
if (bo instanceof StartLadder) {
TransactionalEditingDomain editingDomain = getDiagramEditor()
.getEditingDomain();
CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
IPeCreateService peCreateService = Graphiti
.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape container = (ContainerShape) context
.getSourcePictogramElement();
ILocation location = context.getSourceLocation();
int x = location.getX();
int y = location.getY();
// Point p = gaService.createPoint(x, y);
ChopboxAnchor anchor = peCreateService
.createChopboxAnchor(container);
// gaService.setLocation(anchor, x, y);
// anchor.setUseAnchorLocationAsConnectionEndpoint(true);
Rectangle rect = gaService.createRectangle(anchor);
gaService.setLocation(rect, x, y);
anchor.setGraphicsAlgorithm(rect);
anchor.setReferencedGraphicsAlgorithm(rect);
IEC_Anchor obj = FbsFactory.eINSTANCE.createIEC_Anchor();
obj.setIn(false);
obj.setSource((EObject) bo);
getDiagram().eResource().getContents().add(obj);
// link(shape, obj);
link(anchor, bo);
// use anchor
((CreateConnectionContext) context).setSourceAnchor(anchor);
}
});
}
}
looking the attached jpg.
but i dont want chopbox anchor because it starts from the middle of the shape.
any hints?
BR
Thomas