aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/intermediate
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render/intermediate')
-rw-r--r--src/java/org/apache/fop/render/intermediate/BorderPainter.java7
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFConstants.java1
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFPainter.java21
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFParser.java25
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFRenderer.java30
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFSerializer.java33
6 files changed, 97 insertions, 20 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/BorderPainter.java b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
index fdde321a9..e8874dc69 100644
--- a/src/java/org/apache/fop/render/intermediate/BorderPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
@@ -20,9 +20,11 @@
package org.apache.fop.render.intermediate;
import java.awt.Color;
+import java.awt.Point;
import java.awt.Rectangle;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
/**
* This is an abstract base class for handling border painting.
@@ -198,7 +200,10 @@ public abstract class BorderPainter {
protected abstract void drawBorderLine(int x1, int y1, int x2, int y2,
- boolean horz, boolean startOrBefore, int style, Color col);
+ boolean horz, boolean startOrBefore, int style, Color color);
+
+ public abstract void drawLine(Point start, Point end,
+ int width, Color color, RuleStyle style);
protected abstract void moveTo(int x, int y);
diff --git a/src/java/org/apache/fop/render/intermediate/IFConstants.java b/src/java/org/apache/fop/render/intermediate/IFConstants.java
index f101ad363..e7f7e1a00 100644
--- a/src/java/org/apache/fop/render/intermediate/IFConstants.java
+++ b/src/java/org/apache/fop/render/intermediate/IFConstants.java
@@ -46,6 +46,7 @@ public interface IFConstants extends XMLConstants {
String EL_IMAGE = "image";
String EL_CLIP_RECT = "clip-rect";
String EL_RECT = "rect";
+ String EL_LINE = "line";
String EL_BORDER_RECT = "border-rect";
String EL_FONT = "font";
String EL_TEXT = "text";
diff --git a/src/java/org/apache/fop/render/intermediate/IFPainter.java b/src/java/org/apache/fop/render/intermediate/IFPainter.java
index 4722a02ac..b354510f8 100644
--- a/src/java/org/apache/fop/render/intermediate/IFPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/IFPainter.java
@@ -22,6 +22,7 @@ package org.apache.fop.render.intermediate;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Paint;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.util.Map;
@@ -33,6 +34,7 @@ import org.w3c.dom.Document;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
/**
* Interface used to paint whole documents layouted by Apache FOP.
@@ -277,13 +279,12 @@ public interface IFPainter {
//TODO clipRect() shall be considered temporary until verified with SVG and PCL
/**
- * Draws a rectangle. Either fill or stroke has to be specified.
+ * Fills a rectangular area.
* @param rect the rectangle's coordinates and extent
- * @param fill the fill paint (may be null)
- * @param stroke the stroke color (may be null)
+ * @param fill the fill paint
* @throws IFException if an error occurs while handling this event
*/
- void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException;
+ void fillRect(Rectangle rect, Paint fill) throws IFException;
/**
* Draws a border rectangle. The border segments are specified through {@code BorderProps}
@@ -300,6 +301,18 @@ public interface IFPainter {
BorderProps start, BorderProps end) throws IFException;
/**
+ * Draws a line. NOTE: Currently, only horizontal lines are implemented!
+ * @param start the start point of the line
+ * @param end the end point of the line
+ * @param width the line width
+ * @param color the line color
+ * @param style the line style (using the Constants.EN_* constants for the rule-style property)
+ * @throws IFException if an error occurs while handling this event
+ */
+ void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+ throws IFException;
+
+ /**
* Draws an image identified by a URI inside a given rectangle. This is the equivalent to
* an fo:external-graphic in XSL-FO.
* @param uri the image's URI
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java
index 50c061ff4..cc125a6f7 100644
--- a/src/java/org/apache/fop/render/intermediate/IFParser.java
+++ b/src/java/org/apache/fop/render/intermediate/IFParser.java
@@ -21,6 +21,7 @@ package org.apache.fop.render.intermediate;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.util.Map;
@@ -50,6 +51,7 @@ import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
import org.apache.fop.util.ColorUtil;
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactoryRegistry;
@@ -138,6 +140,7 @@ public class IFParser implements IFConstants {
elementHandlers.put(EL_TEXT, new TextHandler());
elementHandlers.put(EL_CLIP_RECT, new ClipRectHandler());
elementHandlers.put(EL_RECT, new RectHandler());
+ elementHandlers.put(EL_LINE, new LineHandler());
elementHandlers.put(EL_BORDER_RECT, new BorderRectHandler());
elementHandlers.put(EL_IMAGE, new ImageHandler());
}
@@ -467,13 +470,27 @@ public class IFParser implements IFConstants {
} catch (PropertyException pe) {
throw new IFException("Error parsing the fill attribute", pe);
}
- Color strokeColor;
+ painter.fillRect(new Rectangle(x, y, width, height), fillColor);
+ }
+
+ }
+
+ private class LineHandler extends AbstractElementHandler {
+
+ public void startElement(Attributes attributes) throws IFException {
+ int x1 = Integer.parseInt(attributes.getValue("x1"));
+ int y1 = Integer.parseInt(attributes.getValue("y1"));
+ int x2 = Integer.parseInt(attributes.getValue("x2"));
+ int y2 = Integer.parseInt(attributes.getValue("y2"));
+ int width = Integer.parseInt(attributes.getValue("stroke-width"));
+ Color color;
try {
- strokeColor = getAttributeAsColor(attributes, "stroke");
+ color = getAttributeAsColor(attributes, "color");
} catch (PropertyException pe) {
- throw new IFException("Error parsing the stroke attribute", pe);
+ throw new IFException("Error parsing the fill attribute", pe);
}
- painter.drawRect(new Rectangle(x, y, width, height), fillColor, strokeColor);
+ RuleStyle style = RuleStyle.valueOf(attributes.getValue("style"));
+ painter.drawLine(new Point(x1, y1), new Point(x2, y2), width, color, style);
}
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index 0b74987b5..1ea3f9592 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -67,6 +67,7 @@ import org.apache.fop.area.inline.AbstractTextArea;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.Viewport;
@@ -87,6 +88,7 @@ import org.apache.fop.render.intermediate.extensions.GoToXYAction;
import org.apache.fop.render.intermediate.extensions.NamedDestination;
import org.apache.fop.render.pdf.PDFEventProducer;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
/**
* This renderer implementation is an adapter to the {@code IFPainter} interface. It is used
@@ -993,6 +995,30 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
}
/** {@inheritDoc} */
+ public void renderLeader(Leader area) {
+ renderInlineAreaBackAndBorders(area);
+
+ int style = area.getRuleStyle();
+ int ruleThickness = area.getRuleThickness();
+ int startx = currentIPPosition + area.getBorderAndPaddingWidthStart();
+ int starty = currentBPPosition + area.getOffset() + (ruleThickness / 2);
+ int endx = currentIPPosition
+ + area.getBorderAndPaddingWidthStart()
+ + area.getIPD();
+ Color col = (Color)area.getTrait(Trait.COLOR);
+
+ Point start = new Point(startx, starty);
+ Point end = new Point(endx, starty);
+ try {
+ painter.drawLine(start, end, ruleThickness, col, RuleStyle.valueOf(style));
+ } catch (IFException ife) {
+ handleIFException(ife);
+ }
+
+ super.renderLeader(area);
+ }
+
+ /** {@inheritDoc} */
protected void clip() {
throw new IllegalStateException("Not used");
}
@@ -1048,9 +1074,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
/** {@inheritDoc} */
protected void fillRect(float x, float y, float width, float height) {
try {
- painter.drawRect(
+ painter.fillRect(
toMillipointRectangle(x, y, width, height),
- this.graphicContext.getPaint(), null);
+ this.graphicContext.getPaint());
} catch (IFException e) {
handleIFException(e);
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
index 4eb7f0713..20db35c6a 100644
--- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
@@ -22,6 +22,7 @@ package org.apache.fop.render.intermediate;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Paint;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.util.Iterator;
@@ -37,6 +38,7 @@ import org.apache.xmlgraphics.util.XMLizable;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.RuleStyle;
import org.apache.fop.util.ColorUtil;
import org.apache.fop.util.DOM2SAX;
import org.apache.fop.util.XMLUtil;
@@ -364,8 +366,8 @@ public class IFSerializer extends AbstractXMLWritingIFPainter implements IFConst
}
/** {@inheritDoc} */
- public void drawRect(Rectangle rect, Paint fill, Color stroke) throws IFException {
- if (fill == null && stroke == null) {
+ public void fillRect(Rectangle rect, Paint fill) throws IFException {
+ if (fill == null) {
return;
}
try {
@@ -374,15 +376,10 @@ public class IFSerializer extends AbstractXMLWritingIFPainter implements IFConst
addAttribute(atts, "y", Integer.toString(rect.y));
addAttribute(atts, "width", Integer.toString(rect.width));
addAttribute(atts, "height", Integer.toString(rect.height));
- if (fill != null) {
- addAttribute(atts, "fill", toString(fill));
- }
- if (stroke != null) {
- addAttribute(atts, "stroke", toString(stroke));
- }
+ addAttribute(atts, "fill", toString(fill));
element(EL_RECT, atts);
} catch (SAXException e) {
- throw new IFException("SAX error in drawRect()", e);
+ throw new IFException("SAX error in fillRect()", e);
}
}
@@ -417,6 +414,24 @@ public class IFSerializer extends AbstractXMLWritingIFPainter implements IFConst
}
/** {@inheritDoc} */
+ public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
+ throws IFException {
+ try {
+ AttributesImpl atts = new AttributesImpl();
+ addAttribute(atts, "x1", Integer.toString(start.x));
+ addAttribute(atts, "y1", Integer.toString(start.y));
+ addAttribute(atts, "x2", Integer.toString(end.x));
+ addAttribute(atts, "y2", Integer.toString(end.y));
+ addAttribute(atts, "stroke-width", Integer.toString(width));
+ addAttribute(atts, "color", Integer.toString(width));
+ addAttribute(atts, "style", style.getName());
+ element(EL_LINE, atts);
+ } catch (SAXException e) {
+ throw new IFException("SAX error in drawLine()", e);
+ }
+ }
+
+ /** {@inheritDoc} */
public void drawText(int x, int y, int[] dx, int[] dy, String text) throws IFException {
try {
AttributesImpl atts = new AttributesImpl();