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?
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/1e16941c-53d3-4caf-811e-10ce78d259c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.