Skip to main content

Re: LWUIT code size

6 replies [Last post]
Anonymous

Hi Qunhuan,
JSR 75 and 184 (PIM and 3D) aren't used by LWUITs core. If your
application doesn't make use of these features they don't need to be
in the obfuscated jar or in the device.

Since the LWUIT demo makes use of 3D in the 3D transitions this code
is packaged in, but if you don't use it the obfuscator removes the
unused classes implicitly.

I would still like to reduce the JAR size further and this is
something I'm working on, the strategy being to reduce class coupling
and shrink down the size of the hello world MIDlet. This is on my
todo list among way too many things that should be done ;-)

If you suspect the size of your MIDlet is too big try following the
instructions in the proguard manual to track down size: http://
proguard.sourceforge.net/
Generate an obfuscation log and see what gets kept, you can use
options such as "-whyareyoukeeping className" to understand what
gets included. If there is something kept that seems like it
shouldn't be there just let us know.

As a side note it is possible that the current drop build of LWUIT is
a debug build that contains some references to the Log class which
makes use of JSR 75 in some situations. This shouldn't be the case in
the next drop (hopefully).

Thanks,
Shai.

> Hi there,
>
> Good to know that the LWUIT’s code size, after compression, is now
> 123k!
>
> I have noticed to make LWUIT based J2ME app work, the minimum API
> support, apart from MIDP 2.0 and CLDC 1.1, is File and PIM API, and
> Mobile 3D API. I was just wondering if there is still further
> potential to make the code size smaller, since these 2 APIs are
> usually not used in the app, or maybe the obfuscator has already
> figured this out and no code from these two APIs are actually
> included in the final app so 123k is final.
>
> Any thoughts?
>
> Many thanks,
>
> Qunhuan
>

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Matteo Mazzotti

Hi again,
I hope this time will be easier ;)

Is horizontal scrolling with touch screen supported in List ?
I tried the demo with Spring WTK, the scroll demo works properly even with
the accelerated motion.
In my application, I have a horizontal button bar -my touch menu-
(implemented with a List of Buttons. What do you think about this approach
btw?)
I can't get it to scroll with the touch (it does scroll with the arrow
keys).

Thanks!
matteo

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

vprise
Offline
Joined: 2003-11-07
Points: 0

Hi Matteo,
We support navigating the horizontal list with a touch screen by just clicking elements. We generally use the horizontal list with a fixed element position to create the effect of a carousel so it horizontal gesture scrolling wasn't necessary for our use cases.
We debated the issue of horizontal gesture scrolling and we just couldn't think of a use case where this will be convenient (its not a natural physical motion). Do you use a list which is not "fixed" horizontally?
If this is a required use case we can look over the code, its currently very biased to the Y_AXIS but I can see the horizontal list as a special case here...

Thanks,
Shai.

Matteo Mazzotti

I use List.FIXED_NONE for my horizontal list. Is that you mean by 'list with
a fixed element position' ? If so, I tried clicking on the list items on the
WTK HTC Touch but nothing happens. I can only see the first 3 items.
As for the use case, well I think we're seeing more and more UI where the
user is asked to scroll a list horizontally as if they were leafing through
a book. I think this is a concept pretty familiar especially to the Mac
guys...

Anyhow, I hate kidnapping my own thread, but as I was experimenting with the
aforementioned list, I think I found something new (please, don't say you're
starting to hate me now ).

I thought it is perfectly legal to create a List of Button items, and so I
did.

Button[] menuButtons = new Button[MENU_BUTTONS.length];
for (int iter = 0; iter < MENU_BUTTONS.length; iter++) {
menuButtons[iter] = new Button(MENU_BUTTONS[iter]);
menuButtons[iter].addActionListener(new ButtonActionListener());
}
List menu = new List(menuButtons);
menu.setListCellRenderer(new MenuRenderer());

Here is MenuRenderer:
private class MenuRenderer implements ListCellRenderer {

public Component getListCellRendererComponent(List list, Object
value, int index, boolean isSelected) {
button = (Button) value;
button.setBorderPainted(false);
button.setText(MENU_BUTTONS[index][1]);
button.setTextPosition(Component.TOP);
button.setAlignment(Component.CENTER);
button.addActionListener(new ButtonActionListener());
if (isSelected) {
//some style changes here
} else {
//some other style changes here
}
}
return button;
}

public Component getListFocusComponent(List arg0) {
return null;
}
}

The ButtonActionListener is trivial (it prints a message to System.out )

The problem is that when I "click" (with the central rounded soft button)
nothing happens, and actionPerformed is not called.
I don't see what could be wrong... I create the Button objects once, before
insterting them into the list. Then "Object value" in
getListCellRendererComponent should just be passed a reference to those same
Button objects. If I'm right, so why actionPerformed is not triggered?

Luckily it's Friday (so it's likely you won't hear from me for a while !!)

