Package com.nomagic.uml2.ext.jmi.helpers
Class ElementImageHelper
- java.lang.Object
-
- com.nomagic.uml2.ext.jmi.helpers.ElementImageHelper
-
@OpenApiAll public class ElementImageHelper extends java.lang.Object
Utility class to work with 'Image' property, which is contained by all elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ElementImageHelper.ImageInformation
Structure, which contains information of image: content, format and location.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Object,ResizableIcon>
mCache
Stores ImageInformation as key and ResizableIcon as value.
-
Constructor Summary
Constructors Constructor Description ElementImageHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.Object
constructCacheKey(Element element)
Construct icon cache key for a given element.private static java.lang.Object
constructCacheKey(java.lang.String imageContent, java.lang.String location)
Construct icon cache key for a given image content.static ElementImageHelper.ImageInformation
getCustomImageInformation(Element element)
Gets image information by element if image is set.static ElementImageHelper.ImageInformation
getCustomImageInformation(Element element, Stereotype stereotype)
Gets image information by element if image is set.private static java.lang.String
getCustomImageSlotValue(Element element, java.lang.String propertyName, Stereotype stereotype)
Gets slot of image property by element and property name and takes its value.private static TaggedValue
getCustomImageTaggedValue(Element element, java.lang.String propertyName)
Gets slot of image property by element and property name.private static TaggedValue
getCustomImageTaggedValue(Element element, java.lang.String propertyName, Stereotype stereotype)
Gets slot of image property by element and property name.static Element
getElementToSetImage(ModelElementProvider pElement)
Returns element to set image propertystatic ResizableIcon
getIconFromCustomImageProperty(ElementImageHelper.ImageInformation imageInformation)
A helper method to create resizable icon from image information.static ResizableIcon
getIconFromCustomImageProperty(Element element)
Gets 'ResizableIcon', which is created from the image information.static Stereotype
getImageHolderStereotype(Project project)
Return image holder stereotype from a given project.static ElementImageHelper.ImageInformation
getProvidedElementImageInformation(ModelElementProvider pElement)
Returns image information of provided elementstatic void
setCustomImageInformation(Element element, 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.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.private static void
setOrClearValue(TaggedValue taggedValue, java.lang.String value)
-
-
-
Field Detail
-
mCache
private static final java.util.Map<java.lang.Object,ResizableIcon> mCache
Stores ImageInformation as key and ResizableIcon as value. This is used to get already created icon.
-
-
Method Detail
-
getCustomImageTaggedValue
@CheckForNull private static TaggedValue getCustomImageTaggedValue(Element element, java.lang.String propertyName)
Gets slot of image property by element and property name.- Parameters:
element
- element, which contains image property.propertyName
- name of property.- Returns:
- gets slot of image.
-
getCustomImageTaggedValue
@CheckForNull private static TaggedValue getCustomImageTaggedValue(Element element, java.lang.String propertyName, Stereotype stereotype)
Gets slot of image property by element and property name.- Parameters:
element
- element, which contains image property.propertyName
- name of property.- Returns:
- gets slot of image.
-
getCustomImageSlotValue
@CheckForNull private static java.lang.String getCustomImageSlotValue(Element element, java.lang.String propertyName, Stereotype stereotype)
Gets slot of image property by element and property name and takes its value.- Parameters:
element
- element, which contains image property.propertyName
- name of property.- Returns:
- gets slot of image.
-
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.
-
getCustomImageInformation
@CheckForNull public static ElementImageHelper.ImageInformation getCustomImageInformation(Element element, Stereotype stereotype)
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.
-
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.
-
setOrClearValue
private static void setOrClearValue(TaggedValue taggedValue, @CheckForNull java.lang.String value)
-
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
-
constructCacheKey
@CheckForNull private static java.lang.Object constructCacheKey(Element element)
Construct icon cache key for a given element.- Parameters:
element
- element- Returns:
- cache key or null if Element has no Image
-
constructCacheKey
@CheckForNull private static java.lang.Object constructCacheKey(@CheckForNull java.lang.String imageContent, @CheckForNull java.lang.String location)
Construct icon cache key for a given image content.- Parameters:
imageContent
- image content- Returns:
- cache key or null if content is null
-
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
-
-