You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Philippe Converset <pc...@Qarbon.com> on 2002/03/21 12:15:33 UTC

How to reuse a filter from the bridge?

Hi,

I'm trying to reuse a filter defined in a SVG document.
My SVG document is kindof a description file that gives a list of filters 
and paints. The idea is to extract one of these filters and apply it on a 
programmatically created graphicsNode.

I already did a similar job by retrieving a paint defined in a SVG 
document, the code being something like:
     Element paintedElement = document_.getElementById(id);
     Paint paint = PaintServer.convertFillPaint(paintedElement, node, 
bridgeContext_);

This is working great, so I tried something similar for the filter:
     Element filteredElement = document_.getElementById(filteredId);
     Element filterElement = document_.getElementById(filterId);
     SVGFilterElementBridge filterBridge = 
(SVGFilterElementBridge)bridgeContext_.getBridge(filterElement);
     Filter filter = 
filterBridge.createFilter(bridgeContext_,filteredElement,filterElement,node);

But the created filter is always null.

My SVG document looks like:
<svg>
   <defs>
     <filter id="filterRef">
       <feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
     </filter>
   </defs>
   <g>
     <rect id="filteredRef" x="0" y="0" width="100" height="100" 
filter="url(#filterRef)"/>
   </g>
</svg>

Any idea?

Philippe


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


Re: How to reuse a filter from the bridge?

Posted by Philippe Converset <pc...@Qarbon.com>.
It was a mistake on my side, the correct code to create a filter is:

Filter filter = 
filterBridge.createFilter(bridgeContext_,filterElement,filteredElement,node);

the "filterElement" and "filteredElement" were wrongly inverted.

And now, it works!

Philippe.


At 12:15 21/03/2002 +0100, Philippe Converset wrote:
>Hi,
>
>I'm trying to reuse a filter defined in a SVG document.
>My SVG document is kindof a description file that gives a list of filters 
>and paints. The idea is to extract one of these filters and apply it on a 
>programmatically created graphicsNode.
>
>I already did a similar job by retrieving a paint defined in a SVG 
>document, the code being something like:
>     Element paintedElement = document_.getElementById(id);
>     Paint paint = PaintServer.convertFillPaint(paintedElement, node, 
> bridgeContext_);
>
>This is working great, so I tried something similar for the filter:
>     Element filteredElement = document_.getElementById(filteredId);
>     Element filterElement = document_.getElementById(filterId);
>     SVGFilterElementBridge filterBridge = 
> (SVGFilterElementBridge)bridgeContext_.getBridge(filterElement);
>     Filter filter = 
> filterBridge.createFilter(bridgeContext_,filteredElement,filterElement,node);
>
>But the created filter is always null.
>
>My SVG document looks like:
><svg>
>   <defs>
>     <filter id="filterRef">
>       <feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>
>     </filter>
>   </defs>
>   <g>
>     <rect id="filteredRef" x="0" y="0" width="100" height="100" 
> filter="url(#filterRef)"/>
>   </g>
></svg>
>
>Any idea?
>
>Philippe


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