deweese     02/05/15 07:14:31

  Modified:    sources/org/apache/batik/bridge SVGAElementBridge.java
               sources/org/apache/batik/ext/awt/image SVGComposite.java
               sources/org/apache/batik/extension/svg
                        SVGFlowTextElementBridge.java
  Log:
  1) FlowText now supports clicking on anchors.
  2) Fix for drawing to destinations that do not have alpha.
  3) Made the Anchor related Listeners public so FlowText could use them
  
  Revision  Changes    Path
  1.16      +4 -4      xml-batik/sources/org/apache/batik/bridge/SVGAElementBridge.java
  
  Index: SVGAElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAElementBridge.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SVGAElementBridge.java    19 Mar 2002 09:25:40 -0000      1.15
  +++ SVGAElementBridge.java    15 May 2002 14:14:30 -0000      1.16
  @@ -24,7 +24,7 @@
    * Bridge class for the <a> element.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: SVGAElementBridge.java,v 1.15 2002/03/19 09:25:40 hillion Exp $
  + * @version $Id: SVGAElementBridge.java,v 1.16 2002/05/15 14:14:30 deweese Exp $
    */
   public class SVGAElementBridge extends AbstractGraphicsNodeBridge {
   
  @@ -86,7 +86,7 @@
       /**
        * To handle a click on an anchor.
        */
  -    protected static class AnchorListener implements EventListener {
  +    public static class AnchorListener implements EventListener {
   
           protected UserAgent userAgent;
   
  @@ -106,7 +106,7 @@
       /**
        * To handle a mouseover on an anchor and set the cursor.
        */
  -    protected static class CursorMouseOverListener implements EventListener {
  +    public static class CursorMouseOverListener implements EventListener {
   
           protected UserAgent userAgent;
   
  @@ -129,7 +129,7 @@
       /**
        * To handle a mouseout on an anchor and set the cursor.
        */
  -    protected static class CursorMouseOutListener implements EventListener {
  +    public static class CursorMouseOutListener implements EventListener {
   
           protected UserAgent userAgent;
   
  
  
  
  1.4       +98 -1     
xml-batik/sources/org/apache/batik/ext/awt/image/SVGComposite.java
  
  Index: SVGComposite.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/SVGComposite.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGComposite.java 5 Dec 2001 13:46:04 -0000       1.3
  +++ SVGComposite.java 15 May 2002 14:14:30 -0000      1.4
  @@ -29,7 +29,7 @@
    * This provides an implementation of all the composite rules in SVG.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thomas DeWeese</a>
  - * @version $Id: SVGComposite.java,v 1.3 2001/12/05 13:46:04 deweese Exp $
  + * @version $Id: SVGComposite.java,v 1.4 2002/05/15 14:14:30 deweese Exp $
    */
   public class SVGComposite
       implements Composite {
  @@ -130,6 +130,13 @@
   
           switch (rule.getRule()) {
           case CompositeRule.RULE_OVER:
  +            if (!dstCM.hasAlpha()) {
  +                if (use_int_pack) 
  +                    return new OverCompositeContext_INT_PACK_NA(srcCM, dstCM);
  +                else
  +                    return new OverCompositeContext_NA  (srcCM, dstCM);
  +            }
  +
               if (!use_int_pack)
                   return new OverCompositeContext(srcCM, dstCM);
               
  @@ -360,6 +367,53 @@
       }
   
       /**
  +     * This implements SRC_OVER for 4 band byte src data and
  +     * 3 band byte dst data.
  +     */
  +    public static class OverCompositeContext_NA 
  +        extends AlphaPreCompositeContext {
  +        OverCompositeContext_NA(ColorModel srcCM, ColorModel dstCM) {
  +            super(srcCM, dstCM);
  +        }
  +
  +        public void precompose(Raster src, Raster dstIn, 
  +                               WritableRaster dstOut) {
  +            int [] srcPix = null;
  +            int [] dstPix = null;
  +
  +            int x=dstOut.getMinX();
  +            int w=dstOut.getWidth();
  +
  +            int y0=dstOut.getMinY();
  +            int y1=y0 + dstOut.getHeight();
  +
  +            final int norm = (1<<24)/255;
  +            final int pt5  = (1<<23);
  +
  +            for (int y = y0; y<y1; y++) {
  +                srcPix = src.getPixels  (x, y, w, 1, srcPix);
  +                dstPix = dstIn.getPixels(x, y, w, 1, dstPix);
  +                int srcSP  = 0;
  +                int dstSP  = 0;
  +                int end = w*4;
  +                while (srcSP<end) {
  +                    final int dstM = (255-srcPix[srcSP+3])*norm;
  +                    dstPix[dstSP] = 
  +                        srcPix[srcSP] + ((dstPix[dstSP]*dstM +pt5)>>>24);
  +                    ++srcSP; ++dstSP;
  +                    dstPix[dstSP] = 
  +                        srcPix[srcSP] + ((dstPix[dstSP]*dstM +pt5)>>>24);
  +                    ++srcSP; ++dstSP;
  +                    dstPix[dstSP] = 
  +                        srcPix[srcSP] + ((dstPix[dstSP]*dstM +pt5)>>>24);
  +                    srcSP+=2; ++dstSP;
  +                }
  +                dstOut.setPixels(x, y, w, 1, dstPix);
  +            }
  +        }
  +    }
  +
  +    /**
        * This implements SRC_OVER for Int packed data where the src is
        * premultiplied.
        */
  @@ -391,6 +445,49 @@
                           (((     srcP & 0xFF000000) +
                             (((((dstInP>>>24)     )*dstM+pt5)&0xFF000000)     ))|
                            ((     srcP & 0x00FF0000) +
  +                          (((((dstInP>> 16)&0xFF)*dstM+pt5)&0xFF000000)>>> 8))|
  +                         ((     srcP & 0x0000FF00) +
  +                          (((((dstInP>>  8)&0xFF)*dstM+pt5)&0xFF000000)>>>16))|
  +                         ((     srcP & 0x000000FF) +
  +                          (((((dstInP     )&0xFF)*dstM+pt5)         )>>>24)));
  +                }
  +                srcSp    += srcAdjust;
  +                dstInSp  += dstInAdjust;
  +                dstOutSp += dstOutAdjust;
  +            }
  +        }
  +    }
  +
  +    /**
  +     * This implements SRC_OVER for Int packed data and dest has no Alpha...
  +     */
  +    public static class OverCompositeContext_INT_PACK_NA 
  +        extends AlphaPreCompositeContext_INT_PACK {
  +        OverCompositeContext_INT_PACK_NA(ColorModel srcCM, ColorModel dstCM) {
  +            super (srcCM, dstCM);
  +        }
  +
  +        // When we get here src data has been premultiplied.
  +        public void precompose_INT_PACK
  +            (final int width,           final int height,
  +             final int [] srcPixels,    final int srcAdjust,    int srcSp,
  +             final int [] dstInPixels,  final int dstInAdjust,  int dstInSp,
  +             final int [] dstOutPixels, final int dstOutAdjust, int dstOutSp) {
  +
  +            final int norm = (1<<24)/255;
  +            final int pt5  = (1<<23);
  +
  +            int srcP, dstInP, dstM;
  +            
  +            for (int y = 0; y<height; y++) {
  +                final int end = dstOutSp+width;
  +                while (dstOutSp<end) {
  +                    srcP   = srcPixels  [srcSp++];
  +                    dstInP = dstInPixels[dstInSp++];
  +                    
  +                    dstM = (255-(srcP>>>24))*norm;
  +                    dstOutPixels[dstOutSp++] = 
  +                        (((     srcP & 0x00FF0000) +
                             (((((dstInP>> 16)&0xFF)*dstM+pt5)&0xFF000000)>>> 8))|
                            ((     srcP & 0x0000FF00) +
                             (((((dstInP>>  8)&0xFF)*dstM+pt5)&0xFF000000)>>>16))|
  
  
  
  1.5       +31 -6     
xml-batik/sources/org/apache/batik/extension/svg/SVGFlowTextElementBridge.java
  
  Index: SVGFlowTextElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/SVGFlowTextElementBridge.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SVGFlowTextElementBridge.java     30 Apr 2002 19:08:47 -0000      1.4
  +++ SVGFlowTextElementBridge.java     15 May 2002 14:14:31 -0000      1.5
  @@ -21,6 +21,7 @@
   
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
  +import org.w3c.dom.events.EventTarget;
   
   import org.apache.batik.bridge.Bridge;
   import org.apache.batik.bridge.BridgeException;
  @@ -29,6 +30,9 @@
   import org.apache.batik.bridge.SVGUtilities;
   import org.apache.batik.bridge.TextUtilities;
   import org.apache.batik.bridge.UnitProcessor;
  +import org.apache.batik.bridge.UserAgent;
  +import org.apache.batik.bridge.SVGAElementBridge;
  +
   import org.apache.batik.dom.util.XMLSupport;
   import org.apache.batik.dom.util.XLinkSupport;
   import org.apache.batik.gvt.TextNode;
  @@ -39,7 +43,7 @@
    * Bridge class for the &lt;flowText> element.
    *
    * @author <a href="[EMAIL PROTECTED]">Thomas DeWeese</a>
  - * @version $Id: SVGFlowTextElementBridge.java,v 1.4 2002/04/30 19:08:47 deweese 
Exp $
  + * @version $Id: SVGFlowTextElementBridge.java,v 1.5 2002/05/15 14:14:31 deweese 
Exp $
    */
   public class SVGFlowTextElementBridge extends SVGTextElementBridge 
       implements BatikExtConstants {
  @@ -454,12 +458,13 @@
   
               switch (n.getNodeType()) {
               case Node.ELEMENT_NODE:
  -                if (n.getNamespaceURI() != getNamespaceURI()) {
  +                // System.out.println("Element: " + n);
  +                if ((n.getNamespaceURI() != getNamespaceURI()) &&
  +                    (n.getNamespaceURI() != SVG_NAMESPACE_URI)) {
                       break;
                   }
                   
                   nodeElement = (Element)n;
  -
                   String ln = n.getLocalName();
                   if (ln.equals(BATIK_EXT_FLOW_LINE_TAG)) {
                       fillAttributedStringBuffer(ctx, nodeElement, 
  @@ -468,10 +473,30 @@
                       //                    " - '" +  asb + "'");
                       lnLocs.add(new Integer(asb.length()));
                   } else if (ln.equals(BATIK_EXT_FLOW_SPAN_TAG) ||
  -                    ln.equals(SVG_ALT_GLYPH_TAG) ||
  -                    ln.equals(SVG_A_TAG)) {
  +                           ln.equals(SVG_ALT_GLYPH_TAG)) {
                       fillAttributedStringBuffer(ctx, nodeElement,
                                                  false, asb, lnLocs);
  +                } else if (ln.equals(SVG_A_TAG)) {
  +                    EventTarget target = (EventTarget)nodeElement;
  +                    UserAgent ua = ctx.getUserAgent();
  +                    target.addEventListener
  +                        (SVG_EVENT_CLICK, 
  +                         new SVGAElementBridge.AnchorListener(ua),
  +                         false);
  +                    
  +                    target.addEventListener
  +                        (SVG_EVENT_MOUSEOVER,
  +                         new SVGAElementBridge.CursorMouseOverListener(ua),
  +                         false);
  +                    
  +                    target.addEventListener
  +                        (SVG_EVENT_MOUSEOUT,
  +                         new SVGAElementBridge.CursorMouseOutListener(ua),
  +                         false);
  +                    fillAttributedStringBuffer(ctx,
  +                                               nodeElement,
  +                                               false,
  +                                               asb, lnLocs);
                   } else if (ln.equals(SVG_TREF_TAG)) {
                       String uriStr = XLinkSupport.getXLinkHref((Element)n);
                       Element ref = ctx.getReferencedElement((Element)n, uriStr);
  @@ -485,7 +510,7 @@
                           Map m = getAttributeMap(ctx, nodeElement, null);
                           asb.append(s, m);
                       }
  -                }
  +                } 
                   break;
                   
               case Node.TEXT_NODE:
  
  
  

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

Reply via email to