Class Images
java.lang.Object
com.dassault_systemes.modeler.sysml.model.Images
Utility class to work with Image elements
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringEncoding identifier for Base64‑encoded image content.static final StringEncoding identifier for raw (identity) image content.static final StringMIME type for GIF images.static final StringMIME type for JPEG images.static final StringMIME type for PNG images.static final StringCanonical MIME type for SVG images.static final StringMIME type for SVG images expressed as XML. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResizableIconcreateIcon(String encoding, String content, String type, String location) Creates a Swing icon from the given encoded image data.static AttributeDefinitioncreateImage(ModelElementProject project, String type, String encoding, String content) Creates a new image attribute definition under the given project and initializes its metadata fields.static StringgetContentAsBase64(byte[] content) Encodes raw bytes into a Base64 string.static ResizableIconReturns a Swing icon for the given image element, if possible.static booleanChecks whether the given element represents an image using the default image metadata library.static voidsetImageAttributes(Type image, String type, String encoding, String content) Sets the metadata attributes (type, encoding, content) on the given image element.
-
Field Details
-
ENCODING_BASE64
Encoding identifier for Base64‑encoded image content.- See Also:
-
ENCODING_IDENTITY
Encoding identifier for raw (identity) image content.- See Also:
-
TYPE_IMAGE_PNG
MIME type for PNG images.- See Also:
-
TYPE_IMAGE_JPEG
MIME type for JPEG images.- See Also:
-
TYPE_IMAGE_GIF
MIME type for GIF images.- See Also:
-
TYPE_IMAGE_SVG_XML
MIME type for SVG images expressed as XML.- See Also:
-
TYPE_IMAGE_SVG
Canonical MIME type for SVG images.- See Also:
-
-
Constructor Details
-
Images
public Images()
-
-
Method Details
-
createImage
public static AttributeDefinition createImage(ModelElementProject project, String type, String encoding, String content) Creates a new image attribute definition under the given project and initializes its metadata fields.- Parameters:
project- the project in which the image is createdtype- MIME type of the imageencoding- encoding of the image content (base64 or identity)content- encoded image content- Returns:
- the created image attribute definition
-
setImageAttributes
Sets the metadata attributes (type, encoding, content) on the given image element.- Parameters:
image- the image elementtype- MIME typeencoding- encoding formatcontent- encoded content
-
isImage
Checks whether the given element represents an image using the default image metadata library.- Parameters:
element- the element to check- Returns:
- true if the element is an image
-
getIcon
Returns a Swing icon for the given image element, if possible.- Parameters:
element- the image element- Returns:
- a resizable icon, or null if the image cannot be decoded
-
createIcon
@CheckForNull public static ResizableIcon createIcon(@CheckForNull String encoding, @CheckForNull String content, @CheckForNull String type, @CheckForNull String location) Creates a Swing icon from the given encoded image data.- Parameters:
encoding- encoding format (base64 or identity)content- encoded contenttype- MIME typelocation- optional location hint- Returns:
- a resizable icon, or null if decoding fails
-
getContentAsBase64
Encodes raw bytes into a Base64 string.- Parameters:
content- raw bytes- Returns:
- Base64-encoded string
-