From batik-users-return-10544-apmail-xmlgraphics-batik-users-archive=xmlgraphics.apache.org@xmlgraphics.apache.org Sun Jun 11 22:45:05 2006 Return-Path: Delivered-To: apmail-xmlgraphics-batik-users-archive@www.apache.org Received: (qmail 11613 invoked from network); 11 Jun 2006 22:45:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jun 2006 22:45:05 -0000 Received: (qmail 7006 invoked by uid 500); 11 Jun 2006 22:45:04 -0000 Delivered-To: apmail-xmlgraphics-batik-users-archive@xmlgraphics.apache.org Received: (qmail 6987 invoked by uid 500); 11 Jun 2006 22:45:04 -0000 Mailing-List: contact batik-users-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: batik-users@xmlgraphics.apache.org Delivered-To: mailing list batik-users@xmlgraphics.apache.org Received: (qmail 6976 invoked by uid 99); 11 Jun 2006 22:45:04 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jun 2006 15:45:04 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_WHOIS,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [206.190.48.171] (HELO web52408.mail.yahoo.com) (206.190.48.171) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 11 Jun 2006 15:45:02 -0700 Received: (qmail 62024 invoked by uid 60001); 11 Jun 2006 22:44:41 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=eucrW5Hje3iWsT9p7IL45PaSKNGS7lUZ0hmT/1zQK81k972CfTluLVzUDM4a3yaYJdmtdmE3MHIzqoMr4uJ9rrYO8Vz+BUZgnENFQPxhYAuk6xc9v4REBe0VCB5kayBtoQnXV6x/Ib0VOawxU499NNBM8JZJ6ivxzjDrk7tMUmo= ; Message-ID: <20060611224441.62022.qmail@web52408.mail.yahoo.com> Received: from [130.83.218.193] by web52408.mail.yahoo.com via HTTP; Sun, 11 Jun 2006 15:44:40 PDT Date: Sun, 11 Jun 2006 15:44:40 -0700 (PDT) From: Baris YILMAZ Subject: Re: Newbie question To: batik-users@xmlgraphics.apache.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1462941238-1150065880=:60690" Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --0-1462941238-1150065880=:60690 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Thomas, Thank you for your reply. And sorry about my negative opinion regarding the Batik homesite..:) I am trying to implement a java application, which produces a graphic, which represents the different soil layers along a section of topography. For this, I will have to draw paths, which will be filled with pattern elements. Later I want to show this graphic in Java panel, and give the user the opportunity to do some modifications. I'll appreciate if you give me some oppinion on the following points; 1- How should I create and fill this SVG document? 2- I already did this by using SVGGraphics2D, draw(generalpath) methods. But I don't know, how it is possible to fill this path with a predefined pattern like below; I have many other questions in my mind. But for the first time, this is enough. Thank you for your help. Baris thomas.deweese@kodak.com wrote: Hi Baris Baris YILMAZ wrote on 06/11/2006 02:49:34 PM: > I am a newbie in Batik and try to generate a simple svg file as below. But > somehow, my rectange is not appended to my svg file. Can anyone tell me why? Because the SVGGraphics2D.stream method writes what you have drawn to the SVGGraphics2D. Not the Document you give it as a factory. > Moreover, I am trying to find a tutorial on Batik. Except whose in the > homepage I can't find anything. The ones in the homepage, are very > bad written and simple... Uhh, thanks... > I'll appreciate your help.. Perhaps I could help if you could describe what you want to do, I could help. If you just want to serialize a DOM there is no reason to bring in the SVGGraphics2D (in fact there is no reason to use Batik). Batik happens to provide a simple XML serializer: org.apache.batik.dom.util.DOMUtilities.writeDocument(Document, Writer); > public class SVGNeu { > > public static void main(String[] args) throws IOException { > DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); > String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; > Document doc = impl.createDocument(svgNS, "svg", null); > > // get the root element (the svg element) > Element svgRoot = doc.getDocumentElement(); > > // set the width and height attribute on the root svg element > svgRoot.setAttributeNS(null, "width", "400"); > svgRoot.setAttributeNS(null, "height", "450"); > > // create the rectangle > Element rectangle = doc.createElementNS(svgNS, "rect"); > rectangle.setAttributeNS(null, "x", "10"); > rectangle.setAttributeNS(null, "y", "20"); > rectangle.setAttributeNS(null, "width", "100"); > rectangle.setAttributeNS(null, "height", "50"); > rectangle.setAttributeNS(null, "style", "fill:red"); > > // attach the rectangle to the svg root element > svgRoot.appendChild(rectangle); > > SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc); > ctx.setComment("Generated by FooApplication with Batik SVG Generator"); > SVGGraphics2D g2d = new SVGGraphics2D(ctx, false); > > // Finally, stream out SVG to the standard output using UTF-8 > // character to byte encoding > boolean useCSS = true; // we want to use CSS style attribute > Writer out = new OutputStreamWriter(System.out, "UTF-8"); > g2d.stream(out, useCSS); > } > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-1462941238-1150065880=:60690 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Thomas,

