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 Paul Solomon <pa...@clearboxsystems.com.au> on 2008/08/03 17:10:51 UTC

how to access a GraphicsNode

Hi,

I am new to using Batik and I am currently trying to implement CAD type software. Currently I can load and save docs and add elements to a existing doc. I have a DOM doc and a dynamic bridge to a GVT, and I am painting to a Panel using the gvt tree.

I am now trying to work out how to modify existing elements. I would like to do the following:

1. Receive notification is there is a mouseover an element.
2. provide user feedback for mouseover (thicker stroke etc)
3. allow user click/drag of objects to reposition then.

Can anyone give me pointers on relevant interfaces / docs on how to achieve these tasks?

Regards,

Paul 

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


Re: how to access a GraphicsNode

Posted by Paul Solomon <pa...@clearboxsystems.com.au>.
Hi Thomas,

Thanks for your response, I have a few more questions if that is ok.

I initially started out using the GVT tree for rendering rather than the Canvas as I wanted to implement my own way things look and feel, i.e. zoom behaviour, item select hover, ghosting on drag etc and thought that it might be eaiser to just paint the tree and then draw any other bits I need.

Is the Canvas suitable for this type of thing? I am hoping to end up with fairly professional CAD software with similar functionality to AutoCAD / Solidworks etc.

I was hoping to keep the DOM internally representing the actual drawing, so I am not keen on the idea of modifying the DOM (changing stroke widths etc) for the purpose of showing selection highlighting. I would be more likely to want to paint this onto a glass pane (or something similar in the Canvas if there is an equivelent) Is this approach reasonable?

After the GVT is generated and the dynamic bridge is set up, is GVT Root node stable? i.e. can I keep a reference to it or do I need to regenerate the reference everytime I want to paint to look at the tree?

Thanks in advance,

Paul



> I am new to using Batik and I am currently trying to implement CAD 
> type software. Currently I can load and save docs and add elements 
> to a existing doc. I have a DOM doc and a dynamic bridge to a GVT, 
> and I am painting to a Panel using the gvt tree. 

   I must ask, why aren't you using the JSVGCanvas?  It does a lot 
of stuff for you (like partial updates, maintaining a buffered image 
for faster screen updates etc)... 

> I am now trying to work out how to modify existing elements. I would 
> like to do the following: 
> 
> 1. Receive notification is there is a mouseover an element. 

   I would add a mouse over listener in the DOM.  You asked about 
a 'wider' mouse over sensitive region.  Batik doesn't provide 
anything natively, however you could fake it by adding a copy 
(or 'use'ing the primary content) with a thicker stroke attribute, 
and setting  visibility to hidden, and pointer-events to 'all'). 

   If you wanted to adjust the behavior of the GVT node hit 
code then you would basically have to replace all of the 
hit code in the GVT package... 

> 2. provide user feedback for mouseover (thicker stroke etc) 

   With the Canvas you can just update the attributes of the element 
through the DOM and it will update on the screen. 

   e.setAttributeNS(null, "stroke-width", "3"); 

> 3. allow user click/drag of objects to reposition then. 

   This is typically done by adjusting the affine transform 
on the element. 


> Can anyone give me pointers on relevant interfaces / docs on how to 
> achieve these tasks? 

   My primary suggestion would be to stick to using the SVG DOM 
to do these tasks.  Direct use of the GVT isn't encouraged but 
it's "forbidden" either, just understand that support of the SVG 
standard is it's primary purpose. 

PS. As far as building a link between GVT nodes or DOM nodes 
and other structures the simplest mechanism would be a Java 
HashTable... 

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


Re: how to access a GraphicsNode

Posted by th...@kodak.com.
Hi Paul,

Paul Solomon <pa...@clearboxsystems.com.au> wrote on 08/03/2008 11:10:51 
AM:

> I am new to using Batik and I am currently trying to implement CAD 
> type software. Currently I can load and save docs and add elements 
> to a existing doc. I have a DOM doc and a dynamic bridge to a GVT, 
> and I am painting to a Panel using the gvt tree.

   I must ask, why aren't you using the JSVGCanvas?  It does a lot
of stuff for you (like partial updates, maintaining a buffered image
for faster screen updates etc)...

> I am now trying to work out how to modify existing elements. I would
> like to do the following:
> 
> 1. Receive notification is there is a mouseover an element.

   I would add a mouse over listener in the DOM.  You asked about 
a 'wider' mouse over sensitive region.  Batik doesn't provide 
anything natively, however you could fake it by adding a copy
(or 'use'ing the primary content) with a thicker stroke attribute, 
and setting  visibility to hidden, and pointer-events to 'all').

   If you wanted to adjust the behavior of the GVT node hit
code then you would basically have to replace all of the
hit code in the GVT package...

> 2. provide user feedback for mouseover (thicker stroke etc)

   With the Canvas you can just update the attributes of the element
through the DOM and it will update on the screen.

   e.setAttributeNS(null, "stroke-width", "3");

> 3. allow user click/drag of objects to reposition then.

   This is typically done by adjusting the affine transform
on the element.


> Can anyone give me pointers on relevant interfaces / docs on how to 
> achieve these tasks?

   My primary suggestion would be to stick to using the SVG DOM
to do these tasks.  Direct use of the GVT isn't encouraged but
it's "forbidden" either, just understand that support of the SVG
standard is it's primary purpose.

PS. As far as building a link between GVT nodes or DOM nodes
and other structures the simplest mechanism would be a Java
HashTable...