org.eclipse.swt.graphics.Rectangle shadowRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X + SHADOW_WIDTH, 0 + BASE_RECT_SPACE_Y + SHADOW_HEIGHT, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
org.eclipse.swt.graphics.Rectangle contentRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y, content_width, image_height + label_height + IMAGE_LABEL_SPACE + TOP_BOTTOM_SPACE + TOP_BOTTOM_SPACE);
org.eclipse.swt.graphics.Rectangle imageRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + TOP_BOTTOM_SPACE, content_width, image_height);
org.eclipse.swt.graphics.Rectangle labelRect = new org.eclipse.swt.graphics.Rectangle(0 + BASE_RECT_SPACE_X, 0 + BASE_RECT_SPACE_Y + image_height + IMAGE_LABEL_SPACE, content_width, label_height + TOP_BOTTOM_SPACE);
final IGaService gaService = Graphiti.getGaService();
final RoundedRectangle baseRectangle = gaService.createRoundedRectangle(containerShape, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
// create invisible outer rectangle expanded by
// the width needed for the anchor
gaService.setLocationAndSize(baseRectangle, baseRect.x, baseRect.y, baseRect.width, baseRect.height);
baseRectangle.setFilled(false);
baseRectangle.setLineVisible(false);
// shadow
RoundedRectangle shadowRectangle; // need to access it later
{
// create and set visible rectangle inside invisible rectangle
shadowRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
shadowRectangle.setParentGraphicsAlgorithm(baseRectangle);
shadowRectangle.setStyle(StyleUtil.getShadowStyleForCamelClass(getDiagram()));
shadowRectangle.setLineVisible(false);
shadowRectangle.setFilled(true);
gaService.setLocationAndSize(shadowRectangle, shadowRect.x, shadowRect.y, shadowRect.width, shadowRect.height);
}
// the real figure
RoundedRectangle roundedRectangle; // need to access it later
{
// create and set visible rectangle inside invisible rectangle
roundedRectangle = gaService.createRoundedRectangle(baseRectangle, ROUNDED_RECTANGLE_WIDTH, ROUNDED_RECTANGLE_HEIGHT);
roundedRectangle.setParentGraphicsAlgorithm(baseRectangle);
roundedRectangle.setStyle(StyleUtil.getStyleForCamelClass(getDiagram()));
gaService.setLocationAndSize(roundedRectangle, contentRect.x, contentRect.y, contentRect.width, contentRect.height);
}
// image
{
// create shape for image
final Shape shape = peCreateService.createShape(containerShape, false);
// create and set image
final Image image = gaService.createImage(shape, ImageProvider.getKeyForLargeIcon(addedClass.getIconName()));
gaService.setLocationAndSize(image, imageRect.x, imageRect.y, imageRect.width, imageRect.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 (addedClass.eResource() == null) {
// getDiagram().eResource().getContents().add(addedClass);
// }
}
// SHAPE WITH TEXT
{
// create shape for text
final Shape shape = peCreateService.createShape(containerShape, false);
// create and set text graphics algorithm
final Text text = gaService.createDefaultText(getDiagram(), shape, label);
Style style = StyleUtil.getStyleForCamelText(getDiagram());
text.setStyle(style);
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
text.setFont(style.getFont());
gaService.setLocationAndSize(text, labelRect.x, labelRect.y, labelRect.width, labelRect.height);
// create link and wire it
// link(shape, addedClass);
// provide information to support direct-editing directly