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
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Rotate Labelfield

It is possible to paint a Label onto a Bitmap, then rotate the bitmap too. 

 

The easiest way to paint some text onto a Bitmap is to create the Bitmap, then grab the Graphics context for that Bitmap, and just use the standard

<graphics>.drawtext(...)

methods to create the Bitmap.  Then you can rotate the Bitmap. 

 

The critical parts are:

a)  Create a Bitmap using new Bitmap(..).  You will need to figure out what size to make it

b) Get the Graphics context using Graphics.create(..)

c) drawtext - you will need to be careful about positioning

d) Rotate.  You could use this:

http://supportforums.blackberry.com/t5/Java-Development/Rotate-and-scale-bitmaps/ta-p/492524

but it is probably simpler to just create a new Bitmap and use getARGB and setARGB to move the pixels.

 

Then you put the Bitmap in a BitmapField and it will look like a rotated label. 

 

And just to confirm, you can not rotate any Field in the BlackBerry UI. 

 

What you might have been able to do with the links I got you to search for, was create your own LabelField that wrote with rotated text.  This is certainly possible and possibly a little more convenient than what I have suggested above.  But it appears you are struggling to get the idea of this.  There is a lot to learn to do this, for example, you will need to be able to create your own custom Field.  So I think the above is the best option for you.

 

Good luck. 

 

 

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Rotate Labeled

[ Edited ]

Extend LabelField.
Override its paint() method.
Use http://supportforums.blackberry.com/t5/Java-Development/Rotate-Font/m-p/22529#M897 (peter already suggested) to rotate the text.
Override layout(int,int) (because you need different amount of hor/vert space than the original LabelField)
Override getPreferredWidth/Height to help container managers



"Listen carefully, I shall say this only once"