本文整理汇总了Java中org.eclipse.graphiti.services.IPeCreateService.createContainerShape方法的典型用法代码示例。如果您正苦于以下问题:Java IPeCreateService.createContainerShape方法的具体用法?Java IPeCreateService.createContainerShape怎么用?Java IPeCreateService.createContainerShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.graphiti.services.IPeCreateService
的用法示例。
在下文中一共展示了IPeCreateService.createContainerShape方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
Entity addedActor = (Entity) context.getNewObject();
ContainerShape targetContainer = context.getTargetContainer();
int xLocation = context.getX();
int yLocation = context.getY();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
link(context, containerShape, addedActor, BoCategory.CompositeActor);
GraphicsAlgorithm invisibleRectangle = null;
invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
GraphicsAlgorithm actorShapeGA = null;
String iconResource = (String) context.getProperty("icon");
String iconType = (String) context.getProperty("iconType");
switch (iconType) {
case TriqFeatureProvider.ICONTYPE_SVG:
case TriqFeatureProvider.ICONTYPE_PTOLEMY:
actorShapeGA = buildExternallyDefinedShape(context, gaService, invisibleRectangle, containerShape, iconType, iconResource);
break;
default:
actorShapeGA = buildDefaultShape(context, gaService, invisibleRectangle, containerShape, addedActor, iconResource);
}
int width = actorShapeGA.getWidth();
int height = actorShapeGA.getHeight();
gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width + 15, height);
layoutPictogramElement(containerShape);
return containerShape;
}
示例2: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
Annotation addedAnnotation = (Annotation) context.getNewObject();
int textSize = addedAnnotation.getTextSize();
String pVal = addedAnnotation.getText();
Diagram targetDiagram = (Diagram) context.getTargetContainer();
int xLocation = context.getX();
int yLocation = context.getY();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);
Rectangle rectangle = gaService.createRectangle(containerShape);
gaService.setLocationAndSize(rectangle, xLocation, yLocation, WIDTH, (textSize + SPACING_INTERLINE) * HEIGHT_LINES);
rectangle.setBackground(manageColor(ANNOTATION_BACKGROUND));
// create shape for text
Shape shape = peCreateService.createShape(containerShape, false);
// create and set text graphics algorithm
MultiText text = gaService.createMultiText(shape, pVal);
text.setForeground(EditorUtils.buildColorFromString(getDiagram(), addedAnnotation.getColor()));
text.setHeight(HEIGHT_LINES);
text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
text.setFont(gaService.manageFont(getDiagram(), addedAnnotation.getFontFamily(), textSize, addedAnnotation.isItalic(), addedAnnotation.isBold()));
gaService.setLocationAndSize(text, X_OFFSET_TEXT, 0, WIDTH - X_OFFSET_TEXT, (textSize + SPACING_INTERLINE) * HEIGHT_LINES);
link(containerShape, addedAnnotation, BoCategory.Annotation);
layoutPictogramElement(containerShape);
return containerShape;
}
示例3: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
Vertex addedVertex = (Vertex) context.getNewObject();
ContainerShape targetContainer = context.getTargetContainer();
int xLocation = context.getX();
int yLocation = context.getY();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
int xy[] = new int[] { 6, 0, 12, 10, 6, 20, 0, 10 };
Polygon diamond = gaService.createPolygon(containerShape, xy);
diamond.setForeground(manageColor(VERTEX_BACKGROUND));
diamond.setBackground(manageColor(VERTEX_BACKGROUND));
gaService.setLocationAndSize(diamond, xLocation, yLocation, 12, 30);
// add an anchor in the Vertex
// TODO check if we need multiple anchors?
ChopboxAnchor anchor = peCreateService.createChopboxAnchor(containerShape);
anchor.setReferencedGraphicsAlgorithm(diamond);
link(anchor, addedVertex, BoCategory.Relation);
link(containerShape, addedVertex, BoCategory.Relation);
Map<String, Anchor> anchorMap = (Map<String, Anchor>) context.getProperty(FeatureConstants.ANCHORMAP_NAME);
if (anchorMap != null) {
anchorMap.put(addedVertex.getFullName(), anchor);
}
layoutPictogramElement(containerShape);
return containerShape;
}
示例4: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
public PictogramElement add(IAddContext context) {
CloudEnvironment provider = (CloudEnvironment)context.getNewObject();
Diagram targetDiagram = (Diagram) context.getTargetContainer();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetDiagram, true);
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 5, 5);
gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(), context.getWidth(), context.getHeight());
roundedRectangle.setBackground(gaService.manageColor(targetDiagram, BACKGROUND));
// roundedRectangle.setStyle(StyleUtil.getStyleForCloudProvider(targetDiagram));
Shape shape = peCreateService.createShape(containerShape, false);
Text text = gaService.createText(shape, provider.getName()==null ? "Name missing":provider.getName());
text.setForeground(gaService.manageColor(targetDiagram, TEXT));
text.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
gaService.setLocationAndSize(text, 5, 5, context.getWidth()-10, 20);
peCreateService.createChopboxAnchor(containerShape);
// TODO: enable the link to the domain object
link(containerShape, provider);
// Using PROVIDER layout
layoutPictogramElement(containerShape);
return containerShape;
}
示例5: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Diagram targetDiagram = (Diagram) context.getTargetContainer();
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final IGaService gaService = Graphiti.getGaService();
final Medium addedDomainObject = (Medium) context.getNewObject();
// Add the new Instance to the current Network
final Architecture architecture = (Architecture) getBusinessObjectForPictogramElement(getDiagram());
architecture.getMedia().add(addedDomainObject);
// Create the container shape
final ContainerShape topLevelShape = peCreateService.createContainerShape(targetDiagram, true);
PropertiesUtils.setPeIdentifier(topLevelShape, Medium.class);
// Create the container graphic
final Ellipse roundedRectangle = gaService.createPlainEllipse(topLevelShape);
roundedRectangle.setStyle(StyleUtils.mediumShape(getDiagram()));
gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(), SHAPE_WIDTH, SHAPE_HEIGHT);
// The text label for Instance name
final Text text = gaService.createPlainText(roundedRectangle);
PropertiesUtils.setPeIdentifier(text, LABEL_ID);
// Set properties on instance label
text.setStyle(StyleUtils.mediumText(getDiagram()));
gaService.setLocationAndSize(text, 0, 0, SHAPE_WIDTH, LABEL_HEIGHT);
if (addedDomainObject.getName() != null) {
text.setValue(addedDomainObject.getName());
}
// The line separator
final int[] xy = { 0, LABEL_HEIGHT, SHAPE_WIDTH, LABEL_HEIGHT };
final Polyline line = gaService.createPlainPolyline(roundedRectangle, xy);
PropertiesUtils.setPeIdentifier(line, SEP_ID);
line.setLineWidth(SHAPE_SEPARATOR);
// Configure direct editing
IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
directEditingInfo.setPictogramElement(topLevelShape);
directEditingInfo.setGraphicsAlgorithm(text);
directEditingInfo.setMainPictogramElement(topLevelShape);
// We link graphical representation and domain model object
link(topLevelShape, addedDomainObject);
// Create anchor
peCreateService.createChopboxAnchor(topLevelShape);
// create an additional box relative anchor at middle-right
BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(topLevelShape);
boxAnchor.setRelativeWidth(0.5);
boxAnchor.setRelativeHeight(0.0);
boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);
// assign a rectangle graphics algorithm for the box relative anchor
gaService.createPlainRectangle(boxAnchor);
return topLevelShape;
}
示例6: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Diagram targetDiagram = (Diagram) context.getTargetContainer();
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final IGaService gaService = Graphiti.getGaService();
final ProcessingUnit addedDomainObject = (ProcessingUnit) context.getNewObject();
// Add the new Instance to the current Network
final Architecture architecture = (Architecture) getBusinessObjectForPictogramElement(getDiagram());
architecture.getProcessingUnits().add(addedDomainObject);
// Create the container shape
final ContainerShape topLevelShape = peCreateService.createContainerShape(targetDiagram, true);
PropertiesUtils.setPeIdentifier(topLevelShape, type);
// Create the container graphic
final RoundedRectangle roundedRectangle = gaService.createPlainRoundedRectangle(topLevelShape, 5, 5);
roundedRectangle.setStyle(StyleUtils.processingUnitShape(getDiagram(), type));
gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(), SHAPE_WIDTH, SHAPE_HEIGHT);
// The text label for Instance name
final Text text = gaService.createPlainText(roundedRectangle);
PropertiesUtils.setPeIdentifier(text, LABEL_ID);
// Set properties on instance label
text.setStyle(StyleUtils.processingUnitText(getDiagram()));
gaService.setLocationAndSize(text, 0, 0, SHAPE_WIDTH, LABEL_HEIGHT);
if (addedDomainObject.getName() != null) {
text.setValue(addedDomainObject.getName());
}
// The line separator
final int[] xy = { 0, LABEL_HEIGHT, SHAPE_WIDTH, LABEL_HEIGHT };
final Polyline line = gaService.createPlainPolyline(roundedRectangle, xy);
PropertiesUtils.setPeIdentifier(line, SEP_ID);
line.setLineWidth(SHAPE_SEPARATOR);
// Configure direct editing
IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
directEditingInfo.setPictogramElement(topLevelShape);
directEditingInfo.setGraphicsAlgorithm(text);
directEditingInfo.setMainPictogramElement(topLevelShape);
// We link graphical representation and domain model object
link(topLevelShape, addedDomainObject);
// Create anchor
peCreateService.createChopboxAnchor(topLevelShape);
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(topLevelShape);
boxAnchor.setRelativeWidth(0.5);
boxAnchor.setRelativeHeight(1.0);
boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);
// assign a rectangle graphics algorithm for the box relative anchor
gaService.createPlainRectangle(boxAnchor);
return topLevelShape;
}
示例7: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
Attribute addedAttribute = (Attribute) context.getNewObject();
ContainerShape targetContainer = context.getTargetContainer();
int xLocation = context.getX();
int yLocation = context.getY();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
GraphicsAlgorithm invisibleRectangle = null;
invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
GraphicsAlgorithm attributeShapeGA = null;
String iconResource = (String) context.getProperty("icon");
String iconType = (String) context.getProperty("iconType");
switch (iconType) {
case TriqFeatureProvider.ICONTYPE_SVG:
case TriqFeatureProvider.ICONTYPE_PTOLEMY:
attributeShapeGA = buildExternallyDefinedShape(gaService, invisibleRectangle, containerShape, iconType, iconResource);
break;
default:
attributeShapeGA = buildDefaultShape(gaService, invisibleRectangle, containerShape, addedAttribute, iconResource);
}
int width = attributeShapeGA.getWidth();
int height = attributeShapeGA.getHeight();
gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width, height);
if (addedAttribute instanceof Parameter) {
link(containerShape, addedAttribute, BoCategory.Parameter);
} else {
link(containerShape, addedAttribute, BoCategory.Attribute);
}
layoutPictogramElement(containerShape);
return containerShape;
}
示例8: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
Entity addedActor = (Entity) context.getNewObject();
ContainerShape targetContainer = context.getTargetContainer();
// This should be a duplicate from what's in ModelElementCreateFeature,
// to link the toplevel CompositeActor to the Diagram.
// So let's try to do without this.
// Object topLevelForDiagram = getBusinessObjectForPictogramElement(getDiagram());
// if (topLevelForDiagram == null) {
// link(getDiagram(), addedActor.getContainer());
// }
int xLocation = context.getX();
int yLocation = context.getY();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(targetContainer, true);
link(context, containerShape, addedActor, BoCategory.Actor);
GraphicsAlgorithm invisibleRectangle = null;
invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
GraphicsAlgorithm actorShapeGA = null;
String iconResource = (String) context.getProperty("icon");
String iconType = (String) context.getProperty("iconType");
switch (iconType) {
case TriqFeatureProvider.ICONTYPE_SVG:
case TriqFeatureProvider.ICONTYPE_PTOLEMY:
actorShapeGA = buildExternallyDefinedShape(context, gaService, invisibleRectangle, containerShape, iconType, iconResource);
break;
default:
actorShapeGA = buildDefaultShape(context, gaService, invisibleRectangle, containerShape, addedActor, iconResource);
}
int width = actorShapeGA.getWidth();
int height = actorShapeGA.getHeight();
gaService.setLocationAndSize(invisibleRectangle, xLocation, yLocation, width + 2*ACTOR_X_MARGIN, height + 2*ACTOR_Y_MARGIN);
// SHAPES FOR PORTS; added both on default shapes and on custom/externally-defined icons (SVG, ptolemy icons)
Map<Direction, List<Port>> categorizedPorts = addedActor.getPorts().stream().collect(groupingBy(Port::getDirection, mapping(Function.identity(), toList())));
categorizedPorts.forEach((direction, ports) -> createAnchorsAndPortShapesForDirection(context, containerShape, direction, ports));
layoutPictogramElement(containerShape);
return containerShape;
}
示例9: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Event addedEvent = (Event) context.getNewObject();
final ContainerShape parent = context.getTargetContainer();
// CONTAINER SHAPE WITH CIRCLE
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
final int height = context.getHeight() <= 0 ? 35 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
Ellipse circle;
{
final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
invisibleCircle.setFilled(false);
invisibleCircle.setLineVisible(false);
gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);
// create and set visible circle inside invisible circle
circle = gaService.createEllipse(invisibleCircle);
circle.setParentGraphicsAlgorithm(invisibleCircle);
circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
circle.setLineWidth(3);
gaService.setLocationAndSize(circle, 0, 0, width, height);
if (addedEvent.eResource() == null) {
Object parentObject = getBusinessObjectForPictogramElement(parent);
if (parentObject instanceof SubProcess) {
((SubProcess) parentObject).getFlowElements().add(addedEvent);
} else {
getDiagram().eResource().getContents().add(addedEvent);
}
}
// create link and wire it
link(containerShape, addedEvent);
}
{
final Shape shape = peCreateService.createShape(containerShape, false);
final Image image = gaService.createImage(shape, ActivitiImageProvider.IMG_ENDEVENT_ERROR);
gaService.setLocationAndSize(image, 5, 5, 25, 25);
}
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
if (!(addedEvent instanceof EndEvent)) {
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(1.0);
boxAnchor.setRelativeHeight(0.51);
boxAnchor.setReferencedGraphicsAlgorithm(circle);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
}
layoutPictogramElement(containerShape);
return containerShape;
}
示例10: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Event addedEvent = (Event) context.getNewObject();
final ContainerShape parent = context.getTargetContainer();
// CONTAINER SHAPE WITH CIRCLE
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
final int height = context.getHeight() <= 0 ? 35 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
Ellipse circle;
{
final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
invisibleCircle.setFilled(false);
invisibleCircle.setLineVisible(false);
gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);
// create and set visible circle inside invisible circle
circle = gaService.createEllipse(invisibleCircle);
circle.setParentGraphicsAlgorithm(invisibleCircle);
circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
if (addedEvent instanceof EndEvent == true) {
circle.setLineWidth(3);
}
gaService.setLocationAndSize(circle, 0, 0, width, height);
// if addedClass has no resource we add it to the resource of the
// diagram
// in a real scenario the business model would have its own resource
if (addedEvent.eResource() == null) {
Object parentObject = getBusinessObjectForPictogramElement(parent);
if (parentObject instanceof SubProcess) {
((SubProcess) parentObject).getFlowElements().add(addedEvent);
} else {
getDiagram().eResource().getContents().add(addedEvent);
}
}
// create link and wire it
link(containerShape, addedEvent);
}
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
if (!(addedEvent instanceof EndEvent)) {
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(1.0);
boxAnchor.setRelativeHeight(0.51);
boxAnchor.setReferencedGraphicsAlgorithm(circle);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
}
if (addedEvent instanceof StartEvent && ((StartEvent) addedEvent).getEventDefinitions().size() > 0) {
final Shape shape = peCreateService.createShape(containerShape, false);
final Image image = gaService.createImage(shape, ActivitiImageProvider.IMG_BOUNDARY_TIMER);
image.setStretchH(true);
image.setStretchV(true);
image.setWidth(IMAGE_SIZE);
image.setHeight(IMAGE_SIZE);
gaService.setLocationAndSize(image, (width - IMAGE_SIZE) / 2, (height - IMAGE_SIZE) / 2, IMAGE_SIZE, IMAGE_SIZE);
}
layoutPictogramElement(containerShape);
return containerShape;
}
示例11: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Event addedEvent = (Event) context.getNewObject();
final ContainerShape parent = context.getTargetContainer();
// CONTAINER SHAPE WITH CIRCLE
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
final int height = context.getHeight() <= 0 ? 35 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
Ellipse circle;
{
final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
invisibleCircle.setFilled(false);
invisibleCircle.setLineVisible(false);
gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);
// create and set visible circle inside invisible circle
circle = gaService.createEllipse(invisibleCircle);
circle.setParentGraphicsAlgorithm(invisibleCircle);
circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
gaService.setLocationAndSize(circle, 0, 0, width, height);
if (addedEvent.eResource() == null) {
Object parentObject = getBusinessObjectForPictogramElement(parent);
if (parentObject instanceof SubProcess) {
((SubProcess) parentObject).getFlowElements().add(addedEvent);
} else {
getDiagram().eResource().getContents().add(addedEvent);
}
}
// create link and wire it
link(containerShape, addedEvent);
}
{
final Shape shape = peCreateService.createShape(containerShape, false);
final Image image = gaService.createImage(shape, ActivitiImageProvider.IMG_BOUNDARY_TIMER);
image.setStretchH(true);
image.setStretchV(true);
image.setWidth(33);
image.setHeight(33);
gaService.setLocationAndSize(image, 1, 1, 33, 33);
}
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
if (!(addedEvent instanceof EndEvent)) {
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(1.0);
boxAnchor.setRelativeHeight(0.51);
boxAnchor.setReferencedGraphicsAlgorithm(circle);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
}
layoutPictogramElement(containerShape);
return containerShape;
}
示例12: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
@Override
public PictogramElement add(IAddContext context) {
final Event addedEvent = (Event) context.getNewObject();
final ContainerShape parent = context.getTargetContainer();
// CONTAINER SHAPE WITH CIRCLE
final IPeCreateService peCreateService = Graphiti.getPeCreateService();
final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
// check whether the context has a size (e.g. from a create feature)
// otherwise define a default size for the shape
final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
final int height = context.getHeight() <= 0 ? 35 : context.getHeight();
final IGaService gaService = Graphiti.getGaService();
Ellipse circle;
{
final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
invisibleCircle.setFilled(false);
invisibleCircle.setLineVisible(false);
gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);
// create and set visible circle inside invisible circle
circle = gaService.createEllipse(invisibleCircle);
circle.setParentGraphicsAlgorithm(invisibleCircle);
circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
if (addedEvent instanceof EndEvent == true) {
circle.setLineWidth(3);
}
gaService.setLocationAndSize(circle, 0, 0, width, height);
// if addedClass has no resource we add it to the resource of the
// diagram
// in a real scenario the business model would have its own resource
if (addedEvent.eResource() == null) {
Object parentObject = getBusinessObjectForPictogramElement(parent);
if (parentObject instanceof SubProcess) {
((SubProcess) parentObject).getFlowElements().add(addedEvent);
} else {
getDiagram().eResource().getContents().add(addedEvent);
}
}
// create link and wire it
link(containerShape, addedEvent);
}
{
final Shape shape = peCreateService.createShape(containerShape, false);
final Image image = gaService.createImage(shape, "org.activiti.designer.alfresco.logo");
gaService.setLocationAndSize(image, 10, 10, IMAGE_SIZE, IMAGE_SIZE);
}
// add a chopbox anchor to the shape
peCreateService.createChopboxAnchor(containerShape);
// create an additional box relative anchor at middle-right
final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
boxAnchor.setRelativeWidth(1.0);
boxAnchor.setRelativeHeight(0.51);
boxAnchor.setReferencedGraphicsAlgorithm(circle);
final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
layoutPictogramElement(containerShape);
return containerShape;
}
示例13: add
import org.eclipse.graphiti.services.IPeCreateService; //导入方法依赖的package包/类
public PictogramElement add(IAddContext context) {
OperationInterfaceContainer oic = (OperationInterfaceContainer)context.getNewObject();
ContainerShape parentShape = context.getTargetContainer();
Diagram diagram = Graphiti.getPeService().getDiagramForPictogramElement(parentShape);
IPeCreateService peCreateService = Graphiti.getPeCreateService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peCreateService.createContainerShape(parentShape, true);
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 5, 5);
gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(),
Math.max(context.getWidth(),40), Math.max(context.getHeight(),20));
if (oic instanceof ProvidedService){
roundedRectangle.setBackground(gaService.manageColor(diagram, BACKGROUND_DS_PLATFORM_SERVICE));
}
else {
roundedRectangle.setBackground(gaService.manageColor(diagram, BACKGROUND_ES_PLATFORM_SERVICE));
}
roundedRectangle.setLineVisible(true);
roundedRectangle.setLineWidth(1);
roundedRectangle.setForeground(gaService.manageColor(diagram, new ColorConstant("000000")));
// TEXT
{
Shape shape = peCreateService.createShape(containerShape, false);
Text text = gaService.createText(shape, oic.getName());
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
if(oic instanceof ProvidedService){
text.setForeground(gaService.manageColor(diagram, TEXT_ES_PLATFORM_SERVICE));
}
else{
text.setForeground(gaService.manageColor(diagram, TEXT_DS_PLATFORM_SERVICE));
}
/*
if (platformService instanceof ProvidedPlatformRuntimeService){
text.setForeground(gaService.manageColor(diagram, TEXT_ER_PLATFORM_SERVICE));
}
else if (platformService instanceof ProvidedPlatformSupportService){
text.setForeground(gaService.manageColor(diagram, TEXT_ES_PLATFORM_SERVICE));
}
else if (platformService instanceof PlatformRuntimeService){
text.setForeground(gaService.manageColor(diagram, TEXT_DR_PLATFORM_SERVICE));
}
else if (platformService instanceof PlatformSupportService){
text.setForeground(gaService.manageColor(diagram, TEXT_DS_PLATFORM_SERVICE));
}
*/
gaService.setLocationAndSize(text, 0, 0, context.getWidth(), context.getHeight());
// create link and wire it
// link(shape, oic);
// provide information to support direct-editing directly
// after object creation (must be activated additionally)
final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
// set container shape for direct editing after object creation
directEditingInfo.setMainPictogramElement(containerShape);
// set shape and graphics algorithm where the editor for
// direct editing shall be opened after object creation
directEditingInfo.setPictogramElement(shape);
directEditingInfo.setGraphicsAlgorithm(text);
}
peCreateService.createChopboxAnchor(containerShape);
// TODO: enable the link to the domain object
link(containerShape, oic);
layoutPictogramElement(containerShape);
return containerShape;
}