Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • nwilton
    started a topic BUG REPORT: DrawLabel.getBoundingBox()

    BUG REPORT: DrawLabel.getBoundingBox()

    Hi There,

    I've come across a bug that has appeared sometime in the past couple of months.

    Builds tested:
    ---------------

    * SmartGWT Pro 3.1p (2013-06-15).
    * SmartGWT Pro 4.0d (2013-06-15).
    * SmartGWT GPL (2013-05-30)

    Browsers tested:
    -------------------

    * Firefox 21 (Latest).
    * Chrome 27 (Latest).

    Note: Both Host and Development modes were tested.

    The Issue:
    ------------

    DrawLabel.getBoundingBox() only returns the correct data for the FIRST call for objects in a DrawPane object. Subsequent calls to DrawLabel.getBoundingBox() return always returns 0,0 for the second XY coordinate.

    The issue has been tested with both DrawLabel and DrawRect objects. Only the DrawLabel object type is affected.

    Reproduction Code:
    ----------------------
    Code:
    DrawPane drawPane = new DrawPane();  
    drawPane.setHeight(100);  
    drawPane.setWidth(300);  
    drawPane.setShowEdges(true);  
    drawPane.setEdgeSize(4);  
    drawPane.setBackgroundColor("papayawhip");  
    drawPane.setOverflow(Overflow.HIDDEN);  
              
    drawPane.addDrawHandler(new DrawHandler() {  
                   
            public void onDraw(DrawEvent event) {  
      
                    DrawPane drawPane = (DrawPane) event.getSource();  
      
            /*
             * Calling destoryItems() will cause getBoundingBox to fail for
             * both the first and subsequent calls.
             * Uncomment to test this behavior too.
             */
            //drawPane.destroyItems();
            
            DrawLabel helloLabel1 = new DrawLabel();  
            helloLabel1.setDrawPane(drawPane);  
            helloLabel1.setLeft(10);  
            helloLabel1.setTop(10);  
            helloLabel1.setContents("1. Hello Isometric");  
            helloLabel1.draw();  
            
            /*
             * This FIRST call will work. On my system it displays
             *   boundingBox1[0]	10
             *   boundingBox1[1]	10
             *   boundingBox1[2]	171		Correct :-)
             *   boundingBox1[3]	28		Correct :-)
             */
            
            int boundingBox1[] = helloLabel1.getBoundingBox();
            
            System.out.println("boundingBox1[0]\t" + boundingBox1[0]);
            System.out.println("boundingBox1[1]\t" + boundingBox1[1]);
            System.out.println("boundingBox1[2]\t" + boundingBox1[2]);
            System.out.println("boundingBox1[3]\t" + boundingBox1[3]);
            
            DrawLabel helloLabel2 = new DrawLabel();  
            helloLabel2.setDrawPane(drawPane);  
            helloLabel2.setLeft(10);  
            helloLabel2.setTop(40);  
            helloLabel2.setContents("2. Hello Isometric");  
            helloLabel2.draw();  
            
            /*
             * This SECOND call doesn't work. On my system it displays
             *   boundingBox1[0]	10
             *   boundingBox1[1]	40
             *   boundingBox1[2]	0		Incorrect :-(
             *   boundingBox1[3]	0		Incorrect :-(
             */
            
            int boundingBox2[] = helloLabel2.getBoundingBox();
            
            System.out.println("boundingBox2[0]\t" + boundingBox2[0]);
            System.out.println("boundingBox2[1]\t" + boundingBox2[1]);
            System.out.println("boundingBox2[2]\t" + boundingBox2[2]);
            System.out.println("boundingBox2[3]\t" + boundingBox2[3]);
            
        }
        	
    });
    Furthermore, calling DrawPane.destoryItems() before calling getBoundingBox() causes the issue to present for both the first and second calls. You can comment out the relevant line above to reproduce this.

    I hope this makes sense to you. I'm certain that this bug has only occurred in the last few weeks / months, and I'm quite keen for it to be resolved.

    Thank you very much for your support.

    -Nick

  • nwilton
    replied
    Fantastic! I appreciate your assistance. :-)

    Leave a comment:


  • Isomorphic
    replied
    Thanks for the report. This is now fix for tomorrow's 3.1 and newer builds.

    Leave a comment:


  • nwilton
    replied
    Is there any update on this?

    Regards,
    Nick

    p.s. I just noticed the code above should say "Hello Isomophic" instead. Sorry, it was late when I wrote that. :-/
    Last edited by nwilton; 18th Jun 2013, 16:33.

    Leave a comment:

Working...
X