/******************************************************************************* | |
* <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.features.add.DotsConnectionAddFeature; | |
import org.eclipse.fmc.blockdiagram.editor.features.add.DotsShapeAddFeature; | |
import org.eclipse.graphiti.features.IFeatureProvider; | |
import org.eclipse.graphiti.features.context.IResizeShapeContext; | |
import org.eclipse.graphiti.features.impl.DefaultResizeShapeFeature; | |
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; | |
import org.eclipse.graphiti.mm.pictograms.ContainerShape; | |
import org.eclipse.graphiti.mm.pictograms.Shape; | |
import org.eclipse.graphiti.services.Graphiti; | |
/** | |
* | |
* @author Benjamin Schmeling | |
* | |
*/ | |
public class DotsShapeResizeFeature extends DefaultResizeShapeFeature { | |
public DotsShapeResizeFeature(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) { | |
ContainerShape container = (ContainerShape) context | |
.getPictogramElement(); | |
Graphiti.getGaService().setLocationAndSize( | |
container.getGraphicsAlgorithm(), context.getX(), | |
context.getY(), context.getWidth(), context.getHeight()); | |
int i = 0; | |
if (context.getWidth() > context.getHeight()) { | |
int gap = DotsShapeAddFeature.getDotsGap(context.getWidth()); | |
for (Shape shape : container.getChildren()) { | |
GraphicsAlgorithm graphicsAlgorithm = shape | |
.getGraphicsAlgorithm(); | |
Graphiti.getGaService().setLocationAndSize(graphicsAlgorithm, | |
0 + (i) * gap, context.getHeight() / 2, | |
DotsConnectionAddFeature.DOTS_SIZE, | |
DotsConnectionAddFeature.DOTS_SIZE); | |
i++; | |
} | |
} else { | |
int gap = DotsShapeAddFeature.getDotsGap(context.getHeight()); | |
for (Shape shape : container.getChildren()) { | |
GraphicsAlgorithm graphicsAlgorithm = shape | |
.getGraphicsAlgorithm(); | |
Graphiti.getGaService().setLocationAndSize(graphicsAlgorithm, | |
context.getWidth() / 2, 0 + (i) * gap, | |
DotsConnectionAddFeature.DOTS_SIZE, | |
DotsConnectionAddFeature.DOTS_SIZE); | |
i++; | |
} | |
} | |
} | |
} |