Use com.nomagic.magicdraw.icons.IconsFactory to load the icons.
As of version 18.2, modeling tools support HiDPI/Retina monitors and chooses dynamically which icon to load - a lower or higher resolution. All this logic is encapsulated in com.nomagic.ui.ScalableImageIcon. IconsFactory adds additional caching and ensures that icon from the same URL will be loaded just once.
The HiDPI/Retina compatibility requires two images - for a normal resolution and for a high resolution. Use the SVG format for a high resolution image. Put both icons with the same name (but a different extension) at the same location. Use a normal icon URL to load the icon, but the SVG icon will be loaded on the high resolution monitor.
Icon classes
Class | Description |
---|---|
com.nomagic.ui.ResizableIcon | The extended version of javax.swing.Icon. It can be scaled (resized) during the painting. |
com.nomagic.ui.ResizableIconAdapter | An adapter of a simple javax.swing.Icon to a com.nomagic.ui.ResizableIcon. |
com.nomagic.ui.SquareIcon | An icon which fits another icon into a square of a given size. |
com.nomagic.ui.ScalableImageIcon | The HiDPI (Retina) friendly javax.swing.ImageIcon implementation. This class dynamically chooses a right image by the current screen dpi and/or the scaling factor defined in the system (Retina and etc). If scaling is needed and the SVG icon with the same name is available at the given location, the SVG icon will be used instead of a bitmap icon. Dynamic choosing will work only if two icons are provided at the same location. For example, /com/product/icons/a.png and /com/product/icons/a.svg. ScalableImageIcon(Product.class, "/com/product/icons/a.png") will load a.png on a regular dpi monitor, but a.svg will be loaded on the HiDPI monitor. Keep in mind that the SVG icon size can be any. The SVG icon will be resized according to the size of the a.png icon and a scaling factor. For example, if a size of a.png is 16x16 and a scaling factor is 2, the loaded SVG icon will be resized to 32x32 if needed. The original icon will be loaded and scaled if the SVG icon is not provided, but HiDPI with scaling is used. |
Utility classes
Class | Description |
---|---|
com.nomagic.magicdraw.icons.IconsFactory | A utility class to load icons from the MagicDraw icons package or other locations. |
com.nomagic.ui.IconUtilities | A utility class to work with Icons. |
Advanced icons classes
Class | Description |
---|---|
com.nomagic.ui.AlphaCompositeIcon | Paints a wrapped icon with an alpha composite. |
com.nomagic.ui.BorderIcon | An icon for adding a border around a wrapped icon. |
com.nomagic.ui.DoubleIcon | An Icon for painting two wrapped icons on a top of each other. |
com.nomagic.ui.RetinaImageIcon | A retina friendly image icon implementation. The icon (and the image returned by this icon) is twice smaller then the wrapped icon itself. A wrapped icon is used for painting. On painting, Graphics is scaled down by a retina scale factor and the wrapped icon is painted. |
com.nomagic.ui.DoubleSizeImageIcon | An icon combines two other icons and chooses which one to paint depending on the graphics scaling. |
com.nomagic.ui.ResizableIconImageIcon | An image icon which wraps other icon and provides an image for a wrapped icon. The provided image is HiDPI/Retina friendly. On Mac, a special instance of java.awt.Image (sun.awt.image.MultiResolutionToolkitImage) is returned which supports multi-resolution. |