Login | Register
My pages Projects Community openCollabNet

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

gef
Discussion topic

Back to topic list

[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();
    }

« Previous message in topic | 1 of 5 | Next message in topic »

Messages

Show all messages in topic

[gef-issues] [Issue 337] New - Text bounds calculated incorrectly tfmorris Tom Morris 2009-01-12 10:08:34 PST
     [gef-issues] [Issue 337] Text bounds calculated incorrectly mvw Michiel van der Wulp 2009-08-21 06:10:48 PDT
     [gef-issues] [Issue 337] Text bounds calculated incorrectly mvw Michiel van der Wulp 2009-08-21 07:14:41 PDT
     [gef-issues] [Issue 337] Text bounds calculated incorrectly tfmorris Tom Morris 2009-08-21 12:23:45 PDT
     [gef-issues] [Issue 337] Text bounds calculated incorrectly mvw Michiel van der Wulp 2009-08-24 06:39:45 PDT
Messages per page: