jeremias 2005/01/25 04:53:30
Modified: src/java/org/apache/fop/fo/properties
CommonTextDecoration.java
src/java/org/apache/fop/layoutmgr TraitSetter.java
src/java/org/apache/fop/render/pdf PDFRenderer.java
Log:
Get the mark colors for text-decorations right.
Revision Changes Path
1.2 +24 -1
xml-fop/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java
Index: CommonTextDecoration.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommonTextDecoration.java 25 Jan 2005 10:55:46 -0000 1.1
+++ CommonTextDecoration.java 25 Jan 2005 12:53:29 -0000 1.2
@@ -67,6 +67,7 @@
//Parent is checked first
deco = calcTextDecoration(parentList);
}
+ //For rules, see XSL 1.0, chapters 5.5.6 and 7.16.4
List list = pList.get(Constants.PR_TEXT_DECORATION).getList();
Iterator i = list.iterator();
while (i.hasNext()) {
@@ -82,27 +83,33 @@
deco = new CommonTextDecoration();
}
deco.decoration |= UNDERLINE;
+ deco.underColor =
pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_UNDERLINE) {
if (deco != null) {
deco.decoration &= OVERLINE | LINE_THROUGH | BLINK;
+ deco.underColor =
pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_OVERLINE) {
if (deco == null) {
deco = new CommonTextDecoration();
}
deco.decoration |= OVERLINE;
+ deco.overColor =
pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_OVERLINE) {
if (deco != null) {
deco.decoration &= UNDERLINE | LINE_THROUGH | BLINK;
+ deco.overColor =
pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_LINE_THROUGH) {
if (deco == null) {
deco = new CommonTextDecoration();
}
deco.decoration |= LINE_THROUGH;
+ deco.throughColor =
pList.get(Constants.PR_COLOR).getColorType();
} else if (enum == Constants.EN_NO_LINE_THROUGH) {
if (deco != null) {
deco.decoration &= UNDERLINE | OVERLINE | BLINK;
+ deco.throughColor =
pList.get(Constants.PR_COLOR).getColorType();
}
} else if (enum == Constants.EN_BLINK) {
if (deco == null) {
@@ -139,4 +146,20 @@
public boolean isBlinking() {
return (this.decoration & BLINK) != 0;
}
+
+ /** @return the color of the underline mark */
+ public ColorType getUnderlineColor() {
+ return this.underColor;
+ }
+
+ /** @return the color of the overline mark */
+ public ColorType getOverlineColor() {
+ return this.overColor;
+ }
+
+ /** @return the color of the line-through mark */
+ public ColorType getLineThroughColor() {
+ return this.throughColor;
+ }
+
}
1.16 +3 -0
xml-fop/src/java/org/apache/fop/layoutmgr/TraitSetter.java
Index: TraitSetter.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TraitSetter.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TraitSetter.java 25 Jan 2005 12:29:57 -0000 1.15
+++ TraitSetter.java 25 Jan 2005 12:53:29 -0000 1.16
@@ -274,12 +274,15 @@
if (deco != null) {
if (deco.hasUnderline()) {
area.addTrait(Trait.UNDERLINE, Boolean.TRUE);
+ area.addTrait(Trait.UNDERLINE_COLOR,
deco.getUnderlineColor());
}
if (deco.hasOverline()) {
area.addTrait(Trait.OVERLINE, Boolean.TRUE);
+ area.addTrait(Trait.OVERLINE_COLOR, deco.getOverlineColor());
}
if (deco.hasLineThrough()) {
area.addTrait(Trait.LINETHROUGH, Boolean.TRUE);
+ area.addTrait(Trait.LINETHROUGH_COLOR,
deco.getLineThroughColor());
}
if (deco.isBlinking()) {
area.addTrait(Trait.BLINK, Boolean.TRUE);
1.77 +17 -3
xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
Index: PDFRenderer.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- PDFRenderer.java 25 Jan 2005 10:55:47 -0000 1.76
+++ PDFRenderer.java 25 Jan 2005 12:53:29 -0000 1.77
@@ -1067,9 +1067,7 @@
updateFont(name, size, pdf);
ColorType ct = (ColorType) text.getTrait(Trait.COLOR);
- if (ct != null) {
- updateColor(ct, true, pdf);
- }
+ updateColor(ct, true, pdf);
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
@@ -1138,14 +1136,20 @@
updateLineWidth(fs.getDescender() / -8 / 1000f);
float endx = (startx + inline.getIPD()) / 1000f;
if (inline.hasUnderline()) {
+ ColorType ct = (ColorType)
inline.getTrait(Trait.UNDERLINE_COLOR);
+ updateColor(ct, false, null);
float y = baseline - fs.getDescender() / 2;
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
if (inline.hasOverline()) {
+ ColorType ct = (ColorType)
inline.getTrait(Trait.OVERLINE_COLOR);
+ updateColor(ct, false, null);
float y = (float)(baseline - (1.1 * fs.getCapHeight()));
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
if (inline.hasLineThrough()) {
+ ColorType ct = (ColorType)
inline.getTrait(Trait.LINETHROUGH_COLOR);
+ updateColor(ct, false, null);
float y = (float)(baseline - (0.45 * fs.getCapHeight()));
drawLine(startx / 1000f, y / 1000f, endx, y / 1000f);
}
@@ -1228,7 +1232,17 @@
}
}
+ /**
+ * Establishes a new foreground or fill color.
+ * @param col the color to apply (null skips this operation)
+ * @param fill true to set the fill color, false for the foreground color
+ * @param pdf StringBuffer to write the PDF code to, if null, the code is
+ * written to the current stream.
+ */
private void updateColor(ColorType col, boolean fill, StringBuffer pdf) {
+ if (col == null) {
+ return;
+ }
Color newCol = new Color(col.getRed(), col.getGreen(),
col.getBlue());
boolean update = false;
if (fill) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]