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 Marek Scholaster <sc...@seznam.cz> on 2009/01/28 15:47:20 UTC

Conversion to custom format

Hello,
I'm new to Batik and would like to know whether Batik can help me with 
my problem and if so, where to start.

I need to write a conversion program from SVG to my custom format 
(vector based, only a few shapes, no transformations)
In addition I need to handle different layers differently (  <g 
id="layer1">  )
 
Basically I need the svg document in a state where all transformations 
are resolved and there is still information about layer of each shape.

Thank you for any help,
Marek Scholaster

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


Re: Conversion to custom format

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Batik handles the SVG side for you. You just have to handle the changes
of the transformation matrix on the Graphics2D object correctly. Either
you can track what transformations are applied incrementally, or you can
just retrieve the currently valid transformation matrix. Things like the
PathIterator can help you handle those when painting shapes. Either you
just use an identity transform if you apply the transformation matrix in
the context or you can pass in the current transformation matrix any you
get corrected coordinates. Depends on what your own format looks like.

Keep in mind that if you implement a Graphics2D implementation, it
doesn't necessarily have a dependency on Batik. You could use any Java2D
source to create graphics in your format. For example, you could write a
plug-in for the Java Printing System as a wrapper around your Graphics2D
implementation (much like the Transcoder subclass I mentioned). That
would allow any application printing to JPS to create documents in your
format. A big bag of possibilities. ;-)

On 28.01.2009 16:38:51 Marek Scholaster wrote:
> Thanks Jeremias,
> just one more question: transformations are resolved inside Batik or 
> they are left on Graphics2D ?
> 
> Jeremias Maerki wrote:
> > In FOP we convert SVG (or rather vector graphics in general) into
> > various output formats (PDF, PS, GOCA, HP/GL2). For that we "simply"
> > write Graphics2D implementations. When you have that, you can write a
> > Transcoder subclass that uses that Graphics2D implementation to convert
> > the SVG with the same API that Batik provides. If you don't have to do
> > anything SVG-specific, that's most likely the easiest route. Examples
> > for that are PSDocumentGraphics2D in XML Graphics Commons, or various
> > other Graphics2D implementations inside FOP. HTH
> >
> > On 28.01.2009 15:47:20 Marek Scholaster wrote:
> >   
> >> Hello,
> >> I'm new to Batik and would like to know whether Batik can help me with 
> >> my problem and if so, where to start.
> >>
> >> I need to write a conversion program from SVG to my custom format 
> >> (vector based, only a few shapes, no transformations)
> >> In addition I need to handle different layers differently (  <g 
> >> id="layer1">  )
> >>  
> >> Basically I need the svg document in a state where all transformations 
> >> are resolved and there is still information about layer of each shape.
> >>
> >> Thank you for any help,
> >> Marek Scholaster
> >>     
> >




Jeremias Maerki


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


Re: Conversion to custom format

Posted by Marek Scholaster <sc...@seznam.cz>.
Thanks Jeremias,
just one more question: transformations are resolved inside Batik or 
they are left on Graphics2D ?

Jeremias Maerki wrote:
> In FOP we convert SVG (or rather vector graphics in general) into
> various output formats (PDF, PS, GOCA, HP/GL2). For that we "simply"
> write Graphics2D implementations. When you have that, you can write a
> Transcoder subclass that uses that Graphics2D implementation to convert
> the SVG with the same API that Batik provides. If you don't have to do
> anything SVG-specific, that's most likely the easiest route. Examples
> for that are PSDocumentGraphics2D in XML Graphics Commons, or various
> other Graphics2D implementations inside FOP. HTH
>
> On 28.01.2009 15:47:20 Marek Scholaster wrote:
>   
>> Hello,
>> I'm new to Batik and would like to know whether Batik can help me with 
>> my problem and if so, where to start.
>>
>> I need to write a conversion program from SVG to my custom format 
>> (vector based, only a few shapes, no transformations)
>> In addition I need to handle different layers differently (  <g 
>> id="layer1">  )
>>  
>> Basically I need the svg document in a state where all transformations 
>> are resolved and there is still information about layer of each shape.
>>
>> Thank you for any help,
>> Marek Scholaster
>>     
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
>   

Re: Conversion to custom format

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
In FOP we convert SVG (or rather vector graphics in general) into
various output formats (PDF, PS, GOCA, HP/GL2). For that we "simply"
write Graphics2D implementations. When you have that, you can write a
Transcoder subclass that uses that Graphics2D implementation to convert
the SVG with the same API that Batik provides. If you don't have to do
anything SVG-specific, that's most likely the easiest route. Examples
for that are PSDocumentGraphics2D in XML Graphics Commons, or various
other Graphics2D implementations inside FOP. HTH

On 28.01.2009 15:47:20 Marek Scholaster wrote:
> Hello,
> I'm new to Batik and would like to know whether Batik can help me with 
> my problem and if so, where to start.
> 
> I need to write a conversion program from SVG to my custom format 
> (vector based, only a few shapes, no transformations)
> In addition I need to handle different layers differently (  <g 
> id="layer1">  )
>  
> Basically I need the svg document in a state where all transformations 
> are resolved and there is still information about layer of each shape.
> 
> Thank you for any help,
> Marek Scholaster



Jeremias Maerki


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


Re: Conversion to custom format

Posted by Archie Cobbs <ar...@gmail.com>.
On Wed, Jan 28, 2009 at 8:47 AM, Marek Scholaster <sc...@seznam.cz>wrote:

> I need to write a conversion program from SVG to my custom format (vector
> based, only a few shapes, no transformations)
> In addition I need to handle different layers differently (  <g
> id="layer1">  )
>
> Basically I need the svg document in a state where all transformations are
> resolved and there is still information about layer of each shape.
>

Before embarking on writing code, I think you should define what "resolved"
means...

E.g., SVG can only draw rectangles that are parallel to the X and Y axes. If
your language also has this limitation, then when you "resolve" all the
transforms, what happens if the rectangle ends up rotated? Do your rectangle
equivalents have a "rotation" attribute? Etc.

If I were doing this, instead of writing Java I'd just use XSLT plus java
extensions <http://xml.apache.org/xalan-j/extensions.html> for the transform
stuff, but I'm an XSL nerd :-)

-Archie

-- 
Archie L. Cobbs