* @param bf The before float area
*/
protected void renderBeforeFloat(BeforeFloat bf) {
- List blocks = bf.getBlocks();
+ List blocks = bf.getChildAreas();
if (blocks != null) {
renderBlocks(blocks);
Block sep = bf.getSeparator();
* @param footnote The footnote
*/
protected void renderFootnote(Footnote footnote) {
- List blocks = footnote.getBlocks();
+ List blocks = footnote.getChildAreas();
if (blocks != null) {
Block sep = footnote.getSeparator();
if (sep != null) {
*/
protected void renderFlow(Flow flow) {
// the normal flow reference area contains stacked blocks
- List blocks = flow.getBlocks();
+ List blocks = flow.getChildAreas();
renderBlocks(blocks);
}
protected void renderBlock(Block block) {
List children = block.getChildAreas();
if (children == null) {
+ handleBlockTraits(block);
// simply move position
currentBPPosition += block.getHeight();
} else if (block instanceof BlockViewport) {
int saveBP = currentBPPosition;
if (block.getPositioning() == Block.ABSOLUTE) {
- currentIPPosition += block.getXOffset();
- currentBPPosition += block.getYOffset();
+ currentIPPosition = containingIPPosition + block.getXOffset();
+ currentBPPosition = containingBPPosition + block.getYOffset();
+
+ handleBlockTraits(block);
renderBlocks(children);
currentIPPosition += block.getXOffset();
currentBPPosition += block.getYOffset();
+ handleBlockTraits(block);
+
renderBlocks(children);
// stacked and relative blocks effect stacking
}
}
+ /**
+ * Handle block traits.
+ * This method is called when the correct ip and bp posiiton is
+ * set. This should be overridden to draw border and background
+ * traits for the block area.
+ *
+ * @param block the block area
+ */
+ protected void handleBlockTraits(Block block) {
+ // draw border and background
+ }
+
/**
* Renders a block viewport.
*
currentBPPosition = 0;
startVParea(ctm);
+ handleBlockTraits(bv);
renderBlocks(children);
endVParea();
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Version;
import org.apache.fop.fo.properties.RuleStyle;
-//import org.apache.fop.datatypes.*;
import org.apache.fop.pdf.PDFStream;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFInfo;
import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.FontMetric;
+import org.apache.fop.traits.BorderProps;
import org.w3c.dom.Document;
/**
* the current stream to add PDF commands to
*/
- PDFStream currentStream;
+ protected PDFStream currentStream;
/**
* the current annotation list to add annotations to
*/
- PDFAnnotList currentAnnotList;
+ protected PDFAnnotList currentAnnotList;
/**
* the current page to add annotations to
*/
- PDFPage currentPage;
+ protected PDFPage currentPage;
// drawing state
- PDFState currentState = null;
+ protected PDFState currentState = null;
- PDFColor currentColor;
- String currentFontName = "";
- int currentFontSize = 0;
- int pageHeight;
+ protected PDFColor currentColor;
+ protected String currentFontName = "";
+ protected int currentFontSize = 0;
+ protected int pageHeight;
/**
* true if a TJ command is left to be written
*/
- boolean textOpen = false;
+ protected boolean textOpen = false;
/**
* the previous Y coordinate of the last word written.
* Used to decide if we can draw the next word on the same line.
*/
- int prevWordY = 0;
+ protected int prevWordY = 0;
/**
* the previous X coordinate of the last word written.
* used to calculate how much space between two words
*/
- int prevWordX = 0;
+ protected int prevWordX = 0;
/**
* The width of the previous word. Used to calculate space between
*/
- int prevWordWidth = 0;
+ protected int prevWordWidth = 0;
/**
* reusable word area string buffer to reduce memory usage
super.renderRegion(region);
}
+ protected void handleBlockTraits(Block block) {
+ // draw border and background
+ BorderProps bps = (BorderProps)block.getTrait(Trait.BORDER_BEFORE);
+ if(bps != null) {
+ float startx = ((float) currentBlockIPPosition) / 1000f;
+ float starty = (currentBPPosition / 1000f);
+ float endx = (currentBlockIPPosition + block.getWidth()) / 1000f;
+
+ currentStream.add("ET\n");
+ currentStream.add("q\n");
+
+ currentStream.add(bps.width / 1000f + " w\n");
+
+ currentStream.add(startx + " " + starty + " m\n");
+ currentStream.add(endx + " " + starty + " l\n");
+ currentStream.add("S\n");
+
+ currentStream.add("Q\n");
+ currentStream.add("BT\n");
+ }
+ bps = (BorderProps)block.getTrait(Trait.BORDER_START);
+ if(bps != null) {
+ }
+ bps = (BorderProps)block.getTrait(Trait.BORDER_AFTER);
+ if(bps != null) {
+ }
+ bps = (BorderProps)block.getTrait(Trait.BORDER_END);
+ if(bps != null) {
+ }
+ }
+
protected void renderBlockViewport(BlockViewport bv, List children) {
// clip and position viewport if necessary
// save positions
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
+ String saveFontName = currentFontName;
CTM ctm = bv.getCTM();
ctm = tempctm.multiply(ctm);
startVParea(ctm);
+ handleBlockTraits(bv);
renderBlocks(children);
endVParea();
if (ctm != null) {
startVParea(ctm);
}
+ handleBlockTraits(bv);
renderBlocks(children);
if (ctm != null) {
endVParea();
currentBPPosition = saveBP;
currentBPPosition += (int)(bv.getHeight());
}
+ currentFontName = saveFontName;
}
/**