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 Lea Thurman <le...@onesoon.co.uk> on 2008/03/31 22:59:00 UTC

Filling a rectangle with a tiled pattern of .png files

Hi all,

I am a batik novice so please be gentle. 

I am trying to fill a rectangle by tiling a .png image. After looking at the
specification I got as far as rendering the following svg:

<?xml version="1.0" encoding="UTF-8"?>
<svg height="297mm" width="210mm">
    <pattern width="0.5in" x="0.5in" height="0.5in" id="fpatid"
        y="0.5in"
xlink:href="file:///volumes/pbook/users/user/images/image.png"/>
    <rect fill="url(#fpatid)" x="0.0in" width="0.5in"
        height="0.5in" y="0.0in" stroke="none"/>
</svg>

However I am getting the following error:

java.net.MalformedURLException: no protocol: defs.svg#fpatid

I am not sure how to reference the pattern in fill attribute in the
rectangle.

Any help would be much appreciated.

Regards
Lea.
-- 
View this message in context: http://www.nabble.com/Filling-a-rectangle-with-a-tiled-pattern-of-.png-files-tp16399081p16399081.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: Filling a rectangle with a tiled pattern of .png files

Posted by Helder Magalhães <he...@gmail.com>.
>  However I am getting the following error:
>  java.net.MalformedURLException: no protocol: defs.svg#fpatid

Although I'm not sure if the specification states it as mandatory,
elements which are to be reused should generally be enclosed within a
"defs" element [1].

Given your sample will lead to:
<?xml version="1.0" encoding="UTF-8"?>
<svg height="297mm" width="210mm">
  <defs>
    <pattern width="0.5in" x="0.5in" height="0.5in" id="fpatid" y="0.5in"
     xlink:href="file:///volumes/pbook/users/user/images/image.png"/>
  </defs>
  <rect fill="url(#fpatid)" x="0.0in" width="0.5in"
   height="0.5in" y="0.0in" stroke="none"/>
</svg>

Please consider including Jonathan Chetwynd's suggestions for improved
accessibility and standards compliance.

Regards,

  Helder Magalhães

[1] http://www.w3.org/TR/SVG/struct.html#DefsElement

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


Re: Filling a rectangle with a tiled pattern of .png files

Posted by Jonathan Chetwynd <j....@btinternet.com>.
Lea,

batik relies on more detail please use something like:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1"  
baseProfile="full" xmlns:xlink="http://www.w3.org/1999/xlink"  
height="297mm" width="210mm">
<title>Arabian geometric tiled background</title>

a title is not required, but according to the specification should be  
included.

regards

~:"


on os x there is a rather more useful error dialogue:
The prefix "xlink" for attribute "xlink:href" associated with an  
element type "pattern" is not bound.


On 31 Mar 2008, at 21:59, Lea Thurman wrote:

>
> Hi all,
>
> I am a batik novice so please be gentle.
>
> I am trying to fill a rectangle by tiling a .png image. After  
> looking at the
> specification I got as far as rendering the following svg:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <svg height="297mm" width="210mm">
>    <pattern width="0.5in" x="0.5in" height="0.5in" id="fpatid"
>        y="0.5in"
> xlink:href="file:///volumes/pbook/users/user/images/image.png"/>
>    <rect fill="url(#fpatid)" x="0.0in" width="0.5in"
>        height="0.5in" y="0.0in" stroke="none"/>
> </svg>
>
> However I am getting the following error:
>
> java.net.MalformedURLException: no protocol: defs.svg#fpatid
>
> I am not sure how to reference the pattern in fill attribute in the
> rectangle.
>
> Any help would be much appreciated.
>
> Regards
> Lea.
> -- 
> View this message in context: http://www.nabble.com/Filling-a-rectangle-with-a-tiled-pattern-of-.png-files-tp16399081p16399081.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>


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


Re: Filling a rectangle with a tiled pattern of .png files

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

Lea Thurman <le...@onesoon.co.uk> wrote on 03/31/2008 04:59:00 PM:

> I am trying to fill a rectangle by tiling a .png image.

> However I am getting the following error:
> java.net.MalformedURLException: no protocol: defs.svg#fpatid

   This looks to me like somehow you aren't setting the
base URL of the document correctly.  Are you building the
DOM dynamically?  Or are you providing an input stream with
a 'URI' to the XML Parser?  If so you need to replace the
text "defs.svg" with a properly formatted URL (like
"file:///defs.svg"

   Once that is fixed I still don't think it will render right
(see below).

> I am not sure how to reference the pattern in fill attribute in the
> rectangle.
> After looking at the specification I got as far as rendering the
following svg:

> <?xml version="1.0" encoding="UTF-8"?>
> <svg height="297mm" width="210mm">
>     <pattern width="0.5in" x="0.5in" height="0.5in" id="fpatid"
>         y="0.5in"
> xlink:href="file:///volumes/pbook/users/user/images/image.png"/>

   The SVG pattern element doesn't have an xlink:href attribute.
You will need to have an 'image' element under the pattern, something
like:

   <pattern id="fpatid" x="0.5in" y="0.5in" width="0.5in" height="0.5in">
      <image x="0" y="0" width=".5in" height=".5in"

xlink:href="file:///volumes/pbook/users/user/images/image.png"/>
   </pattern>