Class ElementImageHelper


  • @OpenApiAll
    public class ElementImageHelper
    extends java.lang.Object
    Utility class to work with 'Image' property, which is contained by all elements.
    • Constructor Detail

      • ElementImageHelper

        public ElementImageHelper()
    • Method Detail

      • getCustomImageInformation

        @CheckForNull
        public static ElementImageHelper.ImageInformation getCustomImageInformation​(Element element)
        Gets image information by element if image is set.
        Parameters:
        element - element, which contains image property.
        Returns:
        image information if image to element is set, otherwise null.
      • getCustomImageTaggedValue

        @CheckForNull
        private static TaggedValue getCustomImageTaggedValue​(Element element,
                                                             java.lang.String propertyName,
                                                             Stereotype stereotype)
      • getCustomImageTaggedValueValue

        @CheckForNull
        private static java.lang.String getCustomImageTaggedValueValue​(Element element,
                                                                       java.lang.String propertyName,
                                                                       Stereotype stereotype)
      • setCustomImageInformation

        public static void setCustomImageInformation​(Element element,
                                                     Image image)
        Set image information to given element: stereotype 'CustomImageHolder' is applied on element and image information are saved to the tags of this stereotype.
        Parameters:
        element - element, which contains image property
        image - information source used to set image
      • setCustomImageInformation

        public static void setCustomImageInformation​(Element element,
                                                     @CheckForNull
                                                     ElementImageHelper.ImageInformation imageInformation)
        Set image information to given element: stereotype 'CustomImageHolder' is applied on element and image information are saved to the tags of this stereotype. If image is removed, stereotype is removed too.
        Parameters:
        element - element, which contains image property
        imageInformation - structure, which contains information of image: content, format and location
      • getImageHolderStereotype

        public static Stereotype getImageHolderStereotype​(Project project)
        Return image holder stereotype from a given project.
        Parameters:
        project - project
        Returns:
        image holder stereotype
      • getIconFromCustomImageProperty

        @CheckForNull
        public static ResizableIcon getIconFromCustomImageProperty​(@CheckForNull
                                                                   Element element)
        Gets 'ResizableIcon', which is created from the image information.
        Parameters:
        element - element, which contains image property
        Returns:
        'ResizableIcon' if image is set to element's 'Image' property, otherwise null
      • getIconFromCustomImageProperty

        @CheckForNull
        public static ResizableIcon getIconFromCustomImageProperty​(@CheckForNull
                                                                   ElementImageHelper.ImageInformation imageInformation)
        A helper method to create resizable icon from image information.
        Parameters:
        imageInformation - image info
        Returns:
        icon
      • getElementToSetImage

        @CheckForNull
        public static Element getElementToSetImage​(ModelElementProvider pElement)
        Returns element to set image property
        Parameters:
        pElement - presentation element
        Returns:
        element to which image should be set
      • getProvidedElementImageInformation

        @CheckForNull
        public static ElementImageHelper.ImageInformation getProvidedElementImageInformation​(ModelElementProvider pElement)
        Returns image information of provided element
        Parameters:
        pElement - presentation element
        Returns:
        element to which image should be set