×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2007
    Location
    Cordoba, Argentina
    Posts
    17

    Draw rotated text

    Hi everyone, I am Sergio from Argentina, I and writing a Business Intelligence module in J2ME, that I call BI Mobile, I am planning to do alerts list, pie chart, lines and bars charts horizontal and vertical.
    I have finished Pie Chart it works fine, alerts list fine too, but while writing line charts I found that I need to draw 90 degrees rotates text for the X axis labels. Does eny one know how to g.drawString rotated?
    Thanks so much for any help you can give me
    Sergio
    Sergio Mabres
    Prominente S.A.
    Argentina

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Draw rotated text

    Hi Sergio,

    What you could do is this:
    -Create a blank image
    -Create an instance of that image's Graphics class (using getGraphics() method) and write the text on it using the drawString(...) method
    -Show that image using the drawRegion(...) method, specifying the rotation parameter as, for example, Sprite.TRANS_ROT90

    Here's the code I used for the canvas. You can adapt it to suit your needs.
    Code:
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.Sprite;
    
    public class MyCanvas extends Canvas {
        
        public void paint(Graphics g) {
            String s="java";
            Image img=Image.createImage(50,50);
            Graphics gr=img.getGraphics();
            gr.drawString(s, 0, 0, Graphics.TOP|Graphics.LEFT);
            g.drawRegion(img, 0, 0, 50, 50, Sprite.TRANS_ROT90, 0, 0, Graphics.TOP|Graphics.LEFT);
        }
        
    }

  3. #3
    Registered User
    Join Date
    May 2007
    Location
    Cordoba, Argentina
    Posts
    17

    Re: Draw rotated text

    Dear Bogdan thanks so much it is just what I needed; I have been programming for enterprise apps. for more than 20 year I never thought I was going to use a Sprite, your idea is great, I wish I could show you the Line Graph final image.
    Thanks so mucho for your help
    Sergio
    Sergio Mabres
    Prominente S.A.
    Argentina

Similar Threads

  1. Draw text on sprites/bitmaps...
    By erst in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-16, 15:05
  2. How to draw text on the bitmap?
    By Joney.Zhang in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2006-09-12, 07:45
  3. Replies: 0
    Last Post: 2004-11-24, 18:49
  4. How to draw a long text into multiline text??
    By titoliu in forum Symbian
    Replies: 1
    Last Post: 2002-08-09, 11:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •