Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
bmenzel
Posts: 5
Registered: ‎01-27-2011
My Device: Not Specified
Accepted Solution

Is there a way to rotate the complete Screen?

Hi,

 

I am very sorry for posting this twice, but I think that the subject of my old post was misleading and I could not change it anymore. Old Thread: (http://supportforums.blackberry.com/t5/Java-Development/Possibility-to-rotate-a-whole-MIDlet-or-its-...

 

Is there a way to rotate the whole Screen?

I am programming a Midlet for the Bold and the Storm 2. My Midlet has the following Dimensions:

Width 360, height 480;

It works fine on the Storm 2, but I want to rotate it on the bold (becaus its screens width is 480, height is 360) so that the user needs to hold the device sideways (Screen on the left, keyboard on the right).

 

To demonstrate what I want, here is a little Graphic:

storm2bold.jpg

 

Any help is appreciated! Even a 'this is not possible' would help

Thanks in advance,

Benny

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

AFAIK, there is no standard way to do this, I believe to so this you will have to create your own Ui Components that work sideways. 

Please use plain text.
New Contributor
bmenzel
Posts: 5
Registered: ‎01-27-2011
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

Thank you for your answer - I hope you aren't right :-p (but after all the research I already did, i'm also starting to believe that there is no simple function - which is stupid, because the OS itself does have such a method for devices which can be used in portrait or landscape mode, like the storm 2)

 

Just to clarify: I do not use any UIComponents; I use the GameCanvas of the J2ME implementation.

 

Any futher Ideas or suggestions from other people?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

I don't know anything about Midlet UI processing.  But if I was painting onto a Bitmap, which is a bit like a Canvas from what I understand, by swapping x & y round you can 'rotate' images.  So it might be easy for you to do it yourself. 

Please use plain text.
New Contributor
bmenzel
Posts: 5
Registered: ‎01-27-2011
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

[ Edited ]

Yes, that was what I tried to avoid, because I need to rotate the text as well and 'drawStrings' cannot be rotated (so easily); I was hoping to get an answer like 'yes just use this method and you're done' - but as it was already such a hassle to program for the blackberry (before posting this) it does not make me wonder that it is not that simple.

 

What I did now is:

- I wrote a method, which replaces the Image.createImage(imgString) to rotate my images if a flag (displayIsRotated) is set

- For the two Versions I have different paint Methods which swap the X and Y Values (could have done this with a flag or extra Method, but two paint Methods are OK for me)

- The Strings: This was the most annoying thing. as g.drawString() is not able to draw the Strings rotated, I implemented a BitmapFont-Class (from http://devlinslab.blogspot.com/2007/11/using-custom-fonts-or-bitmap-fonts-part_07.html) where I fixed a bug and changed it a bit to be able to draw rotated Bitmaps and created some BitmapFonts with the MicroFontMaker-Tool (http://j2me-mwt.sourceforge.net/microfontmaker.html).

 

Benny

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

I have errors using both links in your Post - any chance you can add them again?

 

With respect to drawing text, one option that I didn't describe to you, was the option of painting the text into a Bitmap, then rotating the Bitmap.  This is relatively easy to to do. 

 

To do this, create a Graphics object, based on the Bitmap, drawtext using the graphics object, then you can rotate that Bitmap.. 

 

Might be easier than trying to format your own font. 

Please use plain text.
New Contributor
bmenzel
Posts: 5
Registered: ‎01-27-2011
My Device: Not Specified

Re: Is there a way to rotate the complete Screen?

Hi,

 

Sorry about the links, the Forum made them clickable and added a ')' after the 'html'; I edited and tested them.

 

About painting the text into a mutable Image

I did try this before starting to implement the BitmapFont-Thing, but I need the Background of the Bitmap to be transparent so that I would have needed to copy each pixel from my Background Bitmap onto the Fonts-Image, because alpha transparency is not available in the MIDlet implementation;

It is also better to use BitmapFonts because the Bolds smalles font is bigger than the Storm2s one, so that this would have been another issue to solve;

 

I'm happy now with my implementation, mentioned above. :-)

 

Thank you,

Benny

Please use plain text.