public final Image addDecoration(
     IPapyrusDecoration pDecoration, int percentageFromSource, int margin, boolean isVolatile) {
   // use image registry, see bug 401056
   Image image = Activator.getPluginIconImage(Activator.ID, pDecoration.getDecorationImageForGE());
   IDecoration decoration =
       createDecorationImage(decoratorTarget, image, percentageFromSource, margin, isVolatile);
   if (decoration != null) {
     decorations.add(decoration);
     String message = pDecoration.getMessage();
     Label toolTip = getToolTip(message);
     if (decoration instanceof Decoration) {
       ((Decoration) decoration).setToolTip(toolTip);
     }
     return image;
   } else {
     return null;
   }
 }
  /**
   * Create a decoration based on an image
   *
   * @param decoratorTarget the decorator target
   * @param image the image
   * @param position the position
   * @param percentageFromSource the percentage from source, only evaluated for edge decorations
   * @param margin the margin in pixels from the target position. @See
   *     org.eclipse.gmf.runtime.diagram.ui.services.decorator.addShapeDecoration: The margin is the
   *     space, in himetric units, between the shape's edge and the decoration. A positive margin
   *     will place the figure outside the shape, a negative margin will place the decoration inside
   *     the shape.
   * @param isVolatile the is volatile
   * @return the decoration
   */
  public final IDecoration createDecorationImage(
      IDecoratorTarget decoratorTarget,
      Image image,
      int percentageFromSource,
      int margin,
      boolean isVolatile) {
    final View view = (View) decoratorTarget.getAdapter(View.class);
    org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoration decoration = null;
    if (view == null || view.eResource() == null || image == null) {
      return decoration;
    }
    EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
    if (editPart == null || editPart.getViewer() == null) {
      return decoration;
    }
    if (view instanceof Edge) {

      decoration = decoratorTarget.addConnectionDecoration(image, percentageFromSource, isVolatile);

    } else {

      IPrimaryEditPart primaryEditPart = getPrimaryEditPart(editPart);

      if (primaryEditPart != null && primaryEditPart instanceof GraphicalEditPart) {
        IFigure parentFig = ((GraphicalEditPart) primaryEditPart).getFigure();

        // only support figures with handle bounds
        Locator locator = new MultiIconTopRightLocator(parentFig, margin);

        // Direction NORTH_EAST will be ignored, since we impose
        // "our" locator below
        decoration =
            decoratorTarget.addShapeDecoration(
                image, IDecoratorTarget.Direction.NORTH_EAST, margin, isVolatile);
        if (decoration instanceof Decoration) {
          ((Decoration) decoration).setLocator(locator);
        }
      }
    }
    return decoration;
  }