String Display using DraxText

Hi,
I have one problem in displaying text in Canvas using DrawText function.
My couple of strings are larger then 2 to 3 lines. And in DrawText '\n' is not supported.
Is there any way or any function in which i just put my string and it will dispaly in well manner if it is two long.
Means it will atomatically create a new line for the string when ever it finds that string is big enough to come in to emulator display.
Thanks in advance

Here is the sample code for text drawing on a Canvas, It will be great if you guys can share your code.
String formattedStrings[] = wrapString(txt, font, width);
if (formattedStrings != null) {
     g.setFont(font);
     for (int i = 0; i < formattedStrings.length; i++) {
          g.drawString(formattedStrings, cursorX, cursorY + height, Graphics.TOP     | Graphics.LEFT);
          height += font.getHeight();
     * Format a given text acording to the font and width of the screen
     * @param txt
     * @param font
     * @param width
     * @return the formatted sets of string
     public String[] wrapString(String txt, Font font, int width) {
          String formattedStrings[] = null;
          if (txt != null && txt.length() > 0) {
               Vector strings = new Vector(2);
               int start = 0;
               int pos = 0;
               while ((pos = nextWrapPosition(txt, font, width, pos)) != -1) {
                    // the next() method returns -1 when the text is finished
                    strings.addElement(txt.substring(start, pos));
                    start = pos; // set to start of next line
               formattedStrings = new String[strings.size()];
               for (int i = 0; i < strings.size(); i++) {
                    formattedStrings[i] = (String) strings.elementAt(i);
          return formattedStrings;
     * Get the next wrapping position to substring the text
     * @param txt
     * @param font
     * @param width
     * @param pos
     * @return the position of the next substring
     private int nextWrapPosition(String txt, Font font, int width, int pos) {
          int i = pos;
          int len = txt.length();
          if (pos >= len)
               return -1;
          int start = pos;
          while (true) {
               while (i < len && txt.charAt(i) > ' ')
                    i++;
               int w = font.stringWidth(txt.substring(start, i));
               if (pos == start) {
                    if (w > width) {
                         while (font.stringWidth(txt.substring(start, --i)) > width) {
                         pos = i;
                         break;
               if (w <= width)
                    pos = i;
               if (w > width || i >= len || txt.charAt(i) == '\n')
                    break;
               i++;
          return pos >= len ? pos : ++pos;

Similar Messages

  • How to read from a xml file(in String format) using a java program

    hi friends
    i have a string , which is xml format. i want read the values and display it.can any one suggest how to read a xml file of string format using a javaprogram
    thanks

            final DocumentBuilder db =  DocumentBuilderFactory.newInstance().newDocumentBuilder();      
            final InputStream documentStream = new ByteArrayInputStream(documentXMLSourceString.getBytes("utf-8"));
            final Document document = db.parse(documentStream);

  • Table Sorter for String displaying Numbers

    Hi All.
    I have a table whose one of the columns display numbers with data type string. This is becuase :
    1. RFC gives me as String.
    2. I have to display blank in case no value or zero is present (since int, long etc default to Zero, hence  
        not used).
    I have to sort this column as a number.Since the datatype is string, it sorts the numbers as string
    for example : if we have  values like : 2, 4, 3, 10, 19, 15, 20, 22
    currently as String it sorts as follows : 10, 15, 19, 2, 20, 22, 3, 4.
    but i want as follows : 2, 3, 4, 10, 15, 19, 20, 22.
    Useful answers will appreciated.
    Thanks and regards,
    Aditya Deshpande.

    In order to sort the node with attribute of type string; please use the following code..
    Here use the node where you store the string value..
    wdContext.nodeTest().sortElements(
                new Comparator() {
                   public int compare(Object o1, Object o2) {
                        // TODO Auto-generated method stub
                   IPrivateExperimentView.ITestElement ele1 = (IPrivateExperimentView.ITestElement)o1;
                   IPrivateExperimentView.ITestElement ele2 = (IPrivateExperimentView.ITestElement)o2;
                        return Integer.parseInt( ele1.getNumStr()) > Integer.parseInt( ele2.getNumStr()) ? 1 : -1;
    input :  "2", "4", "3", "10", "19", "15", "20", "22"
    result : "2", "3", "4", "10", "15", "19", "20", "22"
    vinod

  • Can I connect multiple displays using a mac mini

    Can I connect 2 displays using the mac mini? If so, are there any accessories that I need? Are there certain monitors or connections that I should use?

    Hello,
    Assuming this is a 2012 Mini...
    2nd Display Support:
    Dual/Mirroring*
    2nd Max. Resolution:
    2560x1600*
    Details:
    *This model simultaneously supports 1920x1200 on an HDMI or a DVI display (using the included HDMI-to-DVI adapter) and 2560x1600 on a Thunderbolt or Mini DisplayPort display or even a VGA display (with an optional Mini DisplayPort-to-VGA adapter, which is compatible with the Thunderbolt port).
    http://www.everymac.com/systems/apple/mac_mini/specs/mac-mini-core-i7-2.6-late-2 012-specs.html
    If you need more...
    http://eshop.macsales.com/item/NewerTech/VIDU3HDMIDV/
    http://eshop.macsales.com/item/NewerTech/VIDU2DVIA/

  • The display used to flicker, now it's completely white! PLease HELP!

    So, my display used to flicker with horizontal lines all over it, and slightly adjusting the angle of opening would fix this, but about a week ago it lightened a few times, then got stuck being really light with the desktop being barely visible, though better from way down angle (if you open it all the way out) and looking like a negative from the way up angle. I restarted it, and the problem persisted. I shut it down for a day, and, upon startup, the screen is now completely white with nothing visible on it. I had connected the PB to my tv using the s-video out jack on the back and I can see the desktop clearly on it, but it's extremely difficult to read any text, largely due to my tv being big and not hi-def. So far I had tried fixing or diagnosing it by switching resolutions and calibration in the "display" area of System prefs and also in universal access "seeing" tab, I've reset the PMU and still nothing. Here's what's going on: if I start visualizer on the iTunes, both the TV and the stock display flicker to black, then the TV does the visualizer thingy and the display goes back to white. The apple logo backlight is on no problem at all times as well. The laptop was never dropped, handled roughly or subjected to extreme temps. The flickering problem had first appeared when I had relized that I only had about a minute for the battery to go completely empty (my 'puter is almost 3 years old). The recall for the displays covers laptops manufactured about 2 months after mine, otherwise all the symtoms listed in the recall match. Does anyone know what I should do next? I had read about getting a new LCD inverter, but at the same time I am now unemployed and really have no dough.... I'm a sound engineer, and I need my PB to be mobile. The only thing that had happened recently is that I installed the newer version of Pro Tools on my machine, LE 6.9. Please HELP!
    PB G4 Ti   Mac OS X (10.3.9)  

    You might have to restore the pictures from your ""backup" you have on iCloud. But, then again, that would put your iPhone back to the last state it was in when doing that backup. But at least you would have all your pictures back.
    iin any case, I wouldn't do any further backups or any changes to your iCloud account, until you've got your pictures back again. Proceed cautiously and carefully at this point, until you get an answer that will safely restore the pictures.

  • How to restrict number of rows display using ig:gridView

    Hi
    All
    How to restrict number of rows display using <ig:gridView datasource="{mybean.mylist}">
    i am getting 10 rows using data_row . i wanna show only first 5 rows .
    pageSize ="5" will be ok . but it displays remaining rows in next page. but i want to display only first 5 rows . is there any attribute to restrict number of rows.
    thanks
    rambhapuri

    I have no idea which component you're talking about. If want to discuss here about a non-Sun JSF component, then please mention about the name, version and build in detail. You can also consider posting this question at the website/forum/mailinglist of the component manfacturer rather than here. At least I can tell you that the Sun JSF h:dataTable has the 'rows' attribute for that. I can also suggest you to just take a look in the TLD documentation of the component in question. There should be all possible attributes listed with a detailed explanation about the behaviour.

  • 0 down vote favorite share [fb] share [tw]        How to hide cut/copy/paste/Replace- menu on the UIWebView when it is being displayed over the keyboard.  Detail: I am having a HTML from, having text box, displayed using UIWebView. If user types in text b

    How to hide cut/copy/paste/Replace… menu on the UIWebView when it is being displayed over the keyboard.
    Detail: I am having a HTML from, having text box, displayed using UIWebView. If user types in text box it shows the keyboard. Now If user tap and hold on text box it shows a popup menu. Now while keyboard and pop up are being displayed user scrolls the view. At this time it shows pop up over the keyboard which I need to hide.
    I tried setMenuVisible of UIMenuController when popup rect and keyboard rect intersects each other on viewDidScroll but it didn't help me.
    Any clues will help a lot.
    Thanks.

    You are more likely to get an answer if you post programming problems to the Developer forum. This forum is intended for normal user level problems.

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • End of page in ALV display using OOPS

    Hi all,
       How can i display end of page or footer in ALV display using OOPS concept.
    Thanks,
    vinit

    Hi ,
    Try using this code.
    First add a handler method in your handler class definition as:
    e.g. METHOD handle__end_of_page
    FOR EVENT print_end_of_page OF cl_gui_alv_grid .
    Then implement the method in the implementation part of your local class.
    e.g. METHOD handle_print_end_of_page .
    WRITE:/ 'Flights Made on ', sy-datum .
    ENDMETHOD .
    And register this method as the handler.
    SET HANDLER gr_event_handler->handle_print_end_of_page FOR gr_alvgrid .
    Hope this helps.
    Regards,
    Janaki.

  • Select a range of rows to be displayed using ROWNUM

    I am trying to select a range of records to be displayed using Rownum
    It works using MINUS
    SQL> select rownum,department_id,department_name from departments where rownum <= 20
    minus
    select rownum,department_id,department_name from departments where rownum < 11;
    but does not work if a range is specified
    select rownum,department_id,department_name from departments where rownum >= 11 and rownum <= 20;
    What has gone wrong?
    Details of what I have tried are as follows:
    Connect to the sample schema HR
    SQL> connect hr/hr
    SQL> desc departments
    Name Null? Type
    DEPARTMENT_ID NOT NULL NUMBER(4)
    DEPARTMENT_NAME NOT NULL VARCHAR2(30)
    MANAGER_ID NUMBER(6)
    LOCATION_ID NUMBER(4)
    List all records in Departments
    SQL> select rownum,department_id,department_name from departments;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    1 10 Administration
    2 20 Marketing
    3 30 Purchasing
    4 40 Human Resources
    etc......
    26 260 Recruiting
    27 270 Payroll
    27 rows selected.
    List the first 10 records in DEPARTMENTS
    SQL> select rownum,department_id,department_name from departments where rownum <= 10;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    1 10 Administration
    2 20 Marketing
    etc.....
    10 100 Finance
    List row number from 11 to 20, but cannot no rows selected. Why?
    SQL> select rownum,department_id,department_name from departments where rownum >= 11 and rownum <= 20;
    no rows selected
    Use of MINUS can retrieve row number from 11 to 20
    SQL> select rownum,department_id,department_name from departments where rownum <= 20
    minus
    select rownum,department_id,department_name from departments where rownum < 11;
    ROWNUM DEPARTMENT_ID DEPARTMENT_NAME
    11 110 Accounting
    12 120 Treasury
    13 130 Corporate Tax
    14 140 Control And Credit
    15 150 Shareholder Services
    16 160 Benefits
    17 170 Manufacturing
    18 180 Construction
    19 190 Contracting
    20 200 Operations
    10 rows selected.

    For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.
    Conditions testing for ROWNUM values greater than a positive integer are always false. For example, this query returns no rows:
    SELECT * FROM employees
    WHERE ROWNUM > 1;
    You can get the selected records based on the rownum using the inline query....
    SQL> select rownum, empno from emp;
    ROWNUM EMPNO
    1 7369
    2 7499
    3 7521
    4 7566
    5 7654
    6 7698
    7 7782
    8 7788
    9 7839
    10 7844
    11 7876
    ROWNUM EMPNO
    12 7900
    13 7902
    14 7934
    14 rows selected.
    SQL> select * from (select rownum rn, empno from emp) where rn > 2 and rn < 5;
    RN EMPNO
    3 7521
    4 7566

  • I recently connected my new MBA to an ACER display using the appropriate Apple hardware to connect to a VGA port. The quality of the ACER display is poor- the image is not clear. How do I achieve the same clarity of picture as my MBA screen?

    I recently connected my new MBA to an ACER display using the appropriate Apple hardware to connect to a VGA port. The quality of the ACER display is poor- the image is not clear. How do I achieve the same clarity of picture as my MBA screen?

    Welcome to the Apple Community.
    AirPlay Mirroring requires a second-generation Apple TV or later, OS X 10.8 or better and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer).
    On the basis of the specifications you have given for your set up, mirroring should work.

  • MacBook suddenly won't detect my display, Using Mini Display Port to VGA?

    MacBook suddenly won't detect my display, Using Mini Display Port to VGA?

    dohdoh1985, I have the exact same problem also! I recently bought a 42" RCA LCD TV. I connected my MacBook Pro to my TV using a Dynex Mini DisplayPort to HDMI adapter that I got from BestBuy. It worked great until I upgraded to Mac OS 10.6.4 and then it suddenly stopped working. Same TV, same settings, same cables, same adapter. Nothing changed since the last time it worked except that my OS was upgraded to 10.6.4, so i am assuming that is the culprit. The symptoms are EXACTLY the same as what dohdoh1985 described; when I plug in the TV, the laptop display flashes (3 times) as though it is detecting an external display and the picture on the TV briefly goes from blue to black for about 1 second then back to blue. The TV does not appear in the display menu / control panel and there is no sign that the MacBook detected it. I went through the usual troubleshooting steps (reset PRAM, checked connections, tv settings, etc) but nothing worked. Other HDMI sources (i.e. Blu-ray player) work fine on the TV using the same HDMI cable on the same port so there is nothing wrong with the cable, the TV or the TV's input settings.
    Meanwhile, I can still connect my MacBook to my external ViewSonic monitor at work without any problems. It's just the TV that's not working.
    I cancelled my cable subscription a while ago since I only watch shows online nowadays and this was my only way of watching TV shows, so I'm quite upset.
    Apple, please help!

  • Dual Display using ADC

    Hi. I have PowerMac G5, 1.8GHZ with CRT display and NVDA, Display-A. The PCI card has two output, DVI-I and ADC. DVI-I is connected to SONY display and functioning fine. I want to add another display using ADC. I bought ADC-DVI connector from the apple store (Dr Bott ADC DVI exctractor II). I also bought apple's DVI to video adaptor. Using these, I'm trying to make video display on the NTSC monitor.
    ADC-DVI-RCA
    It doesn't display. Could anyone tell me why it doesn't work?
    martha

    Greetings,
    The ADC-DVI cable only works with LCD monitor, not with CRT. Swap your connection of monitors the other way round and this should work.
    George Chew

  • Trying to compare string array using equals not working

    Hi,
    im prolly being really dumb here, but i am trying to compare 2 string arrays using the following code:
    if(array.equals(copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}
    the trouble is that even though they do match i keep getting dont match, can anyone tell me why?

    try
    if (Arrays.equals(array, copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}

  • Failed to convert Clob to String by using dbms_lob.substr

    it says that the cache is not enough to do this.
    I would like to get some infos from two tables as a View.
    and one of the table contains a Clob data which is large
    than 4k i think.
    and when I tried to create the view, it says that expecting
    - but got Clob, so I would like to change it to String by using
    dbmas_lob.substr function and met the cache limited problem.
    The database I am using is 10.2.0.1.0.

    Thanks for reply.
    and the problem was fixed.
    after I removed 'distinct', which specified after 'select'.

Maybe you are looking for

  • Imported B&W NEF images appear as colour when opened!

    Odd one here. Have searched the forum but while there are some B&W issues discussed, nothing matches this one. OS X 10.6.4, iphoto '09 build (8.1.2). Camera Nikon D90 using NEF images. Camera set to take B&W. Camera is using Colour Profile Adobe RGB

  • FileVault 2 bootup login gets weird after crash

    I have had FileVault 2 encryption enabled on my laptop for almost a year. It's worked well and I've never had trouble... until yesterday. My computer froze while I was saving something in Photoshop and had various other apps open. Nothing unusual. Th

  • Is the iPhone5 as slippery as it was for me?

    This is a strange question to ask I know, but bear with me please. I had a go on the iPhone5 in an Apple store at the weekend.  I was with someone who has the 4S, and she tried it too. When we both held one of these lovely looking phones in our left

  • REF CUR within FUNC

    I'm trying to check if rows exist on table_a - I'm using ref curs b/c need for dynamic FROM clause - getting message : PLS-00455: cursor 'L_REF_CUR' cannot be used in dynamic SQL OPEN statement vers 8.1.7.2.0 Thanks for help. CREATE OR REPLACE FUNCTI

  • Stylesheet control from a loaded xml

    The xml ist ok and I have a control of a loaded css file here (title {color: #FF0000} function onTxtComplete(e:Event):void {     my_txt.styleSheet=my_css;     my_txt.text = myXML; The xml is ok and the title appears BUT I loose the css (the same) con