Thank you for your reply. And sorry about my negative opinion regarding the Batik homesite..:)

I am trying to implement a java application, which produces a graphic, which represents the different soil layers along a section of topography. For this, I will have to draw paths, which will be filled with pattern elements.

Later I want to show this graphic in Java panel, and give the user the opportunity to do some modifications.
 
I'll appreciate if you give me some oppinion on the following points;

1- How should I create and fill this SVG document?
2- I already did this by using SVGGraphics2D, draw(generalpath) methods. But I don't know, how it is possible to fill this path with a predefined pattern like below; 
    <pattern id="pattern1" x="0" y="0" width="15" height="15"
      patternUnits="userSpaceOnUse">  
<circle cx="6" cy="6" r="5"
style="fill: red; stroke:black;" />
</pattern>
I have many other questions in my mind. But for the first time, this is enough.
Thank you for your help.


Baris
 


thomas.deweese@kodak.com wrote:
Hi Baris

Baris YILMAZ wrote on 06/11/2006 02:49:34 PM:

> I am a newbie in Batik and try to generate a simple svg file as below.
But
> somehow, my rectange is not appended to my svg file. Can anyone tell me
why?

Because the SVGGraphics2D.stream method writes what you have drawn to
the SVGGraphics2D. Not the Document you give it as a factory.

> Moreover, I am trying to find a tutorial on Batik. Except whose in the
> homepage I can't find anything. The ones in the homepage, are very
> bad written and simple...

Uhh, thanks...

> I'll appreciate your help..

Perhaps I could help if you could describe what you want to do, I
could help.

If you just want to serialize a DOM there is no reason to bring
in the SVGGraphics2D (in fact there is no reason to use Batik).
Batik happens to provide a simple XML serializer:

org.apache.batik.dom.util.DOMUtilities.writeDocument(Document, Writer);

> public class SVGNeu {
>
> public static void main(String[] args) throws IOException {
> DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
> String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> Document doc = impl.createDocument(svgNS, "svg", null);
>
> // get the root element (the svg element)
> Element svgRoot = doc.getDocumentElement();
>
> // set the width and height attribute on the root svg element
> svgRoot.setAttributeNS(null, "width", "400");
> svgRoot.setAttributeNS(null, "height", "450");
>
> // create the rectangle
> Element rectangle = doc.createElementNS(svgNS, "rect");
> rectangle.setAttributeNS(null, "x", "10");
> rectangle.setAttributeNS(null, "y", "20");
> rectangle.setAttributeNS(null, "width", "100");
> rectangle.setAttributeNS(null, "height", "50");
> rectangle.setAttributeNS(null, "style", "fill:red");
>
> // attach the rectangle to the svg root element
> svgRoot.appendChild(rectangle);
>
> SVGGeneratorContext ctx =
SVGGeneratorContext.createDefault(doc);
> ctx.setComment("Generated by FooApplication with Batik SVG
Generator");
> SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
>
> // Finally, stream out SVG to the standard output using UTF-8
> // character to byte encoding
> boolean useCSS = true; // we want to use CSS style attribute
> Writer out = new OutputStreamWriter(System.out, "UTF-8");
> g2d.stream(out, useCSS);
> }
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

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


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --0-1462941238-1150065880=:60690--