//this.atModel = new CachedRenderPagesModel(renderer);
areaTree.setTreeModel(atModel);
}
+ /**
+ The following statement triggers virtually all of the processing
+ for this document. The SAX parser fires events that are handled by
+ the appropriate InputHandler object, which means that you will need
+ to look in those objects to see where FOP picks up control of
+ processing again. For Structure Renderers (e.g. MIF & RTF), the SAX
+ events are handled directly. For Layout Renderers (e.g. PDF &
+ PostScript), an FO Tree is built by the FOTreeHandler, which in
+ turn fires events when a PageSequence object is complete. This
+ allows higher-level control objects (such as this class) to work
+ directly with PageSequence objects. See foPageSequenceComplete()
+ where this level of control is implemented.
+ */
parser.parse(source);
if (foInputHandler instanceof FOTreeHandler) {
FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler;
}
}
- public void foPageSequenceComplete (FOTreeEvent event) throws FOPException{
+ /**
+ * Required by the FOTreeListener interface. It handles an
+ * FOTreeEvent that is fired when a PageSequence object has been completed.
+ * @param event the FOTreeEvent that was fired
+ * @throws FOPException for errors in building the PageSequence
+ */
+ public void foPageSequenceComplete (FOTreeEvent event) throws FOPException {
PageSequence pageSeq = event.getPageSequence();
Title title = null;
if (pageSeq.getTitleFO() != null) {
pageSeq.format(areaTree);
}
- public void foDocumentComplete (FOTreeEvent event) throws SAXException{
+ /**
+ * Required by the FOTreeListener interface. It handles an FOTreeEvent that
+ * is fired when the Document has been completely parsed.
+ * @param event the FOTreeEvent that was fired
+ * @throws SAXException for parsing errors
+ */
+ public void foDocumentComplete (FOTreeEvent event) throws SAXException {
//processAreaTree(atModel);
try {
areaTree.endDocument();
renderer.stopRenderer();
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
+ throw new SAXException(ex);
}
}
private PageSequence pageSeq;
+ /**
+ * Constructor captures the object that fired the event.
+ * @param source the Object that fired the event.
+ */
public FOTreeEvent (Object source) {
super(source);
}
+ /**
+ * Sets the PageSequence object for this event.
+ * @param pageSeq the PageSequence object attached to this event.
+ */
public void setPageSequence(PageSequence pageSeq) {
this.pageSeq = pageSeq;
}
+
+ /**
+ * @return the PageSequence object attached to this event.
+ */
public PageSequence getPageSequence () {
return pageSeq;
}
import org.apache.fop.apps.FOPException;
/**
- * An Event used for notification that various stages of the building of an
- * FO tree have been completed. Specifically, these are currently used to
- * notify Driver when a PageSequence has been completed.
+ * An interface for classes that need to handle FOTreeEvent objects as they
+ * are fired.
+ * The key benefit to using this interface is that the implementation can handle
+ * PageSequence objects at a higher level, rather than dealing directly with
+ * a lower-level SAX event.
+ * @see FOTreeEvent
*/
public interface FOTreeListener extends EventListener {
- abstract void foPageSequenceComplete (FOTreeEvent e) throws FOPException;
- abstract void foDocumentComplete (FOTreeEvent e) throws SAXException;
+ /**
+ * Method for handling a completed PageSequence object.
+ * @param e the FOTreeEvent that has been fired
+ * @throws FOPException for invalid input
+ */
+ void foPageSequenceComplete (FOTreeEvent e) throws FOPException;
+
+ /**
+ * Method for handling the end of the document.
+ * @param e the FOTreeEvent that has been fired
+ * @throws SAXException for parsing error
+ */
+ void foDocumentComplete (FOTreeEvent e) throws SAXException;
}