xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vha...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/bridge SVGFeImageElementBridge.java
Date Fri, 08 Mar 2002 11:12:47 GMT
vhardy      02/03/08 03:12:46

  Modified:    sources/org/apache/batik/bridge SVGFeImageElementBridge.java
  Log:
  Fixed feImage bridge partially
  
  Revision  Changes    Path
  1.15      +52 -9     xml-batik/sources/org/apache/batik/bridge/SVGFeImageElementBridge.java
  
  Index: SVGFeImageElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFeImageElementBridge.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SVGFeImageElementBridge.java	23 Jan 2002 14:14:07 -0000	1.14
  +++ SVGFeImageElementBridge.java	8 Mar 2002 11:12:46 -0000	1.15
  @@ -34,7 +34,7 @@
    * Bridge class for the <feImage> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGFeImageElementBridge.java,v 1.14 2002/01/23 14:14:07 deweese Exp $
  + * @version $Id: SVGFeImageElementBridge.java,v 1.15 2002/03/08 11:12:46 vhardy Exp $
    */
   public class SVGFeImageElementBridge
       extends AbstractSVGFilterPrimitiveElementBridge {
  @@ -109,6 +109,7 @@
           // try to load an SVG document
           DocumentLoader loader = ctx.getDocumentLoader();
           URIResolver resolver = new URIResolver(svgDoc, loader);
  +        boolean toBBoxNeeded = false;
           try {
               Element refElement = null;
               Node n = resolver.getNode(purl.toString(), filterElement);
  @@ -116,13 +117,14 @@
                   refElement = ((SVGDocument)n).getRootElement();
               } else if (n.getNodeType() == Node.ELEMENT_NODE) {
                   refElement = (Element)n;
  +                toBBoxNeeded = true;
               } else {
                   throw new BridgeException
                       (filterElement, ERR_URI_IMAGE_INVALID,
                        new Object[] {uriStr});
               }
               filter = createSVGFeImage
  -                (ctx, primitiveRegion, refElement);
  +                (ctx, primitiveRegion, refElement, toBBoxNeeded, filterElement, filteredNode);
           } catch (BridgeException ex) {
               throw ex;
           } catch (Exception ex) { /* Nothing to do */ }
  @@ -154,20 +156,61 @@
        * @param ctx the bridge context
        * @param primitiveRegion the primitive region
        * @param Element the referenced element
  +     * @param toBBoxNeeded true if there is a need to transform to ObjectBoundingBox
  +     *        space
  +     * @param filterElement parent filter element
  +     * @param filteredNode node to which the filter applies
        */
       protected static Filter createSVGFeImage(BridgeContext ctx,
                                                Rectangle2D primitiveRegion,
  -                                             Element refElement) {
  -
  +                                             Element refElement,
  +                                             boolean toBBoxNeeded,
  +                                             Element filterElement,
  +                                             GraphicsNode filteredNode) {
  +
  +        //
  +        // <!> FIX ME
  +        // Unresolved issue on the feImage behavior when referencing an
  +        // image (PNG, JPEG or SVG image).
  +        // VH & TK, 03/08/2002
  +        // Furthermore, for feImage referencing doc fragment, should act
  +        // like a <use>, i.e., CSS cascading and the whole zing bang.
  +        //
           GraphicsNode node = ctx.getGVTBuilder().build(ctx, refElement);
           Filter filter = node.getGraphicsNodeRable(true);
   
  -        // Need to translate the image to the x, y coordinate to
  -        // have the same behavior as the <use> element
  -        // <!> FIX ME? I THINK THIS IS ONLY PARTIALLY IMPLEMENTING THE SPEC.
  -        // <!> TO DO : HANDLE TRANSFORM
           AffineTransform at = new AffineTransform();
  -        at.translate(primitiveRegion.getX(), primitiveRegion.getY());
  +
  +        if (toBBoxNeeded){
  +            // 'primitiveUnits' attribute - default is userSpaceOnUse
  +            short coordSystemType;
  +            Element filterDefElement = (Element)(filterElement.getParentNode());
  +            String s = SVGUtilities.getChainableAttributeNS
  +                (filterDefElement, null, SVG_PRIMITIVE_UNITS_ATTRIBUTE, ctx);
  +            if (s.length() == 0) {
  +                coordSystemType = SVGUtilities.USER_SPACE_ON_USE;
  +            } else {
  +                coordSystemType = SVGUtilities.parseCoordinateSystem
  +                    (filterDefElement, SVG_PRIMITIVE_UNITS_ATTRIBUTE, s);
  +            }
  +            
  +            if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX) {
  +                at = SVGUtilities.toObjectBBox(at, filteredNode);
  +            }
  +
  +            Rectangle2D bounds = filteredNode.getGeometryBounds();
  +            at.preConcatenate(AffineTransform.getTranslateInstance
  +                              (primitiveRegion.getX() - bounds.getX(), 
  +                               primitiveRegion.getY() - bounds.getY()));
  +            
  +        } else {
  +            
  +            // Need to translate the image to the x, y coordinate to
  +            // have the same behavior as the <use> element
  +            at.preConcatenate(AffineTransform.getTranslateInstance
  +                              (primitiveRegion.getX(), primitiveRegion.getY()));
  +        }
  +
           return new AffineRable8Bit(filter, at);
       }
   
  
  
  

---------------------------------------------------------------------
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