/******************************************************************************* | |
* <copyright> | |
* | |
* Copyright (c) 2013, 2013 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.fmc.blockdiagram.editor.features.resize; | |
import org.eclipse.fmc.blockdiagram.editor.algorithm.connection.FMCConnectionAlgorithm; | |
import org.eclipse.fmc.blockdiagram.editor.util.FMCUtil; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.features.context.IResizeShapeContext; | |
import org.eclipse.graphiti.features.context.impl.ResizeShapeContext; | |
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature; | |
/** | |
* | |
* @author Benjamin Schmeling | |
* | |
*/ | |
public class ChannelResizeFeature extends DefaultResizeShapeFeature { | |
public ChannelResizeFeature(IFeatureProvider fp) { | |
super(fp); | |
} | |
@Override | |
/* | |
* (non-Javadoc) | |
* | |
* @see | |
* org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature#resizeShape | |
* (org.eclipse.graphiti.features.context.IResizeShapeContext) | |
*/ | |
public void resizeShape(IResizeShapeContext context) { | |
int minimum = FMCUtil.getMinimum(context.getWidth(), | |
context.getHeight()); | |
if (minimum < FMCConnectionAlgorithm.CHANNEL_MIN_SIZE) | |
minimum = FMCConnectionAlgorithm.CHANNEL_MIN_SIZE; | |
ResizeShapeContext ctx = new ResizeShapeContext(context.getShape()); | |
ctx.setHeight(minimum); | |
ctx.setWidth(minimum); | |
ctx.setLocation(context.getX(), context.getY()); | |
super.resizeShape(ctx); | |
} | |
} |