/** * <copyright> * * Copyright (c) 2012, 2012 SAP AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * SAP AG - initial API, implementation and documentation * * </copyright> */ package org.eclipse.graphiti.examples.filesystem.features; import org.eclipse.graphiti.features.IAddFeature; import org.eclipse.graphiti.features.IFeatureProvider; import org.eclipse.graphiti.features.context.IAddConnectionContext; import org.eclipse.graphiti.features.context.IAddContext; import org.eclipse.graphiti.features.impl.AbstractAddFeature; import org.eclipse.graphiti.mm.algorithms.Polyline; import org.eclipse.graphiti.mm.pictograms.Connection; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.graphiti.services.Graphiti; import org.eclipse.graphiti.services.IGaService; import org.eclipse.graphiti.services.IPeCreateService; import org.eclipse.graphiti.util.IColorConstant; public class AddContainmentConnectionFeature extends AbstractAddFeature implements IAddFeature { public AddContainmentConnectionFeature(IFeatureProvider fp) { super(fp); } public boolean canAdd(IAddContext context) { return context instanceof IAddConnectionContext; } public PictogramElement add(IAddContext context) { IAddConnectionContext addConContext = (IAddConnectionContext) context; IPeCreateService peCreateService = Graphiti.getPeCreateService(); IGaService gaService = Graphiti.getGaService(); Connection connection = peCreateService.createCurvedConnection(new double[] { 0d, 0d, 0.5d, -50d, 1d, 0d }, getDiagram()); connection.setStart(addConContext.getSourceAnchor()); connection.setEnd(addConContext.getTargetAnchor()); Polyline polyline = gaService.createPlainPolyline(connection); polyline.setForeground(manageColor(IColorConstant.BLACK)); return connection; } }