xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frizzell, Michael A" <michael.frizz...@eds.com>
Subject Filter Problem with Java
Date Thu, 15 Aug 2002 14:07:54 GMT
Hello,

This problem occurs only when I try and use a "filter:url(#Filter_Name)"
inside the style tag of a given item. Whenever I run the file with that
filter info in the style tag it returns a "java.lang.NullPointerException". 

Successful fixes:
- Print out the dom that I'm creating to a file, use a rasterizer to import
the xml and create the jpg.

My filter code looks as such:

public void addFilter() {
	Element newDefs = doc.createElement("defs");
	newDefs.setAttributeNS(null, "id", "filterdefs");
	root.appendChild(newDefs);

	Element cmatrix = doc.createElement("feColorMatrix");
		cmatrix.setAttributeNS(null, "type", "matrix");
		cmatrix.setAttributeNS(null, "values", "0 0 0 0 0 0 0 0 .9 0
0 0 0 .9 0 0 0 0 1 0");

	Element merge = doc.createElement("feMerge");
	Element merge1 = doc.createElement("feMergeNode");
	merge1.setAttributeNS(null, "in", "coloredBlur");
   	Element merge2 = doc.createElement("feMergeNode");
   	merge2.setAttributeNS(null, "in", "SourceGraphic");
   	merge.appendChild(merge1);
  	merge.appendChild(merge2);


	Element gblur = doc.createElement("feGaussianBlur");
  	gblur.setAttributeNS(null, "stdDeviation", "5");
   	gblur.setAttributeNS(null, "result", "coloredBlur");

	Element MyFilter = doc.createElement("filter");
	MyFilter.setAttributeNS(null, "id", "glow");
	MyFilter.appendChild(cmatrix);
	MyFilter.appendChild(gblur);
	MyFilter.appendChild(merge);

	newDefs.appendChild(MyFilter);
}

The part where I use the filter:

Element path = doc.createElementNS(svgNS,"path");

path.setAttributeNS(null,"d", "M10 191 C16.6819 172.06 26.7093 40.9726 37 34
C72.0466 10.2538 49.9817 151 108 151 C147.528 151 176.714 90 225 90 L260 90
C272.484 90 292.389 88.4206 303 96 C319.88 108.057 326.492 168.377 352 162
C378.063 155.484 377.921 118.263 397 103 C435.649 72.0804 496.52 167.533 510
195");

path.setAttributeNS(null,"style","filter:url(#glow);fill:none;stroke-width:5
;opacity:1;fill-opacity:1;stroke-opacity:1;stroke:rgb(255,255,0)");
root.appendChild(path);

I'm thinking that it has everything to do with Namespace. That somehow when
I create the dom dynamically the namespacing is getting messed up and the
filter:url(#glow) can't find the filter id correctly, but when I open import
the outputted xml through the rasterizer, it does the namespacing correctly.
Any aid in how I might resolve this would be greatly appreciated. Thanks....

	Mike

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


Mime
View raw message