Skip to content

How to create iconsets and imagesets for TG applications

homedirectory edited this page Dec 16, 2022 · 3 revisions

Often during the development of new application functionality some specific icons are required.

The following steps explain how to use newly created icons:

  1. All required icons should be optimized (https://jakearchibald.github.io/svgomg/ + add id="iconname") and put into one folder. It is better to change every icon id to some meaningful name by opening an icon in a text editor and correcting the id which is at the beginning.
  2. Copy this folder to src/main/resources (*-web-ui project).
  3. Now we should combine all icons into one iconset. To do that we can use IronIconsetUtility.

This is an example how to do that:

public class MenuIconsetCreator {
    public static void main(final String[] args) throws IOException {
        final String srcFolder= "src/main/resources/folder_with_icons_name";
        final String iconsetId = "iconset-id";
        final int svgWidth = 1000;
        final String outputFile = "src/main/resources/iconset-file-name.js";
        final IronIconsetUtility iconsetUtility = new IronIconsetUtility(iconsetId, svgWidth, srcFolder);
        iconsetUtility.createSvgIconset(outputFile);
    }
} 

This will create a .js iconset file in src/main/resources.

  1. Now this file should be imported by application-startup-resources.js
/* menu icons */
import '/resources/tgpsa-main-menu.js';

And now icons are ready to be used in this way: "iconset-id:iconId"

Clone this wiki locally