You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Arvinder Singh <an...@WPI.EDU> on 2004/01/05 08:56:12 UTC

Overlays in Batik

Hi,

I'm new to Batik/SVG, and i'm trying to develop a java application using
batik that will load a svg file, display it, and then display a dot
(or any other simple graphic) on top of that svg at specified co-
ordinates.

Upto now i have been sucessful in gettign the SVG file to display, but i
don't know how to add something on top of that. Any information would
be appreciated.

Thanks,

-Andy

PS: My email program froze on me when i send my previous message and i'm
not sure if it went through so i'm sending this out again. I am sorry if
you got 2 identical emails from me.


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


Re: Overlays in Batik

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

It is depends on what you want, if you want to append the svg itself use
the appendChild() approach as suggested by other. However, if you want
only display the dot/anything but not changing the underlying svg just
draw on top Java Graphics object (it is simpler)

Regards
Tonny Kohar
http://www.kiyut.com

On Mon, 2004-01-05 at 14:56, Arvinder Singh wrote:
> Hi,
> 
> I'm new to Batik/SVG, and i'm trying to develop a java application using
> batik that will load a svg file, display it, and then display a dot
> (or any other simple graphic) on top of that svg at specified co-
> ordinates.
> 
> Upto now i have been sucessful in gettign the SVG file to display, but i
> don't know how to add something on top of that. Any information would
> be appreciated.
> 
> Thanks,
> 
> -Andy
> 
> PS: My email program froze on me when i send my previous message and i'm
> not sure if it went through so i'm sending this out again. I am sorry if
> you got 2 identical emails from me.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 


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


Re: Overlays in Batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Arvinder Singh wrote:

> I haven't used an svg Document in my code. I have an acutal svg file that
> I display on the JSVGCanvas. So how can I appendChild() to that?
> 
> Any sample code would really help.

Hi Arvinder,

    You might want to read the docs for JSVGComponent (baseclass of 
JSVGCanvas):

http://xml.apache.org/batik/javadoc/org/apache/batik/swing/svg/JSVGComponent.html

    It is important that you wait until the 'documentLoadingCompleted'
event is generated before this the document will be null.

    From here you need to learn/understand the standard W3C DOM.
Using 'createElementNS', setAttribute/setAttributeNS and the like
to create/configure and add elements to the Document.

    You also need to take care to only modify the document in the
UpdateManagers runnable Queue otherwise the changes will not be
properly tracked.

    You should be able to search this list for lots of info on the
UpdateManager.

    Good luck!

> 
> Thanks,
> 
> -Arvinder
> 
> On Mon, 5 Jan 2004, Jean-Christophe ARNU wrote:
> 
> 
>>Le Mon, 5 Jan 2004 02:56:12 -0500 (EST)
>>Arvinder Singh <an...@WPI.EDU> me disait que :
>>
>>
>>>I'm new to Batik/SVG, and i'm trying to develop a java application using
>>>batik that will load a svg file, display it, and then display a dot
>>>(or any other simple graphic) on top of that svg at specified co-
>>>ordinates.
>>>Upto now i have been sucessful in gettign the SVG file to display, but i
>>>don't know how to add something on top of that. Any information would
>>>be appreciated.
>>
>>	Hi,
>>	You can appendChild (the child is your "dots or other SVG object" you want
>>the document to be decorated) to root node of your DOM document.(That's the
>>way I do it). Don't forget to set the document ALWAYS_DYNAMIC if you apply
>>changes to it!





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


Re: Overlays in Batik

Posted by Arvinder Singh <an...@WPI.EDU>.
I haven't used an svg Document in my code. I have an acutal svg file that
I display on the JSVGCanvas. So how can I appendChild() to that?

Any sample code would really help.

Thanks,

-Arvinder

On Mon, 5 Jan 2004, Jean-Christophe ARNU wrote:

