本文整理汇总了Java中org.eclipse.graphiti.services.IGaService.setLocationAndSize方法的典型用法代码示例。如果您正苦于以下问题:Java IGaService.setLocationAndSize方法的具体用法?Java IGaService.setLocationAndSize怎么用?Java IGaService.setLocationAndSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.graphiti.services.IGaService
的用法示例。
在下文中一共展示了IGaService.setLocationAndSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addNode
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
protected ContainerShape addNode(Node node, ContainerShape parent, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peService.createContainerShape(parent, true);
PatternUtil.addShapeID(containerShape, "node");
link(containerShape, node);
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 15, 15);
gaService.setLocationAndSize(roundedRectangle, x, y, w, h);
//roundedRectangle.setBackground(getColorBackground(node));
roundedRectangle.setBackground(manageColor(ColorConstant.GREEN));
roundedRectangle.setForeground(getColorForeground(node));
addName(node, containerShape, 5, 5, w-5, 20);
return containerShape;
}
示例2: addNode
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
protected ContainerShape addNode(Node node, ContainerShape parent, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peService.createContainerShape(parent, true);
PatternUtil.addShapeID(containerShape, "node");
link(containerShape, node);
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 5, 5);
gaService.setLocationAndSize(roundedRectangle, x, y, w, h);
roundedRectangle.setBackground(getColorBackground(node));
roundedRectangle.setForeground(getColorForeground(node));
addName(node, containerShape, 5, 5, w-5, 20);
return containerShape;
}
示例3: addNode
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
@Override
protected ContainerShape addNode(Node node, ContainerShape parent, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peService.createContainerShape(parent, true);
PatternUtil.addShapeID(containerShape, "node");
link(containerShape, node);
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(containerShape, 5, 5);
gaService.setLocationAndSize(roundedRectangle, x, y, w, h);
roundedRectangle.setBackground(getColorBackground(node));
roundedRectangle.setForeground(getColorForeground(node));
addName(node, containerShape, 5, 5, w-5, 20);
return containerShape;
}
示例4: addNode
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
protected ContainerShape addNode(Node node, ContainerShape parent, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
ContainerShape containerShape = peService.createContainerShape(parent, true);
PatternUtil.addShapeID(containerShape, "node");
link(containerShape, node);
Polygon polygon = gaService.createPolygon(containerShape, new int[]{0,0, w,0, w+30,h/2, w,h, 0,h});
//createRoundedRectangle(containerShape, 15, 15);
gaService.setLocationAndSize(polygon, x, y, w, h);
polygon.setBackground(getColorBackground(node));
polygon.setForeground(getColorForeground(node));
addName(node, containerShape, 5, 0, w-5, h);
return containerShape;
}
示例5: createPortShape
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
/**
* Creates a port shape matching the direction along its actor shape, the single/multi and the input/output types.
*
* @param diagram
* @param anchor the anchor on which the port shape must be created
* @param direction
* @param p
* @return
*/
public static Polygon createPortShape(Diagram diagram, Anchor anchor, Direction direction, Port p) {
IGaService gaService = Graphiti.getGaService();
Collection<Point> portShapePoints = getPortShapeDefinition(direction, p);
final Polygon portShape = gaService.createPlainPolygon(anchor, portShapePoints);
portShape.setForeground(gaService.manageColor(diagram, PORT_FOREGROUND));
IColorConstant portColour = p.isMultiPort() ? PORT_BACKGROUND_MULTIPORT : PORT_BACKGROUND_SINGLEPORT;
portShape.setBackground(gaService.manageColor(diagram, portColour));
portShape.setLineWidth(1);
gaService.setLocationAndSize(portShape, 0, 0, PORT_SIZE, PORT_SIZE);
return portShape;
}
示例6: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例7: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例8: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例9: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例10: addName
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
protected void addName(Node node, ContainerShape root, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
Shape shape = peService.createShape(root, false);
PatternUtil.addShapeID(shape, "node_name");
Text textName = gaService.createText(shape, getTitle(node));
textName.setForeground(getColorText(node));
textName.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
gaService.setLocationAndSize(textName, x, y, w, h);
}
示例11: addName
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的package包/类
@Override
protected void addName(Node node, ContainerShape root, int x, int y, int w, int h){
// Get Graphiti services for easier access
IPeService peService = Graphiti.getPeService();
IGaService gaService = Graphiti.getGaService();
Shape shape = peService.createShape(root, false);
PatternUtil.addShapeID(shape, "node_name");
Text textName = gaService.createText(shape, node.getName());
textName.setForeground(getColorText(node));
textName.setHorizontalAlignment(Orientation.ALIGNMENT_LEFT);
textName.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
gaService.setLocationAndSize(textName, x, y, w, h);
}
示例12: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例13: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例14: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}
示例15: add
import org.eclipse.graphiti.services.IGaService; //导入方法依赖的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;
}