The attachment is the svg file I tested, when drag the circle, it work soomthly in Adobe SVGViewer, but in Squiggle, it give me a totally odd exception:The attribute 'cx' of the element <circle> is invalid. I've read the FAQ, and tried the setAttributeNS method, the result is same.
Later I found the exception raise originally from org.apache.batik.parser.LengthParser.parseLength() method, it report "character.unexpected" error, I feel too strange this exception is warppered and rethrowed in org.apache.batik.bridge.UnitProcessor.svgToUserSpace class that I don't even know what is wrong there.
Any one have idea about this?


OS: winxp with sp1
JDK: sun jdk 1.4.1


Eric



// the exception stack printed
org.apache.batik.bridge.BridgeException: file:/G:/Downloads/Java/tools/batik-src-1.5/xml-batik/move_circle.svg:0
The attribute 'cx' of the element <circle> is invalid


at org.apache.batik.bridge.UnitProcessor.svgToUserSpace(UnitProcessor.java:307)


at org.apache.batik.bridge.UnitProcessor.svgHorizontalCoordinateToUserSpace(UnitProcessor.java:238)



at org.apache.batik.bridge.SVGCircleElementBridge.buildShape(SVGCircleElementBridge.java:62)



at org.apache.batik.bridge.SVGCircleElementBridge.handleDOMAttrModifiedEvent(SVGCircleElementBridge.java:106)



at org.apache.batik.bridge.BridgeContext$DOMAttrModifiedEventListener.handleEvent(BridgeContext.java:1041)



at org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:227)



at org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:184)



at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:413)


at org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:502)


at org.apache.batik.dom.AbstractAttr.setNodeValue(AbstractAttr.java:133)


at org.apache.batik.dom.AbstractAttr.setValue(AbstractAttr.java:176)

at org.apache.batik.dom.AbstractElement.setAttribute(AbstractElement.java:123)
...........


_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg width="400" height="250" viewBox="0 0 400 250">
<script type = "text/ecmascript">
<![CDATA[

var dragging=false;
var offX,offY;

function startDrag(evt)
{
	dragging = true;
	offX = evt.getClientX-evt.getTarget().getAttribute("cx");
	offY = evt.getClientY-evt.getTarget().getAttribute("cy");
}
function endDrag()
{
	dragging = false;
}
function doDrag(evt)
{
	if (!dragging)
	{
		return;
	}
	var circle = evt.getTarget();
	circle.setAttribute("cx",evt.getClientX()-offX);
	circle.setAttribute("cy", evt.getClientY()-offY);

	// use setAttributeNS does work too

	//var svgNS = "http://www.w3.org/2000/svg";;
	//circle.setAttributeNS(svgNS,"cx",evt.getClientX()-offX);
	//circle.setAttribute(svgNS,"cy", evt.getClientY()-offY);


}
]]>
</script>

<circle cx="100" cy="100" r="20" fill="red" onmousedown="startDrag(evt)" onmouseup="endDrag()" onmousemove="doDrag(evt)"/>
</svg>

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

Reply via email to