> Le Mon, 5 Jan 2004 02:56:12 -0500 (EST)
> Arvinder Singh <an...@WPI.EDU> me disait que :
>
> > I'm new to Batik/SVG, and i'm trying to develop a java application using
> > batik that will load a svg file, display it, and then display a dot
> > (or any other simple graphic) on top of that svg at specified co-
> > ordinates.
> > Upto now i have been sucessful in gettign the SVG file to display, but i
> > don't know how to add something on top of that. Any information would
> > be appreciated.
> 	Hi,
> 	You can appendChild (the child is your "dots or other SVG object" you want
> the document to be decorated) to root node of your DOM document.(That's the
> way I do it). Don't forget to set the document ALWAYS_DYNAMIC if you apply
> changes to it!
>
> 	regards,
>
> --
> Jean-Christophe Arnu
> Paratronic
>


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


Re: Overlays in Batik

Posted by "Jean-Christophe ARNU (JX)" <ar...@paratronic.fr>.
Le Mon, 5 Jan 2004 02:56:12 -0500 (EST)
Arvinder Singh <an...@WPI.EDU> me disait que :

> I'm new to Batik/SVG, and i'm trying to develop a java application using
> batik that will load a svg file, display it, and then display a dot
> (or any other simple graphic) on top of that svg at specified co-
> ordinates.
> Upto now i have been sucessful in gettign the SVG file to display, but i
> don't know how to add something on top of that. Any information would
> be appreciated.
	Hi,
	You can appendChild (the child is your "dots or other SVG object" you want
the document to be decorated) to root node of your DOM document.(That's the
way I do it). Don't forget to set the document ALWAYS_DYNAMIC if you apply
changes to it!

	regards,

-- 
Jean-Christophe Arnu
Paratronic

Re: Overlays in Batik

Posted by Bibek Sahu <sc...@dodds.net>.
Hi Arvinder,

What is the purpose of this dot / these dots?

* if the purpose is keep stateful information inside the SVG (e.g., you want
  to save the coordinates as part of the SVG), then the best bet is to
  modify the DOM as suggested by many:

	JSVGCanvas canvas = ...; // create canvas or JSVGComponent, etc.
	Element circle = canvas.getSVGDocument().createElement("circle"); // create circle --- not yet attached to anything
	circle.setAttribute("r", "3"); // set radius of circle
	circle.setAttribute("cx", "10"); // set x-coord of circle
	circle.setAttribute("cy, "12"); // set y-coord of circle

	canvas.getUpdateManager().getRunnableQueue().add( new Runnable() {
		public void run() {
			 // add circle to SVG
			canvas.getSVGDocument().getRootElement().appendChild(circle);
  		}
  	});

* if the purpose is simply to display (dynamically) some dots as the user
  moves the cursor or whatnot, then the Overlay you were asking about is
  probably the easiest way.

  public static void main(.....) {

  	final JSVGCanvas canvas = ....;

	class Blah implements Overlay {
		public void paint(Graphics g) {
			Graphics2D g2d = (Graphics2D) g;
			AffineTransform oldAt = g2d.getTransform();
			g2d.transform(mySvgCanvas.getRenderingTransform());

			// do painting
			g2d.drawCircle(......);

			// reset graphics, so other overlays draw correctly
			g2d.setTransform(oldAT);
		}
	}

	canvas.getOverlays().add(new Blah());
  }



Good luck!
- Bob


On Mon, 5 Jan 2004, Arvinder Singh wrote:

> Hi,
>
> I'm new to Batik/SVG, and i'm trying to develop a java application using
> batik that will load a svg file, display it, and then display a dot
> (or any other simple graphic) on top of that svg at specified co-
> ordinates.
>
> Upto now i have been sucessful in gettign the SVG file to display, but i
> don't know how to add something on top of that. Any information would
> be appreciated.
>
> Thanks,
>
> -Andy
>
> PS: My email program froze on me when i send my previous message and i'm
> not sure if it went through so i'm sending this out again. I am sorry if
> you got 2 identical emails from me.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>


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