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 Selva <se...@yahoo.co.in> on 2006/05/05 14:21:52 UTC

Custom cursors problem

Hi All,

When i tried to add custom cursor to my svg canvas. It is throwing the 
attached exception. I used the following code to add custom cursor.

Anyone please specify why it’s throwing the exception?
 
Element defs = doc.createElementNS(svgNS, "defs");

Element cursor = doc.createElementNS(svgNS, "cursor");
cursor.setAttributeNS(null, "id", "zoomin");
cursor.setAttributeNS(null, "xlink:href", "file:///E:/zoomin.gif");
defs.appendChild(cursor);
               
doc.getRootElement().appendChild(defs);
doc.getRootElement().setAttributeNS(null, "style", "cursor:url
(#zoomin),crosshair");


org.apache.batik.bridge.BridgeException: null:0
The attribute "xlink:href" of the element <cursor> is required
at org.apache.batik.bridge.CursorManager.convertSVGCursorElement
(CursorManager.java:333)
at org.apache.batik.bridge.CursorManager.convertSVGCursor
(CursorManager.java:303)
at org.apache.batik.bridge.CursorManager.convertCursor(CursorManager.java:198)
at org.apache.batik.bridge.CSSUtilities.convertCursor(CSSUtilities.java:254)
at org.apache.batik.bridge.BridgeContext$DOMMouseOverEventListener.handleEvent
(BridgeContext.java:1485)
at org.apache.batik.dom.events.EventSupport.fireEventListeners
(EventSupport.java:350)
at org.apache.batik.dom.events.EventSupport.fireEventListeners
(EventSupport.java:407)
at org.apache.batik.dom.events.EventSupport.dispatchEvent
(EventSupport.java:281)
at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1010)
.
.
.

Thanks,
Selva



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


Re: Custom cursors problem

Posted by Chris Lilley <ch...@w3.org>.
On Friday, May 5, 2006, 2:21:52 PM, Selva wrote:

S> Hi All,

S> When i tried to add custom cursor to my svg canvas. It is throwing the 
S> attached exception. I used the following code to add custom cursor.

S> Anyone please specify why it’s throwing the exception?
S>  
S> Element defs = doc.createElementNS(svgNS, "defs");

S> Element cursor = doc.createElementNS(svgNS, "cursor");
S> cursor.setAttributeNS(null, "id", "zoomin");
S> cursor.setAttributeNS(null, "xlink:href", "file:///E:/zoomin.gif");


Its not the "xlink:href" attribute in the null namespace. Its the href attribute in the Xink namespace, http://www.w3.org/1999/xlink - which may or may not be bound to the xlink: prefix.

So
cursor.setAttributeNS(xlinkNS, "href", "file:///E:/zoomin.png");
would be better, assuming xlinkns is defined.





-- 
 Chris Lilley                    mailto:chris@w3.org
 Interaction Domain Leader
 Chair, W3C SVG Working Group
 W3C Graphics Activity Lead
 Co-Chair, W3C Hypertext CG


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


Custom cursors: SVG or Swing (inspired by: Custom Cursor Problems)

Posted by Urs Reupke <ur...@gmx.net>.
Hi,
reading the recent messages about custom cursors made me thinking.
I didn't know customizing the cursors for SVG elements was so simple,
up to now I did everything concerning cursors using Swing.
In case you're wondering, I had to extend and override the 
cursor-methods in the SVGCanvas.

My system is running fine, but I was wondering if the SVG way might be 
more performant or maybe even simpler to implement.

Right now, I am listening for mouse move events on the cursor, check 
whether the cursor is inside an element's bounding box, and if it is, 
replace the standard arrow cursor by one of two custom cursors, 
depending on state of the model represented by the element in the SVG.

If done by SVG, I would save the time to calculate the bounding box, 
however, I'd have to manipulate the document whenever the underlying 
model changes.

Considering the possible trouble involved, is it worth changing?

Regards
-Urs

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


Re: Custom cursors problem

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Hi Selva,

thats because you didn't use the xlink namespace but "null", which 
defaults to the SVG namespace and is wrong.

Try using the following:

cursor.setAttributeNS("http://www.w3.org/1999/xlink","href","zoomin.png");

Also note that gif might not be supported in all viewers, but png will 
be supported. Also I would recommend to use a relative URI and not an 
absolute. Otherwise you can't move your project to different machines.

Andreas

> Element cursor = doc.createElementNS(svgNS, "cursor");
> cursor.setAttributeNS(null, "id", "zoomin");
> cursor.setAttributeNS(null, "xlink:href", "file:///E:/zoomin.gif");
> defs.appendChild(cursor);
>                
> doc.getRootElement().appendChild(defs);
> doc.getRootElement().setAttributeNS(null, "style", "cursor:url
> (#zoomin),crosshair");
> 
> 
> org.apache.batik.bridge.BridgeException: null:0
> The attribute "xlink:href" of the element <cursor> is required
> at org.apache.batik.bridge.CursorManager.convertSVGCursorElement
> (CursorManager.java:333)
> at org.apache.batik.bridge.CursorManager.convertSVGCursor
> (CursorManager.java:303)
> at org.apache.batik.bridge.CursorManager.convertCursor(CursorManager.java:198)
> at org.apache.batik.bridge.CSSUtilities.convertCursor(CSSUtilities.java:254)
> at org.apache.batik.bridge.BridgeContext$DOMMouseOverEventListener.handleEvent
> (BridgeContext.java:1485)
> at org.apache.batik.dom.events.EventSupport.fireEventListeners
> (EventSupport.java:350)
> at org.apache.batik.dom.events.EventSupport.fireEventListeners
> (EventSupport.java:407)
> at org.apache.batik.dom.events.EventSupport.dispatchEvent
> (EventSupport.java:281)
> at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1010)
> .
> .
> .
> 
> Thanks,
> Selva
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


-- 
----------------------------------------------
Andreas Neumann - Institute of Cartography
Swiss Federal Institute of Technology (ETH)
ETH Hoenggerberg
CH-8093  Zurich, Switzerland
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/

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