Skip to main content

Animation does not work in the current build

7 replies [Last post]
mrjansa
Offline
Joined: 2008-10-08
Points: 0

If I use the jar built 22 dec, animation works perfectly.
But if I use the current build it does not work. What has changed that could cause this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mrjansa
Offline
Joined: 2008-10-08
Points: 0

Ok here is an example.
With the december release the image is rotating as expected. But with the current build in svn the image is not rotating.

--startapp--
[code]
Form f = new Form();
f.addComponent(new InfiniteProgressIndicator());
f.show();
[/code]

--InfiniteProgressIndicator--
[code]
public class InfiniteProgressIndicator extends Label {
private int angle;
private Image[] angles;
private long lastInvoke;

public InfiniteProgressIndicator() throws IOException {
Image a = Image.createImage("/img/wait-circle.png");
Image b = a.rotate(30);
Image c = a.rotate(90);

angles = new Image[]{
a,
b,
c,
a.rotate(90),
b.rotate(90),
c.rotate(90),
a.rotate(180),
b.rotate(180),
c.rotate(180),
a.rotate(270),
b.rotate(270),
c.rotate(270),
};

getStyle().setBgTransparency(0);
setIcon(a);
setAlignment(Component.CENTER);
}

public void initComponent() {
getComponentForm().registerAnimated(this);
}

public boolean animate() {
long current = System.currentTimeMillis();
if (current - lastInvoke > 50) {
lastInvoke = current;
angle++;
setIcon(angles[Math.abs(angle % angles.length)]);
return true;
}
return false;
}
}
[/code]

Chen Fishbein

Hi,
Your Custom Component doesn't give a preferred size to its layout,
override calcPreferredSize or call to setPreferredSize.

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Ok here is an example.
> With the december release the image is rotating as expected. But with the current build in svn the image is not rotating.
>
> --startapp--
> [code]
> Form f = new Form();
> f.addComponent(new InfiniteProgressIndicator());
> f.show();
> [/code]
>
> --InfiniteProgressIndicator--
> [code]
> public class InfiniteProgressIndicator extends Label {
> private int angle;
> private Image[] angles;
> private long lastInvoke;
>
> public InfiniteProgressIndicator() throws IOException {
> Image a = Image.createImage("/img/wait-circle.png");
> Image b = a.rotate(30);
> Image c = a.rotate(90);
>
> angles = new Image[]{
> a,
> b,
> c,
> a.rotate(90),
> b.rotate(90),
> c.rotate(90),
> a.rotate(180),
> b.rotate(180),
> c.rotate(180),
> a.rotate(270),
> b.rotate(270),
> c.rotate(270),
> };
>
> getStyle().setBgTransparency(0);
> setIcon(a);
> setAlignment(Component.CENTER);
> }
>
> public void initComponent() {
> getComponentForm().registerAnimated(this);
> }
>
> public boolean animate() {
> long current = System.currentTimeMillis();
> if (current - lastInvoke > 50) {
> lastInvoke = current;
> angle++;
> setIcon(angles[Math.abs(angle % angles.length)]);
> return true;
> }
> return false;
> }
> }
> [/code]
> [Message sent by forum member 'mrjansa' (mrjansa)]
>
> http://forums.java.net/jive/thread.jspa?messageID=331693
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

mrjansa
Offline
Joined: 2008-10-08
Points: 0

Thanks, but it didn't help. The image is still not animating with the current build. Any other suggestons?

chenf
Offline
Joined: 2008-04-29
Points: 0

Hi,
That's work fine for me, add the bold line to your code.

Chen

public InfiniteProgressIndicator() throws IOException {
...
getStyle().setBgTransparency(0);
setIcon(a);
setAlignment(Component.CENTER);
[b]setPreferredSize(new Dimension(c.getWidth(), c.getHeight()));[/b]
}

mrjansa
Offline
Joined: 2008-10-08
Points: 0

I added the bold line but the image is still not moving with current version(rev. 387).

Any other suggestions?

mrjansa
Offline
Joined: 2008-10-08
Points: 0

Problem solved.

I removed this from the animation component:
[code]public void initComponent() {
getComponentForm().registerAnimated(this);
}[/code]
.. and added this to the form:
[code]f.registerAnimated(i);[/code]

And now it works.
So, something has been changed in the lwuit code since the last drop.

Message was edited by: mrjansa

Chen Fishbein

Hi,
What's not working?, post a sample code.

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> If I use the jar built 22 dec, animation works perfectly.
> But if I use the current build it does not work. What has changed that could cause this?
> [Message sent by forum member 'mrjansa' (mrjansa)]
>
> http://forums.java.net/jive/thread.jspa?messageID=331387
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net