Thanks again
matteo

> Hi Matteo,
> We support navigating the horizontal list with a touch screen
> by just clicking elements. We generally use the horizontal
> list with a fixed element position to create the effect of a
> carousel so it horizontal gesture scrolling wasn't necessary
> for our use cases.
> We debated the issue of horizontal gesture scrolling and we
> just couldn't think of a use case where this will be
> convenient (its not a natural physical motion). Do you use a
> list which is not "fixed" horizontally?
> If this is a required use case we can look over the code, its
> currently very biased to the Y_AXIS but I can see the
> horizontal list as a special case here...
>
> Thanks,
> Shai.
> [Message sent by forum member 'vprise' (vprise)]
>
> http://forums.java.net/jive/thread.jspa?messageID=278859

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

Shai Almog

> I use List.FIXED_NONE for my horizontal list. Is that you mean by
> 'list with
> a fixed element position' ? If so, I tried clicking on the list
> items on the
> WTK HTC Touch but nothing happens. I can only see the first 3 items.
> As for the use case, well I think we're seeing more and more UI
> where the
> user is asked to scroll a list horizontally as if they were leafing
> through
> a book. I think this is a concept pretty familiar especially to the
> Mac
> guys...

I meant fixed center, left or right...
I use a Mac daily and the only horizontal list I can think of (still
haven't upgraded to Leopard) is the cover flow view which isn't
exactly a list.
Generally I think a horizontal list is great but I don't know of any
UI that uses horizontal gesture scrolling?
In the iPhone the horizontal motion is used to unlock the device, but
I can't think of a place (other than cover flow) where you scroll a
list on the side.

The cover flow case is interesting since its really browsing not
scrolling (the content view changes during transition).

I'll talk it over with Chen, he might also have some input that can
help.
If this is an important feature for you I think it should be doable.

> Anyhow, I hate kidnapping my own thread, but as I was experimenting
> with the
> aforementioned list, I think I found something new (please, don't
> say you're
> starting to hate me now ).

Users finding issues and helping us improve the end result are the
best kind of users, the worst kind are those who don't complain and
just sulk ;-)

> I thought it is perfectly legal to create a List of Button items,
> and so I
> did.

Sorry I completely forgot about the button list question...
Its technically OK to use buttons for list elements but its not very
helpful since a list is very elaborate and it would be somewhat wasted.

We try to explain this in the guide/docs and tutorial but the
renderer concept is one of the hardest concepts to grab in Swing and
in LWUIT.

The component returned by the list renderer is discarded, always...
Its essentially used purely as a "rubber stamp" only for what it can
do to graphics.
No events will be delivered to this component since as far as the
list is concerned it no longer exists at this point...

So you might as well use a label (such as DefaultListCellRenderer).

Use the list events (selection and action) to detect user
interaction, if you want more you can derive list and listen to
keyPress/Release & pointer/Drag/Press/Release.

> Luckily it's Friday (so it's likely you won't hear from me for a
> while !!)

Actually Sunday and Monday are holidays around here too but I
personally work 24x7 ;-)
Or at least I try...

Thanks,
Shai.

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

Matteo Mazzotti

> In the iPhone the horizontal motion is used to unlock the
> device, but I can't think of a place (other than cover flow)
> where you scroll a list on the side.

Here's an example of a list scrolled horizontally I can think of: those
fancy javascript/ajax photo galleries where you have the thumbnails placed
in a horizontal list, and the big full size picture on top of them. Some
implementation in Flash are acceleration based.

> If this is an important feature for you I think it should be doable.
Well not so important, but it would be cool (if I'm not the only one asking
for it, obviously!)

> So you might as well use a label (such as DefaultListCellRenderer).
>
> Use the list events (selection and action) to detect user
> interaction, if you want more you can derive list and listen
> to keyPress/Release & pointer/Drag/Press/Release.

Ok thanks, I'll give it a try tomorrow.

> Actually Sunday and Monday are holidays around here too but I
> personally work 24x7 ;-) Or at least I try...

Eheheh same for me !
Thanks,
Have a good weekend

Matteo

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

Shai Almog

> Here's an example of a list scrolled horizontally I can think of:
> those
> fancy javascript/ajax photo galleries where you have the thumbnails
> placed
> in a horizontal list, and the big full size picture on top of them.
> Some
> implementation in Flash are acceleration based.

Thats a good example, I'll discuss it with Chen next week.

>> If this is an important feature for you I think it should be doable.
> Well not so important, but it would be cool (if I'm not the only
> one asking
> for it, obviously!)

We will see how it fits with the code, for simplicities sake gestures
on only one axis is supported at the time and this is hardcoded for Y.
Otherwise when scroll is enabled on two axis things might be "weird"...

This however might not pose much of a problem since the list is only
scrollable on X making the Y scrolling irrelevant.

Thanks,
Shai.

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