Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xmlgraphics-fop Wiki" 
for change notification.

The following page has been changed by JeremiasMaerki:
http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml/NewDesign

The comment on the change is:
Synchronize with implementation

------------------------------------------------------------------------------
  
  [http://people.apache.org/~jeremias/fop/renderer-design-new.png]
  
- == IFPainter design ==
+ == Intermediate format design (Java part) ==
  
- IFPainter (working title, better suggestions welcome!) is a central 
interface, like Renderer. There's one implementation for each output format 
that is useful in the context of the intermediate format (probably includes all 
current renderers except text. most important are: PostScript, AFP and PCL). 
Ideally, the IFPainter interface is a direct equivalent to the possible SAX 
stream for the new IF format, i.e. it is possible to convert between IFPainter 
and the IF-NG SAX stream with no losses. The IFContentHandler in the graphic 
above would convert the SAX stream to IFPainter calls and a special IFPainter 
implementation used by IFRenderer could convert the calls to the SAX stream. 
That way, the IFRenderer could actually render to an IFPainter without the 
detour over XML.
+ IF!DocumentHandler and IFPainter (working titles, better suggestions 
welcome!) are the central interfaces, like Renderer. There's one implementation 
for each output format that is useful in the context of the intermediate format 
(probably includes all current renderers except text. most important are: 
PostScript, AFP and PCL). Ideally, the interfaces are a direct equivalent to 
the possible SAX stream for the new IF format, i.e. it is possible to convert 
between the interfaces and the IF-NG SAX stream with no losses. The IFParser in 
the graphic above will convert the SAX stream to IF!DocumentHandler and 
IFPainter calls and a special implementation used by IFRenderer would convert 
the calls to a SAX stream. That way, the IFRenderer could actually render to an 
IFPainter without the detour over XML.
  
+ In contrast to the Renderer interface, the new intermediate format uses two 
basic interfaces: IF!DocumentHandler and IFPainter. IF!DocumentHandler is 
responsible for setting up the output file and handling file/document-level 
responsibilities. IFPainter handles the actual "painting" of the individual 
pages. The split has advantages: The various implementation classes are smaller 
and more readable. Formats like the PCL renderer need to convert certain 
features to bitmaps (text, borders etc.) as they can't be painted as nicely in 
the native print language. In this case, FOP uses Java2D to create those 
bitmaps. Separating document-level code from page-level code makes code-reuse 
easier.
+ 
- The IFPainter interface is not fully designed, yet, so the following is just 
to give an idea what it could look like (all methods will probably throw 
SAXException):
+ The interfaces are not fully designed, yet, (pending verification in real 
life) so the following is just to give an idea what it could look like (all 
methods will probably throw SAXException):
  
  {{{
+ public interface IFDocumentHandler {
+ 
+     void setUserAgent(FOUserAgent userAgent);
+     void setResult(Result result) throws IFException;
+     void setFontInfo(FontInfo fontInfo);
+     IFDocumentHandlerConfigurator getConfigurator();
+     boolean supportsPagesOutOfOrder();
+     String getMimeType();
+ 
+     void startDocument() throws IFException;
+     void endDocument() throws IFException;
+     void startDocumentHeader() throws IFException;
+     void endDocumentHeader() throws IFException;
+     void startDocumentTrailer() throws IFException;
+     void endDocumentTrailer() throws IFException;
+     void startPageSequence(String id) throws IFException;
+     void endPageSequence() throws IFException;
+     void startPage(int index, String name, Dimension size) throws IFException;
+     void endPage() throws IFException;
+     void startPageHeader() throws IFException;
+     void endPageHeader() throws IFException;
+     IFPainter startPageContent() throws IFException;
+     void endPageContent() throws IFException;
+     void startPageTrailer() throws IFException;
+     void endPageTrailer() throws IFException;
+     void handleExtensionObject(Object extension) throws IFException;
+ 
+ }
+ 
+ 
  public interface IFPainter {
  
-     void setUserAgent(FOUserAgent userAgent);
-     void setResult(Result result);
-     boolean supportsPagesOutOfOrder();
- 
-     void startDocument();
-     void endDocument();
- 
-     void startDocumentHeader();
-     void endDocumentHeader();
- 
-     void startDocumentTrailer();
-     void endDocumentTrailer();
- 
-     void startPageSequence(String id);
-     void endPageSequence();
- 
-     void startPage(int index, String name, Dimension size);
-     void endPage();
- 
-     void startPageHeader();
-     void endPageHeader();
- 
-     void startPageContent();
-     void endPageContent();
- 
-     void startPageTrailer();
-     void addTarget(String name, int x, int y);
-     void endPageTrailer();
- 
-     //viewport: for viewport/reference pairs
-     void startViewport(AffineTransform transform, Dimension size, Rectangle 
clipRect);
+     void startViewport(AffineTransform transform, Dimension size, Rectangle 
clipRect) throws IFException;
-     void startViewport(AffineTransform[] transforms, Dimension size, 
Rectangle clipRect);
+     void startViewport(AffineTransform[] transforms, Dimension size, 
Rectangle clipRect) throws IFException;
-     //For transform parsing, Batik's 
org.apache.batik.parser.TransformListHandler/Parser can be reused
+     //For transform, Batik's 
org.apache.batik.parser.TransformListHandler/Parser can be used
-     void endViewport();
+     void endViewport() throws IFException;
  
-     //group: for reference areas and explicit content grouping
-     void startGroup(AffineTransform transform);
-     void startGroup(AffineTransform[] transforms);
+     void startGroup(AffineTransform[] transforms) throws IFException;
-     //For transform parsing, Batik's 
org.apache.batik.parser.TransformListHandler/Parser can be reused
-     void endViewport();
+     void startGroup(AffineTransform transform) throws IFException;
+     void endGroup() throws IFException;
  
-     void setFont(String family, String style, Integer weight, String variant, 
Integer size, String color);
+     void setFont(String family, String style, Integer weight, String variant, 
Integer size,
+             Color color) throws IFException;
      //All of setFont()'s parameters can be null if no state change is 
necessary
-     void drawText(int x, int y, int[] dx, int[] dy, String text);
+     void drawText(int x, int y, int[] dx, int[] dy, String text) throws 
IFException;
-     void drawRect(Rectangle rect, Paint fill, Color stroke);
+ 
+     void clipRect(Rectangle rect) throws IFException;
+     //TODO clipRect() shall be considered temporary until verified with SVG 
and PCL
+ 
+     void fillRect(Rectangle rect, Paint fill) throws IFException;
+     void drawBorderRect(Rectangle rect,
+             BorderProps before, BorderProps after,
+             BorderProps start, BorderProps end) throws IFException;
+     void drawLine(Point start, Point end, int width, Color color, RuleStyle 
style)
+             throws IFException;
-     void drawImage(String uri, Rectangle rect, Map foreignAttributes); 
//external images
+     void drawImage(String uri, Rectangle rect, Map foreignAttributes) throws 
IFException;
-     void drawImage(Document doc, String rootNamespace, Rectangle rect, Map 
foreignAttributes); //used for instream-foreign-objects
+     void drawImage(Document doc, Rectangle rect, Map foreignAttributes)
+                 throws IFException;
  
-     void handleExtensionObject(Object extension);
-     //etc. etc.
  }
  
  public class IFState {
@@ -149, +158 @@

  //additional needed classes
  public class IFSerializer implements IFPainter {
  
-     public IFSerializer(ContentHandler handler) {
+     public IFSerializer() {
      [..]
  
+     public void setResult(Result result) throws IFException {
+     [..]
+ 
-     //convert IFPainter calls to XML (IF-NG)
+     //convert IFDocumentHandler/IFPainter calls to XML (IF-NG)
  }
  
  public class IFParser {
  
-     public void parse(Source src, IFPainter painter, FOUserAgent userAgent)
+     public void parse(Source src, IFDocumentHandler documentHandler, 
FOUserAgent userAgent)
              throws TransformerException {
      [..]
      }
  
-     public ContentHandler getContentHandler(IFPainter painter, FOUserAgent 
userAgent) {
+     public ContentHandler getContentHandler(IFDocumentHandler 
documentHandler, FOUserAgent userAgent) {
      [..]
  
-     //convert SAX stream calls to IFPainter calls
+     //convert SAX stream calls to IFDocumentHandler/IFPainter calls
  
  }
  }}}
  
- Note that the IFPainter should be designed so it is easy to write some kind 
of filter (like !FilteredOutputStream) where implementors can react to certain 
events like startPageContent() so they can add their own content calls (content 
enrichment) for things like barcodes, OMR marks, background images etc.
+ Note that IFDocumentHandler and IFPainter should be designed so it is easy to 
write some kind of filter (like !FilteredOutputStream) where implementors can 
react to certain events like startPageContent() so they can add their own 
content calls (content enrichment) for things like barcodes, OMR marks, 
background images etc. This can be done in Java on the interface or in XML 
using XSLT.
  
  === Performance evaluation compared to previous approach ===
  
@@ -265, +277 @@

  
   * [done] Check usage of PPML in this context. (Result: Wouldn't really help 
in this context but the resemblance of the basic structure to the new IF is 
remarkable.)
   * [OPEN] Don't forget different writing modes
-  * [OPEN] Decide whether to split IFPainter into IF!DocumentHandler and 
IFPainter to reduce the number of methods per interface.
+  * [done] Decide whether to split IFPainter into IF!DocumentHandler and 
IFPainter to reduce the number of methods per interface. Result: Split 
performed. Expected improvements realized.
   * [OPEN] Deprecate the renderers that have been replaced by respective 
painter implementations once they are stable.
  
  == Comments ==

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to