bella       01/07/30 23:18:40

  Modified:    sources/org/apache/batik/gvt/text GlyphLayout.java
  Log:
  text rotate attribute now handled properly
  
  Revision  Changes    Path
  1.18      +19 -14    xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java
  
  Index: GlyphLayout.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- GlyphLayout.java  2001/07/27 02:23:37     1.17
  +++ GlyphLayout.java  2001/07/31 06:18:40     1.18
  @@ -39,7 +39,7 @@
    * @see org.apache.batik.gvt.TextSpanLayout.
    *
    * @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
  - * @version $Id: GlyphLayout.java,v 1.17 2001/07/27 02:23:37 bella Exp $
  + * @version $Id: GlyphLayout.java,v 1.18 2001/07/31 06:18:40 bella Exp $
    */
   public class GlyphLayout implements TextSpanLayout {
   
  @@ -1101,8 +1101,8 @@
               // computed on the basis of baseline-shifts, etc.
               float ox = 0f;
               float oy = 0f;
  -            Float rotation = null;
               float verticalGlyphRotation = 0f;
  +            Float rotation = null;
   
               if (ch != CharacterIterator.DONE) {
                   Float x = (Float) aci.getAttribute(
  @@ -1139,6 +1139,7 @@
                       }
                   }
   
  +                // calculate the total rotation for this glyph
                   if (rotation == null || rotation.isNaN()) {
                       rotation = new Float(verticalGlyphRotation);
                   } else {
  @@ -1225,13 +1226,11 @@
                       }
                   }
               }
  +
  +            // set the new glyph position
               gv.setGlyphPosition(i, new Point2D.Float(curr_x_pos+ox,curr_y_pos+oy));
  -            if (rotation.floatValue() != 0f) {
  -                gv.setGlyphTransform(i,
  -                    AffineTransform.getRotateInstance(
  -                        (double)rotation.floatValue()));
  -            }
   
  +            // calculte the position of the next glyph
               if (!ArabicTextHandler.arabicCharTransparent(ch)) {
                   // only apply the advance if the current char is not transparent
                   GVTGlyphMetrics gm = gv.getGlyphMetrics(i);
  @@ -1250,14 +1249,9 @@
                               advanceY = gm.getHorizontalAdvance();
                           } else { // 270
                               advanceY = gm.getHorizontalAdvance();
  -                            // need to translate backwards so that the spacing
  +                            // need to translate so that the spacing
                               // between chars is correct
  -                            AffineTransform glyphTransform = 
gv.getGlyphTransform(i);
  -                            if (glyphTransform == null) {
  -                                glyphTransform = new AffineTransform();
  -                            }
  -                            glyphTransform.translate(-advanceY, 0);
  -                            gv.setGlyphTransform(i, glyphTransform);
  +                            gv.setGlyphTransform(i, 
AffineTransform.getTranslateInstance(0, advanceY));
                           }
                       }
                       curr_y_pos += advanceY;
  @@ -1265,6 +1259,17 @@
                       curr_x_pos += gm.getHorizontalAdvance();
                   }
               }
  +
  +            // rotate the glyph
  +            if (rotation.floatValue() != 0f) {
  +                AffineTransform glyphTransform = gv.getGlyphTransform(i);
  +                if (glyphTransform == null) {
  +                    glyphTransform = new AffineTransform();
  +                }
  +                glyphTransform.rotate((double)rotation.floatValue());
  +                gv.setGlyphTransform(i, glyphTransform);
  +            }
  +
               ch = aci.setIndex(aci.getBeginIndex() + i + gv.getCharacterCount(i,i));
               i++;
               firstChar = false;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to