Package com.nomagic.magicdraw.icons
Class IconsFactory
java.lang.Object
com.nomagic.magicdraw.icons.IconsFactory
Utility class to load icons from MagicDraw icons package or other locations.
All loaded icons are cached, so second attempt to load same icon will take it from a cache.
Icons are loader using
Class.getResource(String)
, so icon name should follow that notation.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ResizableIcon
Load icon from a given resourcestatic ResizableIcon
Load icon from a given resource.static ResizableIcon
Load icon from a given resourcestatic ResizableIcon
Load icon from a given resource.static ResizableIcon
Load icon from given bytes.static ResizableIcon
Load icon from given bytes.static ResizableIcon
Load icon from a given url.static ResizableIcon
Load icon from a given url.static byte[]
getIconData
(File file) Reads icon data from a given file.static byte[]
getIconData
(InputStream input) Reads icon data from a given stream.static byte[]
getIconData
(URL url) Reads icon data from a given url.static ResizableIcon
getNotScaledIcon
(Class clazz, String name) Load icon from a given resource.static ResizableIcon
getNotScaledIcon
(String name) Load icon from a given resource.static ResizableIcon
getNotScaledIcon
(URI uri, byte[] data) Load icon from given bytes.static ResizableIcon
getNotScaledIcon
(URI uri, byte[] data, int size) Load icon from given bytes.static ResizableIcon
getNotScaledIcon
(URL url) Load icon from a given url.static ResizableIcon
getNotScaledIcon
(URL url, int size) Load icon from a given url.static String
getQualifiedResourceName
(String resourceName) Resolves given resource name to a qualified name in this package.static URL
getResource
(String name) Provide URL to a resource in this packagestatic InputStream
getResourceAsStream
(String name) Provide stream to a resource in this packagestatic ResizableIcon
getSvgIcon
(URL url) Load SVG icon from a given url.
-
Constructor Details
-
IconsFactory
public IconsFactory()
-
-
Method Details
-
getIcon
Load icon from a given resource- Parameters:
name
- icon name- Returns:
- icon
- See Also:
-
getIcon
Load icon from a given resource- Parameters:
clazz
- icon resource classname
- icon name- Returns:
- icon
- See Also:
-
getNotScaledIcon
Load icon from a given resource. Does not scale icon by screen dpi.- Parameters:
name
- icon name- Returns:
- icon
- See Also:
-
getNotScaledIcon
Load icon from a given resource. Does not scale icon by screen dpi.- Parameters:
clazz
- icon resource classname
- icon name- Returns:
- icon
- See Also:
-
getIcon
Load icon from a given resource.- Parameters:
name
- icon namesilent
- true if missing icon should not be reported to a log file- Returns:
- icon
- See Also:
-
getIcon
Load icon from a given resource.- Parameters:
clazz
- icon resource classname
- icon namesilent
- true if missing icon should not be reported to a log file- Returns:
- icon
- See Also:
-
getResourceAsStream
Provide stream to a resource in this package- Parameters:
name
- resource name- Returns:
- icon
- See Also:
-
getResource
Provide URL to a resource in this package- Parameters:
name
- resource name- Returns:
- icon
- See Also:
-
getQualifiedResourceName
Resolves given resource name to a qualified name in this package. If resource name is already qualified (starts with "/"), returns it.- Parameters:
resourceName
- resource name- Returns:
- qualified resource name in this package
-
getIcon
Load icon from a given url.- Parameters:
url
- url- Returns:
- icon
-
getIcon
Load icon from a given url. Scales icon to a box of given size.- Parameters:
url
- urlsize
- icon box size. -1 if scaling is not needed- Returns:
- icon
-
getNotScaledIcon
Load icon from a given url. Does not scale icon by screen dpi.- Parameters:
url
- url- Returns:
- icon
-
getNotScaledIcon
Load icon from a given url. Scales icon to a box of given size. Does not scale icon by screen dpi.- Parameters:
url
- urlsize
- icon box size. -1 if scaling is not needed- Returns:
- icon
-
getIcon
Load icon from given bytes.- Parameters:
uri
- uri describing the location (or format) of the icondata
- an array of icon data bytes- Returns:
- icon
-
getIcon
Load icon from given bytes. Scales icon to a box of given size. Does not scale icon by screen dpi.- Parameters:
uri
- uridata
- an array of icon datasize
- icon box size. Icon will be scaled to this box. -1 if scaling is not needed- Returns:
- icon
- See Also:
-
getNotScaledIcon
Load icon from given bytes. Scales icon to a box of given size. Does not scale icon by screen dpi.- Parameters:
uri
- icon uridata
- an array of icon data- Returns:
- icon
-
getNotScaledIcon
Load icon from given bytes. Scales icon to a box of given size. Does not scale icon by screen dpi.- Parameters:
uri
- icon uridata
- an array of icon datasize
- icon box size. Icon will be scaled to this box. -1 if scaling is not needed- Returns:
- icon
-
getIconData
Reads icon data from a given file.- Parameters:
file
- an icon file- Returns:
- icon data from given file
-
getIconData
Reads icon data from a given url.- Parameters:
url
- icon url- Returns:
- icon data from given url
-
getIconData
Reads icon data from a given stream.- Parameters:
input
- input stream- Returns:
- icon data
-
getSvgIcon
Load SVG icon from a given url. Other getIcon(...) methods in this class also can read SVG icons, but this one does not return icon compatible withImageIcon
.- Parameters:
url
- icon url- Returns:
- icon
-