本文整理汇总了Java中org.eclipse.graphiti.services.IPeCreateService.createBoxRelativeAnchor方法的典型用法代码示例。如果您正苦于以下问题:Java IPeCreateService.createBoxRelativeAnchor方法的具体用法?Java IPeCreateService.createBoxRelativeAnchor怎么用?Java IPeCreateService.createBoxRelativeAnchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.graphiti.services.IPeCreateService
的用法示例。
在下文中一共展示了IPeCreateService.createBoxRelativeAnchor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}