Christophe Mertz > svg-svg2zinc-0.10 > SVG:SVG2zinc::Backend


Annotate this POD


Open  1
View/Report Bugs


SVG:SVG2zinc::Backend - a virtual class SVG:SVG2zinc svg reader. Sub-class are specialized for different type of generation


package SVG:SVG2zinc::Backend::SubClass

use SVG:SVG2zinc::Backend;

## some methods definition


 ## when using a specialized backend:

 use SVG:SVG2zinc::Backend::SubClass;

 $backend = SVG:SVG2zinc::Backend::SubClass->new(
               -out => filename_or_handle,
               -in => svgfilename,
               -verbose => 0|1,


 $backend->treatLines("lineOfCode1", "lineOfCode2",...);

 $backend->comment("comment1", "comment2", ...);

 $backend->printLines("comment1", "comment2", ...);



SVG:SVG2zinc::Backend is a perl virtual class which should be specialized in sub-classes. It defines a common interface ot classes which can for example generate perl code with Tk::Zinc, display SVG file in a Tk::Zinc widget, convert svg file in image files (e.g. png) or generate tcl code to be used with TkZinc etc...

A backend should provide the following methods:


This creation class method should accept pairs of (-option => value) as well as the following arguments:


A filename or a filehandle ready for writing the output. In same rare cases (e.g. the Display backend which only displays the SVG file on the screen, this option will not be used)


The svg filename. It should be used in comments only in the generated file


It will be used for letting the backend being verbose


Generates the header in the out file, if needed. This method should be called just after creating a backend and prior any treatLines or comment method call.


Processes the given arguments as lines of code. The arguments are very close to Tk::Zinc perl code. When creating a new backend, using the Print backend can help understanding what are exactly these arguments.


Processes the given arguments as comments. Depending on the backend, this method must be redefined so that arguments are treated as comments, or just skipped.


Print in an outfile the given arguments as lines of text. This method should not be re-defined, but used by any Backend which generates code.


Generate the tail in the out file if needed and closes the out file. This must be the last call.

A backend can use the printLines method to print lines in the generated file.


SVG::SVG2zinc::Backend::Display(3pm), SVG::SVG2zinc::Backend::PerlScript(3pm), SVG::SVG2zinc::Backend::TclScript(3pm), SVG::SVG2zinc::Backend::PerlClass(3pm) code as examples of SVG::SVG2zinc::Backend subclasses.



Christophe Mertz <mertz at intuilab dot com> with some help from Daniel Etienne <etienne at cena dot fr>


CENA (C) 2003-2004

This program is free software; you can redistribute it and/or modify it under the term of the LGPL licence.

syntax highlighting: