Login | Register
My pages Projects Community openCollabNet

Discussions > issues > [gef-issues] [Issue 337] New - Text bounds calculated incorrectly

gef
Discussion topic

Hide all messages in topic

All messages in topic

[gef-issues] [Issue 337] Text bounds calculated incorrectly

Reply

Author mvw
Full name Michiel van der Wulp
Date 2009-08-24 06:39:45 PDT
Message http://gef.tigris.or​g/issues/show_bug.cg​i?id=337



User mvw changed the following:

                What |Old value |New value
====================​====================​====================​====================​
                  Status|RESOLVED |REOPENED
--------------------​--------------------​--------------------​--------------------​
              Resolution|FIXED |
--------------------​--------------------​--------------------​--------------------​




------- Additional comments from mvw at tigris dot org Mon Aug 24 06:39:44 -0700 2009 -------
Ok, you made me change my mind: The bugs I fixed were severe. IMHO the remaining
problems are less important, but they do exist.
Reopen.

[gef-issues] [Issue 337] Text bounds calculated incorrectly

Reply

Author tfmorris
Full name Tom Morris
Date 2009-08-21 12:23:45 PDT
Message http://gef.tigris.or​g/issues/show_bug.cg​i?id=337






------- Additional comments from tfmorris at tigris dot org Fri Aug 21 12:23:43 -0700 2009 -------
If Sun's text measuring methods are broken or inadequate for some reason, that
should be reported to them. Otherwise, I believe that continuing to use
homegrown algorithms instead of the standard built-in Java algorithms will just
lead to continued problems. In particular, non-Roman character sets (e.g.
Kanji, etc) may not conform to the assumptions baked into GEF's private algorithm.

[gef-issues] [Issue 337] Text bounds calculated incorrectly

Reply

Author mvw
Full name Michiel van der Wulp
Date 2009-08-21 07:14:41 PDT
Message http://gef.tigris.or​g/issues/show_bug.cg​i?id=337






------- Additional comments from mvw at tigris dot org Fri Aug 21 07:14:41 -0700 2009 -------
Committed revision 1272 with some improvements.

[gef-issues] [Issue 337] Text bounds calculated incorrectly

Reply

Author mvw
Full name Michiel van der Wulp
Date 2009-08-21 06:10:48 PDT
Message http://gef.tigris.or​g/issues/show_bug.cg​i?id=337



User mvw changed the following:

                What |Old value |New value
====================​====================​====================​====================​
                      CC|'' |'mvw'
--------------------​--------------------​--------------------​--------------------​
                  Status|NEW |RESOLVED
--------------------​--------------------​--------------------​--------------------​
              Resolution| |FIXED
--------------------​--------------------​--------------------​--------------------​




------- Additional comments from mvw at tigris dot org Fri Aug 21 06:10:47 -0700 2009 -------
Committed revision 1271.

I think that the text size and position are calculated correctly now.
But I did not use any code like the example given by Tom.

I presume this is sufficient, and put this issue on fixed.

[gef-issues] [Issue 337] New - Text bounds calculated incorrectly

Reply

Author tfmorris
Full name Tom Morris
Date 2009-01-12 10:08:34 PST
Message http://gef.tigris.or​g/issues/show_bug.cg​i?id=337
                 Issue #|337
                 Summary|Text bounds calculated incorrectly
               Component|gef
                 Version|current
                Platform|All
                     URL|
              OS/Version|All
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|core
             Assigned to|issues@gef
             Reported by|tfmorris






------- Additional comments from tfmorris at tigris dot org Mon Jan 12 10:08:32 -0800 2009 -------
The calcBounds method incorrectly calculates the bounding box. It doesn't take
into account the fact that the baseline (where the text is positioned) is almost
always inside the bounding box and it usually undermeasures the width of the text.

It shouldn't be doing the measuring by hand anyway. It should be using the Java
facilities for doing this. Something similar to the following from ArgoUML's
PathItemPlacement could be used as a template for implementation.

    private Rectangle remeasureText(Graphics g, FigText textFig) {
        FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();
        AttributedCharacterIterator aci = new AttributedString(textFig
                .getText()).getIterator();
        LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
        // No autowrapping - use a wide width
        TextLayout tl = lbm.nextLayout(5000);
        return tl.getBounds().getBounds();
    }
Messages per page: