xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewe...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/gvt/text GlyphLayout.java
Date Fri, 09 Nov 2001 15:32:57 GMT
deweese     01/11/09 07:32:57

  Modified:    sources/org/apache/batik/ext/awt/image/rendered
                        TileCache.java TileMap.java
               sources/org/apache/batik/gvt/renderer
                        StrokingTextPainter.java
               sources/org/apache/batik/gvt/text GlyphLayout.java
  Log:
  1) Fixed a memory hanger onner in the tile cache.
  2) Reindented some of the font code.
  
  Revision  Changes    Path
  1.3       +2 -1      xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileCache.java
  
  Index: TileCache.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TileCache.java	2001/02/07 18:29:59	1.2
  +++ TileCache.java	2001/11/09 15:32:57	1.3
  @@ -21,7 +21,8 @@
   		return new TileGrid(minTileX, minTileY, xSz, ySz, src, cache);
   	}
   
  -	public static TileStore getTileGrid(RenderedImage img, TileGenerator src) {
  +	public static TileStore getTileGrid(RenderedImage img, 
  +					    TileGenerator src) {
   		return new TileGrid(img.getMinTileX(),  img.getMinTileY(), 
                               img.getNumXTiles(), img.getNumYTiles(), 
                               src, cache);
  
  
  
  1.8       +6 -4      xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileMap.java
  
  Index: TileMap.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileMap.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TileMap.java	2001/07/18 22:04:53	1.7
  +++ TileMap.java	2001/11/09 15:32:57	1.8
  @@ -26,10 +26,10 @@
   
       static class TileMapLRUMember extends TileLRUMember {
           public Point   pt;
  -        public TileMap parent;
  +        public SoftReference parent;
           TileMapLRUMember(TileMap parent, Point pt, Raster ras) {
               super(ras);
  -            this.parent = parent;
  +            this.parent = new SoftReference(parent);
               this.pt     = pt;
           }
   
  @@ -48,7 +48,7 @@
       private LRUCache      cache = null;
   
       public TileMap(TileGenerator source,
  -                    LRUCache cache) {
  +		   LRUCache cache) {
           this.cache    = cache;
           this.source   = source;
       }
  @@ -155,7 +155,9 @@
                               if (o == null) continue;
                           
                               TileMapLRUMember item = (TileMapLRUMember)o;
  -                            item.parent.rasters.remove(item.pt);
  +			    TileMap parent = (TileMap)item.parent.get();
  +			    if (parent != null)
  +				parent.rasters.remove(item.pt);
                           }
                       }
                   }
  
  
  
  1.21      +8 -2      xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
  
  Index: StrokingTextPainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- StrokingTextPainter.java	2001/11/05 20:04:11	1.20
  +++ StrokingTextPainter.java	2001/11/09 15:32:57	1.21
  @@ -60,7 +60,7 @@
    * @see org.apache.batik.gvt.text.GVTAttributedCharacterIterator
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: StrokingTextPainter.java,v 1.20 2001/11/05 20:04:11 deweese Exp $
  + * @version $Id: StrokingTextPainter.java,v 1.21 2001/11/09 15:32:57 deweese Exp $
    */
   public class StrokingTextPainter extends BasicTextPainter {
   
  @@ -477,6 +477,7 @@
                           for (int j = currentIndex; j < displayUpToIndex; j++) {
                               if (fontAssigned[j - start]) {
                                   if (runStart != -1) {
  +				    // System.out.println("Font 1: " + font);
                                       as.addAttribute(GVT_FONT, font, 
                                                       runStart-begin, j-begin);
                                       runStart=-1;
  @@ -489,6 +490,7 @@
                               numSet++;
                           }
                           if (runStart != -1) {
  +			    // System.out.println("Font 2: " + font);
                               as.addAttribute(GVT_FONT, font, 
                                               runStart-begin, 
                                               displayUpToIndex-begin);
  @@ -511,6 +513,7 @@
               for (int i = 0; i < aciLength; i++) {
                   if (fontAssigned[i]) {
                       if (runStart != -1) {
  +			// System.out.println("Font 3: " + prevF);
                           as.addAttribute(GVT_FONT, prevF, 
                                           runStart+asOff, i+asOff);
                           runStart = -1;
  @@ -532,6 +535,7 @@
                               prevF = fontFamily.deriveFont(fontSize, aci);
                       } else if (prevFF != fontFamily) {
                           // Font family changed...
  +			// System.out.println("Font 4: " + prevF);
                           as.addAttribute(GVT_FONT, prevF, 
                                           runStart+asOff, i+asOff);
                       
  @@ -544,9 +548,11 @@
                       }
                   }
               }
  -            if (runStart != -1) 
  +            if (runStart != -1) {
  +		// System.out.println("Font 5: " + prevF);
                   as.addAttribute(GVT_FONT, prevF, 
                                   runStart+asOff, aciLength+asOff);
  +	    }
   
               asOff += aciLength;
               if (aci.setIndex(end) == aci.DONE) {
  
  
  
  1.28      +37 -25    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- GlyphLayout.java	2001/11/06 18:48:18	1.27
  +++ GlyphLayout.java	2001/11/09 15:32:57	1.28
  @@ -42,7 +42,7 @@
    * @see org.apache.batik.gvt.text.TextSpanLayout
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: GlyphLayout.java,v 1.27 2001/11/06 18:48:18 deweese Exp $
  + * @version $Id: GlyphLayout.java,v 1.28 2001/11/09 15:32:57 deweese Exp $
    */
   public class GlyphLayout implements TextSpanLayout {
   
  @@ -861,23 +861,22 @@
       }
   
       /**
  -     * Returns the GVTFont to use when rendering the specified character iterator.
  -     * This should already be set as an attribute on the aci.
  +     * Returns the GVTFont to use when rendering the specified
  +     * character iterator.  This should already be set as an attribute
  +     * on the aci.
        *
        * @param aci The character iterator to get the font attribute from.
        *
  -     * @return The GVTFont to use.
  -     */
  +     * @return The GVTFont to use.  */
       protected GVTFont getFont(AttributedCharacterIterator aci) {
           aci.first();
  -        GVTFont gvtFont = (GVTFont)aci.getAttributes().get(
  -                GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
  -        if (gvtFont != null) {
  +        GVTFont gvtFont = (GVTFont)aci.getAttributes().get
  +	    (GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
  +        if (gvtFont != null) 
               return gvtFont;
  -        } else {
  -            // shouldn't get here
  -            return new AWTGVTFont(aci.getAttributes());
  -        }
  +
  +	// shouldn't get here
  +	return new AWTGVTFont(aci.getAttributes());
       }
   
       /**
  @@ -890,8 +889,8 @@
       protected void doPathLayout(boolean offsetApplied) {
   
           aci.first();
  -        textPath =  (TextPath) aci.getAttribute(
  -               GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
  +        textPath =  (TextPath) aci.getAttribute
  +	    (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
   
           // if doesn't have an attached text path, just return
           if (textPath == null) {
  @@ -970,11 +969,15 @@
   
                   Point2D nextGlyphPosition = gv.getGlyphPosition(i+1);
                   if (horizontal) {
  -                    glyphAdvance = (float)(nextGlyphPosition.getX() - currentGlyphPosition.getX());
  -                    nextGlyphOffset = (float)(nextGlyphPosition.getY() - currentGlyphPosition.getY());
  +                    glyphAdvance    = (float)(nextGlyphPosition.getX() - 
  +					      currentGlyphPosition.getX());
  +                    nextGlyphOffset = (float)(nextGlyphPosition.getY() - 
  +					      currentGlyphPosition.getY());
                   } else {
  -                    glyphAdvance = (float)(nextGlyphPosition.getY() - currentGlyphPosition.getY());
  -                    nextGlyphOffset = (float)(nextGlyphPosition.getX() - currentGlyphPosition.getX());
  +                    glyphAdvance    = (float)(nextGlyphPosition.getY() - 
  +					      currentGlyphPosition.getY());
  +                    nextGlyphOffset = (float)(nextGlyphPosition.getX() - 
  +					      currentGlyphPosition.getX());
                   }
               } else {
                   // last glyph, use the glyph metrics
  @@ -989,7 +992,8 @@
                               glyphAdvance = gm.getVerticalAdvance();
                           }
                       } else {
  -                        if (glyphOrientationAngle == 0 || glyphOrientationAngle == 180)
{
  +                        if ((glyphOrientationAngle == 0) || 
  +			    (glyphOrientationAngle == 180)) {
                               glyphAdvance = gm.getVerticalAdvance();
                           } else { // 90 || 270
                               glyphAdvance = gm.getHorizontalAdvance();
  @@ -1077,7 +1081,8 @@
               currentPosition += glyphAdvance;
               glyphOffset += nextGlyphOffset;
               currentChar += gv.getCharacterCount(i,i);
  -            ch = aci.setIndex(aci.getBeginIndex() + i + gv.getCharacterCount(i,i));
  +            ch = aci.setIndex(aci.getBeginIndex() + i + 
  +			      gv.getCharacterCount(i,i));
           }
   
           // store the position where a following glyph should be drawn,
  @@ -1086,9 +1091,13 @@
           if (lastGlyphDrawn > -1) {
               Point2D lastGlyphPos = gv.getGlyphPosition(lastGlyphDrawn);
               if (horizontal) {
  -                textPathAdvance = new Point2D.Double(lastGlyphPos.getX()+lastGlyphAdvance,
lastGlyphPos.getY());
  +                textPathAdvance = new Point2D.Double
  +		    (lastGlyphPos.getX()+lastGlyphAdvance, 
  +		     lastGlyphPos.getY());
               } else {
  -                textPathAdvance = new Point2D.Double(lastGlyphPos.getX(), lastGlyphPos.getY()+lastGlyphAdvance);
  +                textPathAdvance = new Point2D.Double
  +		    (lastGlyphPos.getX(), 
  +		     lastGlyphPos.getY()+lastGlyphAdvance);
               }
           } else {
               textPathAdvance = new Point2D.Double(0,0);
  @@ -1142,7 +1151,8 @@
   
                   // transform the glyph position
                   Point2D glyphPos = gv.getGlyphPosition(i);
  -                AffineTransform t = AffineTransform.getTranslateInstance(startPos.getX(),
startPos.getY());
  +                AffineTransform t = AffineTransform.getTranslateInstance
  +		    (startPos.getX(), startPos.getY());
                   t.scale(xscale,yscale);
                   t.translate(-startPos.getX(), -startPos.getY());
                   Point2D newGlyphPos = new Point2D.Float();
  @@ -1152,10 +1162,12 @@
                   // stretch the glyph
                   AffineTransform glyphTransform = gv.getGlyphTransform(i);
                   if (glyphTransform != null) {
  -                    glyphTransform.preConcatenate(AffineTransform.getScaleInstance(xscale,
yscale));
  +                    glyphTransform.preConcatenate
  +			(AffineTransform.getScaleInstance(xscale, yscale));
                       gv.setGlyphTransform(i, glyphTransform);
                   } else {
  -                    gv.setGlyphTransform(i, AffineTransform.getScaleInstance(xscale, yscale));
  +                    gv.setGlyphTransform
  +			(i, AffineTransform.getScaleInstance(xscale, yscale));
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Mime
View raw message