I'm drawing clocks in my app. They are just a circle with two lines, and many of these are drawn as images and added to the hashmap of a list model (as 'icon' ) and applied to a MultiList. There are about 20 items on the list, with icon (a clock) text and emblem.
The clock is made by a class that has a static method that returns a method showing the time passed to it. The image is created by Image.create(width, height). Graphics object is obtained by calling getGraphics on this image, and then used to draw a circle and two lines.
Image clock = Image.createImage(size, size, 0x00000000);
Graphics g = clock.getGraphics();
g.setAntiAliased(true);
g.setAlpha(255);
//draw circle and hands with g.drawShape(GeneralPath,Stroke);
Shape drawn is obtained from GeneralPath.createFromPool() and reset and then recycled between each call. Stroke is set once and used for all subsequent calls.
All of this is done on the EDT I believe, its called from onPostShow but it is wrapped in a Display.getInstance().invokeAndBlock() so I can show and then hide a InfiniteProgress dialog.
Dialog d = new InfiniteProgress().showInifiniteBlocking();
Display.getInstance().invokeAndBlock(() -> {
//Draw clock in here - along with a couple of other method calls, all layout related.
});
d.dispose();
Works great on Android and the simulator. On iOS it works for about half the items on the list, the other half the time there are random errors - sometimes images are missing entirely (remaining content in the list item is shifted left), sometimes the image is totally black, and sometimes the circle is missing but the hands are draw.
Any things I should be aware of about this approach?