|
Re: Drag and Drop Multiple Pictogram elements from the Palette [message #1703922 is a reply to message #1703887] |
Wed, 05 August 2015 20:42 |
Marek Jagielski Messages: 97 Registered: April 2012 |
Member |
|
|
Hi,
In my editor I am adding rectangle with associated label that are separate pictogram elements. However they are both linked to the same business object and more linked to each other.
Please look at example from my code:
@Override
public PictogramElement add(IAddContext context) {
final Task addedTask = (Task) context.getNewObject();
final ContainerShape target = context.getTargetContainer();
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final IGaService gaService = Graphiti.getGaService();
final ContainerShape containerShape = peCreateService.createContainerShape(target, true);
int width = 0;
int height = 0;
width = context.getWidth() <= 0 ? getWidth() : context.getWidth();
height = context.getHeight() <= 0 ? getHeight() : context.getHeight();
final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width, height);
// create and set visible rectangle inside invisible rectangle
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 20, 20);
roundedRectangle.setParentGraphicsAlgorithm(invisibleRectangle);
roundedRectangle.setStyle(addedTask.isOnlyLocal() ? onlyLocalStyle : getStyle());
if(!addedTask.isAtomic()) roundedRectangle.setLineStyle(LineStyle.DOT);
gaService.setLocationAndSize(roundedRectangle, 0, 0, width, height);
insertInside(peCreateService, gaService, width, height, containerShape, invisibleRectangle, addedTask);
ContainerShape labelShape = addLabel(target, addedTask.getId(), width, height, context.getX(), context.getY());
link(containerShape, new Object[] {addedTask, labelShape});
link(labelShape, new Object[] {addedTask, containerShape});
updatePictogramElement(labelShape);
layoutPictogramElement(labelShape);
addInternalPorts(addedTask, containerShape);
updatePictogramElement(containerShape);
return containerShape;
}
I think that linking or making somehow relation between pictogram elements should be enough.
[Updated on: Wed, 05 August 2015 20:49] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02947 seconds