diff options
author | Keiron Liddle <keiron@apache.org> | 2002-08-22 13:57:49 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-08-22 13:57:49 +0000 |
commit | 68b21a99b13332f92bb896e818e17bc1dc17f74c (patch) | |
tree | f009e115770da2f1daadc027a1175d6623625b9a /src/org | |
parent | 764bcf89165659d00a6a9e026457c1cb15d62186 (diff) | |
download | xmlgraphics-fop-68b21a99b13332f92bb896e818e17bc1dc17f74c.tar.gz xmlgraphics-fop-68b21a99b13332f92bb896e818e17bc1dc17f74c.zip |
implemeneted leader with leader-pattern of rule
adjusts line area ipd to best fit (spaces not handled yet) and aligns
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195112 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/apache/fop/area/LineArea.java | 14 | ||||
-rw-r--r-- | src/org/apache/fop/area/inline/Leader.java | 10 | ||||
-rw-r--r-- | src/org/apache/fop/area/inline/Stretch.java | 2 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Leader.java | 99 | ||||
-rw-r--r-- | src/org/apache/fop/layoutmgr/BlockLayoutManager.java | 1 | ||||
-rw-r--r-- | src/org/apache/fop/layoutmgr/LayoutContext.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java | 14 | ||||
-rw-r--r-- | src/org/apache/fop/layoutmgr/LineBPLayoutManager.java | 143 | ||||
-rw-r--r-- | src/org/apache/fop/render/AbstractRenderer.java | 3 | ||||
-rw-r--r-- | src/org/apache/fop/render/pdf/PDFRenderer.java | 80 | ||||
-rw-r--r-- | src/org/apache/fop/render/svg/SVGRenderer.java | 13 | ||||
-rw-r--r-- | src/org/apache/fop/render/xml/XMLRenderer.java | 13 | ||||
-rw-r--r-- | src/org/apache/fop/tools/AreaTreeBuilder.java | 13 |
13 files changed, 295 insertions, 121 deletions
diff --git a/src/org/apache/fop/area/LineArea.java b/src/org/apache/fop/area/LineArea.java index fc7771da0..44c8e35d5 100644 --- a/src/org/apache/fop/area/LineArea.java +++ b/src/org/apache/fop/area/LineArea.java @@ -45,9 +45,9 @@ public class LineArea extends Area { } public void addChild(Area childArea) { - if (childArea instanceof InlineArea) { - addInlineArea((InlineArea)childArea); - } + if (childArea instanceof InlineArea) { + addInlineArea((InlineArea)childArea); + } } public void addInlineArea(InlineArea area) { @@ -57,5 +57,13 @@ public class LineArea extends Area { public List getInlineAreas() { return inlineAreas; } + + public void setStartIndent(int si) { + startIndent = si; + } + + public int getStartIndent() { + return startIndent; + } } diff --git a/src/org/apache/fop/area/inline/Leader.java b/src/org/apache/fop/area/inline/Leader.java index 2475cac80..0bc5415a5 100644 --- a/src/org/apache/fop/area/inline/Leader.java +++ b/src/org/apache/fop/area/inline/Leader.java @@ -8,6 +8,7 @@ package org.apache.fop.area.inline; import org.apache.fop.render.Renderer; +import org.apache.fop.fo.properties.RuleStyle; public class Leader extends Stretch { @@ -18,14 +19,7 @@ public class Leader extends Stretch { // if space replaced with a space // otherwise this is a holder for a line - public static final int DOTTED = 0; - public static final int DASHED = 1; - public static final int SOLID = 2; - public static final int DOUBLE = 3; - public static final int GROOVE = 4; - public static final int RIDGE = 5; - - int ruleStyle = SOLID; + int ruleStyle = RuleStyle.SOLID; int ruleThickness = 1000; public Leader() { diff --git a/src/org/apache/fop/area/inline/Stretch.java b/src/org/apache/fop/area/inline/Stretch.java index ed1ba2254..fd173e850 100644 --- a/src/org/apache/fop/area/inline/Stretch.java +++ b/src/org/apache/fop/area/inline/Stretch.java @@ -10,7 +10,7 @@ package org.apache.fop.area.inline; import org.apache.fop.area.MinOptMax; public class Stretch extends InlineArea { - MinOptMax contentIPD; + MinOptMax contentIPD = null; public void setAllocationIPD(MinOptMax mom) { contentIPD = mom; diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java index d4e56a3d1..bf0906f14 100644 --- a/src/org/apache/fop/fo/flow/Leader.java +++ b/src/org/apache/fop/fo/flow/Leader.java @@ -17,6 +17,7 @@ import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.LeafNodeLayoutManager; +import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.area.MinOptMax; import java.util.List; @@ -27,24 +28,39 @@ import java.util.List; * The pattern use-content is ignored, i.e. it still must be implemented. */ public class Leader extends FObjMixed { + int ruleStyle; + int ruleThickness; + int leaderPattern; public Leader(FONode parent) { super(parent); } public void addLayoutManager(List list) { - list.add(new LeafNodeLayoutManager(this) { - public InlineArea get() { - int contentIPD = parentLM.getContentIPD(); - return getInlineArea(contentIPD); - } - }); + LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this) { + public InlineArea get(LayoutContext context) { + int refIPD = context.getRefIPD(); + return getInlineArea(refIPD); + } + }; + lm.setAlignment(properties.get("leader-alignment").getEnum()); + list.add(lm); } - protected InlineArea getInlineArea(int maxIPD) { + protected InlineArea getInlineArea(int refIPD) { + setup(); + org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); - leader.setWidth(maxIPD / 2); - leader.setAllocationIPD(new MinOptMax(0, maxIPD / 2, maxIPD)); + + MinOptMax alloc = getAllocationIPD(refIPD); + leader.setAllocationIPD(alloc); + leader.setWidth(alloc.opt); + + if(leaderPattern == LeaderPattern.RULE) { + leader.setRuleStyle(ruleStyle); + leader.setRuleThickness(ruleThickness); + } + return leader; } @@ -99,40 +115,51 @@ public class Leader extends FObjMixed { // fo:leader specific properties // determines the pattern of leader; allowed values: space, rule,dots, use-content - int leaderPattern = this.properties.get("leader-pattern").getEnum(); - // length of the leader - int leaderLengthOptimum = - this.properties.get("leader-length.optimum").getLength().mvalue(); - int leaderLengthMinimum = - this.properties.get("leader-length.minimum").getLength().mvalue(); - Length maxlength = this.properties.get("leader-length.maximum").getLength(); - int leaderLengthMaximum; - if(maxlength instanceof PercentLength) { - //leaderLengthMaximum = (int)(((PercentLength)maxlength).value() - // * area.getAllocationWidth()); - } else { - leaderLengthMaximum = maxlength.mvalue(); + leaderPattern = this.properties.get("leader-pattern").getEnum(); + switch(leaderPattern) { + case LeaderPattern.SPACE: + // use Space + break; + case LeaderPattern.RULE: + // the following properties only apply + // for leader-pattern = "rule" + ruleThickness = + properties.get("rule-thickness").getLength().mvalue(); + ruleStyle = properties.get("rule-style").getEnum(); + break; + case LeaderPattern.DOTS: + break; + case LeaderPattern.USECONTENT: + // use inline layout manager to create inline areas + // add the inline parent multiple times until leader full + break; } - // the following properties only apply for leader-pattern = "rule" - int ruleThickness = - this.properties.get("rule-thickness").getLength().mvalue(); - int ruleStyle = this.properties.get("rule-style").getEnum(); + // if leaderPatternWidth = 0 = default = use-font-metric int leaderPatternWidth = this.properties.get("leader-pattern-width").getLength().mvalue(); - int leaderAlignment = - this.properties.get("leader-alignment").getEnum(); } - /* - * //should only be necessary for use-content - * protected void addCharacters(char data[], int start, int length) { - * FOText textNode = new FOText(data,start,length, this); - * textNode.setLogger(log); - * children.addElement(textNode); - * } - */ + protected MinOptMax getAllocationIPD(int ipd) { + // length of the leader + int opt = getLength("leader-length.optimum", ipd); + int min = getLength("leader-length.minimum", ipd); + int max = getLength("leader-length.maximum", ipd); + + return new MinOptMax(min, opt, max); + } + protected int getLength(String prop, int dim) { + int length; + Length maxlength = properties.get(prop).getLength(); + if(maxlength instanceof PercentLength) { + length = (int)(((PercentLength)maxlength).value() + * dim); + } else { + length = maxlength.mvalue(); + } + return length; + } } diff --git a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java index 588335171..d43ce8cc1 100644 --- a/src/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -130,6 +130,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { if (curLM.generatesInlineAreas()) { // set stackLimit for lines childLC.setStackLimit(new MinOptMax(ipd/* - m_iIndents - m_iTextIndent*/)); + childLC.setRefIPD(ipd); } else { childLC.setStackLimit( MinOptMax.subtract(context.getStackLimit(), diff --git a/src/org/apache/fop/layoutmgr/LayoutContext.java b/src/org/apache/fop/layoutmgr/LayoutContext.java index d53cd4b23..bc0976fa8 100644 --- a/src/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/org/apache/fop/layoutmgr/LayoutContext.java @@ -67,6 +67,9 @@ public class LayoutContext { private HyphContext m_hyphContext = null; /** Stretch or shrink value when making areas. */ + private double ipdAdjust = 0.0; + + /** Stretch or shrink value when adding spaces. */ private double m_dSpaceAdjust = 0.0; private int m_iLineHeight; @@ -185,6 +188,14 @@ public class LayoutContext { return m_dSpaceAdjust; } + public void setIPDAdjust(double ipdA) { + ipdAdjust = ipdA; + } + + public double getIPDAdjust() { + return ipdAdjust; + } + public void setLineHeight(int lh) { m_iLineHeight = lh; } diff --git a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java index f0a63d2cd..d2c6d42e2 100644 --- a/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LeafNodeLayoutManager.java @@ -28,7 +28,7 @@ public class LeafNodeLayoutManager extends AbstractBPLayoutManager { super(fobj); } - public InlineArea get() { + public InlineArea get(LayoutContext context) { return curArea; } @@ -68,7 +68,7 @@ public class LeafNodeLayoutManager extends AbstractBPLayoutManager { public BreakPoss getNextBreakPoss(LayoutContext context, Position prevBreakPoss) { - curArea = get(); + curArea = get(context); if (curArea == null) { setFinished(true); return null; @@ -128,6 +128,16 @@ public class LeafNodeLayoutManager extends AbstractBPLayoutManager { break; } + double dAdjust = context.getIPDAdjust(); + MinOptMax ipd = curArea.getAllocationIPD(); + int width = ipd.opt; + if(dAdjust < 0) { + width = (int)(width + dAdjust * (ipd.opt - ipd.min)); + } else if(dAdjust > 0) { + width = (int)(width + dAdjust * (ipd.max - ipd.opt)); + } + curArea.setWidth(width); + while (posIter.hasNext()) { posIter.next(); } diff --git a/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java b/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java index f24b94c05..16998de81 100644 --- a/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java +++ b/src/org/apache/fop/layoutmgr/LineBPLayoutManager.java @@ -47,14 +47,18 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { private static class LineBreakPosition extends LeafPosition { // int m_iPos; double m_dAdjust; // Percentage to adjust (stretch or shrink) + double ipdAdjust; // Percentage to adjust (stretch or shrink) + int startIndent; int lineHeight; int baseline; LineBreakPosition(BPLayoutManager lm, int iBreakIndex, - double dAdjust, int lh, int bl) { + double ipdA, double dAdjust, int ind, int lh, int bl) { super(lm, iBreakIndex); // m_iPos = iBreakIndex; + ipdAdjust = ipdA; m_dAdjust = dAdjust; + startIndent = ind; lineHeight = lh; baseline = bl; } @@ -65,7 +69,7 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { private ArrayList m_vecInlineBreaks = new ArrayList(); private BreakPoss m_prevBP = null; // Last confirmed break position - private boolean m_bJustify = false; // True if fo:block text-align=JUSTIFY + private int bTextAlignment = TextAlign.JUSTIFY; private int m_iTextIndent = 0; private int m_iIndents = 0; private HyphenationProps m_hyphProps; @@ -90,7 +94,7 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { MarginProps marginProps = propMgr.getMarginProps(); m_iIndents = marginProps.startIndent + marginProps.endIndent; BlockProps blockProps = propMgr.getBlockProps(); - m_bJustify = (blockProps.textAlign == TextAlign.JUSTIFY); + bTextAlignment = blockProps.textAlign; m_iTextIndent = blockProps.firstIndent; m_hyphProps = propMgr.getHyphenationProps(); } @@ -177,7 +181,7 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { // This break position doesn't fit // TODO: If we are in nowrap, we use it as is! - if (m_bJustify || m_prevBP == null) { + if (bTextAlignment == TextAlign.JUSTIFY || m_prevBP == null) { // If we are already in a hyphenation loop, then stop. if (inlineLC.tryHyphenate()) { @@ -261,29 +265,15 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { if (bp != m_prevBP && !bp.couldEndLine()) { reset(); } - // Distribute space in the line - MinOptMax actual; - if (bp != m_prevBP) { - MinOptMax mom = getPrevIPD(m_prevBP.getLayoutManager()); - if (mom != null) { - actual = MinOptMax.add(m_prevBP.getStackingSize(), mom); - } else { - actual = m_prevBP.getStackingSize(); - } - } else { - actual = m_prevBP.getStackingSize(); - } - // ATTENTION: make sure this hasn't gotten start space for next - // LM added onto it! - actual.add(m_prevBP.resolveTrailingSpace(true)); - //log.error("Target opt=" + availIPD.opt + " bp.opt=" + - // actual.opt + " bp.max=" + actual.max + " bm.min=" + - // actual.min); // Don't justify last line in the sequence or if forced line-end - boolean bJustify = (m_bJustify && !m_prevBP.isForcedBreak() && - !isFinished()); - return makeLineBreak(iPrevLineEnd, availIPD, actual, bJustify); + int talign = bTextAlignment; + if((bTextAlignment == TextAlign.JUSTIFY + && (m_prevBP.isForcedBreak() + || isFinished()))) { + talign = TextAlign.START; + } + return makeLineBreak(iPrevLineEnd, availIPD, talign); } @@ -399,23 +389,9 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { private BreakPoss makeLineBreak(int prevLineEnd, MinOptMax target, - MinOptMax actual, boolean bJustify) { + int textalign) { // make a new BP // Store information needed to make areas in the LineBreakPosition! - // Calculate stretch or shrink factor - - double dAdjust = 0.0; - if (bJustify) { - if (actual.opt < target.opt) { - // Stretch - dAdjust = (double)(target.opt - actual.opt) / - (double)(actual.max - actual.opt); - } else { - // Shrink - dAdjust = (double)(target.opt - actual.opt) / - (double)(actual.opt - actual.min); - } - } // lead to baseline is // max of: baseline fixed alignment and middle/2 @@ -428,6 +404,11 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { int maxtb = follow + halfLeading; // max size of middle alignment below baseline int middlefollow = maxtb; + + // calculate actual ipd + MinOptMax actual = new MinOptMax(); + BreakPoss lastBP = null; + LayoutManager lastLM = null; for(Iterator iter = m_vecInlineBreaks.listIterator(prevLineEnd); iter.hasNext(); ) { BreakPoss bp = (BreakPoss)iter.next(); @@ -439,15 +420,87 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { } if(bp.getMiddle() > middlefollow) { middlefollow = bp.getMiddle(); - } + } + + // the stacking size of textLM accumulate for each break + // so the ipd is only added at the end of each LM + if(bp.getLayoutManager() != lastLM) { + if(lastLM != null) { + actual.add(lastBP.getStackingSize()); + } + lastLM = bp.getLayoutManager(); + } + lastBP = bp; + } + if(lastBP != null) { + // add final ipd + actual.add(lastBP.getStackingSize()); + // ATTENTION: make sure this hasn't gotten start space for next + // LM added onto it! + actual.add(lastBP.resolveTrailingSpace(true)); } + if(maxtb - lineLead > middlefollow) { middlefollow = maxtb - lineLead; } - //log.debug("Adjustment factor=" + dAdjust); - BreakPoss curLineBP = new BreakPoss( new LineBreakPosition(this, - m_vecInlineBreaks.size() - 1, dAdjust, lineLead + middlefollow, lineLead)); + // in 7.21.4 the spec suggests that the leader and other + // similar min/opt/max areas should be adjusted before + // adjusting word spacing + + // Calculate stretch or shrink factor + double ipdAdjust = 0; + int targetWith = target.opt; + int realWidth = actual.opt; + if (actual.opt > targetWith) { + if (actual.opt - targetWith < + (actual.opt - actual.min)) { + ipdAdjust = -(actual.opt - targetWith) / + (float)(actual.opt - actual.min); + realWidth = targetWith; + } else { + ipdAdjust = -1; + realWidth = actual.max; + } + } else { + if (targetWith - actual.opt < + actual.max - actual.opt) { + ipdAdjust = (targetWith - actual.opt) / + (float)(actual.max - actual.opt); + realWidth = targetWith; + } else { + ipdAdjust = 1; + realWidth = actual.min; + } + } + + // if justifying then set the space adjustment + // after the normal ipd adjustment + double dAdjust = 0.0; + int indent = 0; + switch (textalign) { + case TextAlign.JUSTIFY: + if(realWidth != 0) { + dAdjust = (targetWith - realWidth) / realWidth; + } + break; + case TextAlign.START: + //indent = 0; + break; + case TextAlign.CENTER: + indent = (targetWith - realWidth) / 2; + break; + case TextAlign.END: + indent = targetWith - realWidth; + break; + } + + LineBreakPosition lbp; + lbp = new LineBreakPosition(this, + m_vecInlineBreaks.size() - 1, + ipdAdjust, dAdjust, indent, + lineLead + middlefollow, lineLead); + BreakPoss curLineBP = new BreakPoss(lbp); curLineBP.setFlag(BreakPoss.ISLAST, isFinished()); curLineBP.setStackingSize(new MinOptMax(lineLead + middlefollow)); @@ -488,6 +541,7 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { while (parentIter.hasNext()) { LineBreakPosition lbp = (LineBreakPosition) parentIter.next(); LineArea lineArea = new LineArea(); + lineArea.setStartIndent(lbp.startIndent); lineArea.setHeight(lbp.lineHeight); lc.setBaseline(lbp.baseline); lc.setLineHeight(lbp.lineHeight); @@ -498,6 +552,7 @@ public class LineBPLayoutManager extends InlineStackingBPLayoutManager { lbp.getLeafPos() + 1); iStartPos = lbp.getLeafPos() + 1; lc.setSpaceAdjust(lbp.m_dAdjust); + lc.setIPDAdjust(lbp.ipdAdjust); lc.setLeadingSpace(new SpaceSpecifier(true)); lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true); setChildContext(lc); diff --git a/src/org/apache/fop/render/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java index e6cd863cc..2075a4fd1 100644 --- a/src/org/apache/fop/render/AbstractRenderer.java +++ b/src/org/apache/fop/render/AbstractRenderer.java @@ -320,7 +320,8 @@ public abstract class AbstractRenderer extends AbstractLogEnabled implements Ren // a line area is rendered from the top left position // of the line, each inline object is offset from there LineArea line = (LineArea) obj; - currentBlockIPPosition = currentIPPosition; + currentBlockIPPosition = currentIPPosition + + line.getStartIndent(); renderLineArea(line); currentBPPosition += line.getHeight(); } diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index d3b0ddccd..c7059f21c 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -618,15 +618,79 @@ public class PDFRenderer extends PrintRenderer { } public void renderLeader(Leader area) { + closeText(); currentStream.add("ET\n"); - currentStream.add((((float) currentBlockIPPosition) / 1000f) + - " " + ((currentBPPosition + area.getOffset()) / - 1000f) + " m\n"); - currentStream.add( - ((currentBlockIPPosition + area.getWidth()) / 1000f) + - " " + ((currentBPPosition + area.getOffset()) / - 1000f) + " l\n"); - currentStream.add("S\n"); + currentStream.add("q\n"); + int style = area.getRuleStyle(); + boolean alt = false; + switch(style) { + case RuleStyle.SOLID: + currentStream.add("[] 0 d\n"); + break; + case RuleStyle.DOTTED: + currentStream.add("[2] 0 d\n"); + break; + case RuleStyle.DASHED: + currentStream.add("[6 4] 0 d\n"); + break; + case RuleStyle.DOUBLE: + case RuleStyle.GROOVE: + case RuleStyle.RIDGE: + alt = true; + break; + } + float startx = ((float) currentBlockIPPosition) / 1000f; + float starty = ((currentBPPosition + area.getOffset()) / 1000f); + float endx = (currentBlockIPPosition + area.getWidth()) / 1000f; + if(!alt) { + currentStream.add(area.getRuleThickness() / 1000f + " w\n"); + + currentStream.add(startx + " " + starty + " m\n"); + currentStream.add(endx + " " + starty + " l\n"); + currentStream.add("S\n"); + } else { + if(style == RuleStyle.DOUBLE) { + float third = area.getRuleThickness() / 3000f; + currentStream.add(third + " w\n"); + currentStream.add(startx + " " + starty + " m\n"); + currentStream.add(endx + " " + starty + " l\n"); + currentStream.add("S\n"); + + currentStream.add(startx + " " + (starty + 2 * third) + " m\n"); + currentStream.add(endx + " " + (starty + 2 * third) + " l\n"); + currentStream.add("S\n"); + } else { + float half = area.getRuleThickness() / 2000f; + + currentStream.add("1 g\n"); + currentStream.add(startx + " " + starty + " m\n"); + currentStream.add(endx + " " + starty + " l\n"); + currentStream.add(endx + " " + (starty + 2 * half) + " l\n"); + currentStream.add(startx + " " + (starty + 2 * half) + " l\n"); + currentStream.add("h\n"); + currentStream.add("f\n"); + if(style == RuleStyle.GROOVE) { + currentStream.add("0 g\n"); + currentStream.add(startx + " " + starty + " m\n"); + currentStream.add(endx + " " + starty + " l\n"); + currentStream.add(endx + " " + (starty + half) + " l\n"); + currentStream.add((startx + half) + " " + (starty + half) + " l\n"); + currentStream.add(startx + " " + (starty + 2 * half) + " l\n"); + } else { + currentStream.add("0 g\n"); + currentStream.add(endx + " " + starty + " m\n"); + currentStream.add(endx + " " + (starty + 2 * half) + " l\n"); + currentStream.add(startx + " " + (starty + 2 * half) + " l\n"); + currentStream.add(startx + " " + (starty + half) + " l\n"); + currentStream.add((endx - half) + " " + (starty + half) + " l\n"); + } + currentStream.add("h\n"); + currentStream.add("f\n"); + } + + } + + currentStream.add("Q\n"); currentStream.add("BT\n"); super.renderLeader(area); } diff --git a/src/org/apache/fop/render/svg/SVGRenderer.java b/src/org/apache/fop/render/svg/SVGRenderer.java index 597cf8282..403800c06 100644 --- a/src/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/org/apache/fop/render/svg/SVGRenderer.java @@ -15,6 +15,7 @@ import org.apache.fop.image.*; import org.apache.fop.svg.SVGUtilities; import org.apache.fop.layout.FontInfo; import org.apache.fop.fo.FOUserAgent; +import org.apache.fop.fo.properties.RuleStyle; import org.w3c.dom.Node; import org.w3c.dom.ProcessingInstruction; @@ -316,19 +317,19 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { String style = "stroke:black;stroke-width:" + (area.getRuleThickness() / 1000) + ";"; switch (area.getRuleStyle()) { - case Leader.DOTTED: + case RuleStyle.DOTTED: style += "stroke-dasharray:1,1"; break; - case Leader.DASHED: + case RuleStyle.DASHED: style += "stroke-dasharray:5,1"; break; - case Leader.SOLID: + case RuleStyle.SOLID: break; - case Leader.DOUBLE: + case RuleStyle.DOUBLE: break; - case Leader.GROOVE: + case RuleStyle.GROOVE: break; - case Leader.RIDGE: + case RuleStyle.RIDGE: break; } Element line = SVGUtilities.createLine(svgDocument, diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index 896698110..15ba3c66d 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -20,6 +20,7 @@ import org.apache.fop.fo.properties.LeaderPattern; import org.apache.fop.fo.FOUserAgent; import org.apache.fop.layout.FontInfo; import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.RuleStyle; // Avalon import org.apache.avalon.framework.logger.Logger; @@ -364,21 +365,21 @@ public class XMLRenderer extends AbstractRenderer { public void renderLeader(Leader area) { String style = "solid"; switch (area.getRuleStyle()) { - case Leader.DOTTED: + case RuleStyle.DOTTED: style = "dotted"; break; - case Leader.DASHED: + case RuleStyle.DASHED: style = "dashed"; break; - case Leader.SOLID: + case RuleStyle.SOLID: break; - case Leader.DOUBLE: + case RuleStyle.DOUBLE: style = "double"; break; - case Leader.GROOVE: + case RuleStyle.GROOVE: style = "groove"; break; - case Leader.RIDGE: + case RuleStyle.RIDGE: style = "ridge"; break; } diff --git a/src/org/apache/fop/tools/AreaTreeBuilder.java b/src/org/apache/fop/tools/AreaTreeBuilder.java index 212e7b55b..03e863d1f 100644 --- a/src/org/apache/fop/tools/AreaTreeBuilder.java +++ b/src/org/apache/fop/tools/AreaTreeBuilder.java @@ -20,6 +20,7 @@ import org.apache.fop.layout.FontInfo; import org.apache.fop.layout.FontState; import org.apache.fop.layout.FontMetric; import org.apache.fop.fo.FOUserAgent; +import org.apache.fop.fo.properties.RuleStyle; import org.apache.avalon.framework.logger.ConsoleLogger; import org.apache.avalon.framework.logger.AbstractLogEnabled; @@ -603,17 +604,17 @@ class TreeLoader { Leader leader = new Leader(); String rs = root.getAttribute("ruleStyle"); if ("solid".equals(rs)) { - leader.setRuleStyle(Leader.SOLID); + leader.setRuleStyle(RuleStyle.SOLID); } else if ("dotted".equals(rs)) { - leader.setRuleStyle(Leader.DOTTED); + leader.setRuleStyle(RuleStyle.DOTTED); } else if ("dashed".equals(rs)) { - leader.setRuleStyle(Leader.DASHED); + leader.setRuleStyle(RuleStyle.DASHED); } else if ("double".equals(rs)) { - leader.setRuleStyle(Leader.DOUBLE); + leader.setRuleStyle(RuleStyle.DOUBLE); } else if ("groove".equals(rs)) { - leader.setRuleStyle(Leader.GROOVE); + leader.setRuleStyle(RuleStyle.GROOVE); } else if ("ridge".equals(rs)) { - leader.setRuleStyle(Leader.RIDGE); + leader.setRuleStyle(RuleStyle.RIDGE); } String rt = root.getAttribute("ruleThickness"); int thick = Integer.parseInt(rt); |