Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/intermediate/IFSerializer.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/intermediate/IFSerializer.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/intermediate/IFSerializer.java Thu Sep 30 11:51:08 2010 @@ -33,6 +33,7 @@ import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; + import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -471,6 +472,14 @@ public class IFSerializer extends Abstra } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + // TODO Auto-generated method stub + + } + + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -490,7 +499,7 @@ public class IFSerializer extends Abstra /** {...@inheritdoc} */ public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after, - BorderProps start, BorderProps end) throws IFException { + BorderProps start, BorderProps end, Color innerBackgroundColor) throws IFException { if (before == null && after == null && start == null && end == null) { return; } @@ -512,6 +521,12 @@ public class IFSerializer extends Abstra if (end != null) { addAttribute(atts, "end", end.toString()); } + + if (innerBackgroundColor != null) { + addAttribute(atts, "inner-background-color", + ColorUtil.colorToString(innerBackgroundColor)); + } + handler.element(EL_BORDER_RECT, atts); } catch (SAXException e) { throw new IFException("SAX error in drawBorderRect()", e); @@ -775,4 +790,13 @@ public class IFSerializer extends Abstra } } + /** {...@inheritdoc} */ + public boolean isBackgroundRequired(BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) { + return true; + } + + + + }
Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java Thu Sep 30 11:51:08 2010 @@ -26,6 +26,7 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; +import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -315,4 +316,42 @@ public class Java2DBorderPainter extends this.currentPath = null; } + /** {...@inheritdoc} */ + protected void arcTo(double startAngle, double endAngle, int cx, int cy, int width, int height) + throws IOException { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ + protected void changeCoords(double a, double b, double c, double d, double e, double f) { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ + protected void cubicBezierTo(int p1x, int p1y, int p2x, int p2y, int p3x, int p3y) + throws IOException { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ + protected void rotateCoordinates(double angle) throws IOException { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ + protected void scaleCoordinates(float xScale, float yScale) throws IOException { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ + protected void translateCoordinates(int xTranslate, int yTranslate) throws IOException { + // TODO Auto-generated method stub + + } + } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/java2d/Java2DPainter.java Thu Sep 30 11:51:08 2010 @@ -173,6 +173,13 @@ public class Java2DPainter extends Abstr } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + // TODO Auto-generated method stub + + } + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -188,10 +195,10 @@ public class Java2DPainter extends Abstr BorderProps start, BorderProps end) throws IFException { if (before != null || after != null || start != null || end != null) { try { - this.borderPainter.drawBorders(rect, before, after, start, end); - } catch (IOException e) { + this.borderPainter.drawBorders(rect, before, after, start, end, null); + } catch (IFException e) { //Won't happen with Java2D - throw new IllegalStateException("Unexpected I/O error"); + throw new IllegalStateException("Unexpected IF error"); } } } @@ -261,4 +268,6 @@ public class Java2DPainter extends Abstr g2dState.transform(transform); } + + } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pcl/PCLPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pcl/PCLPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pcl/PCLPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pcl/PCLPainter.java Thu Sep 30 11:51:08 2010 @@ -99,7 +99,7 @@ public class PCLPainter extends Abstract /** @return the target resolution */ protected int getResolution() { - int resolution = (int)Math.round(getUserAgent().getTargetResolution()); + int resolution = Math.round(getUserAgent().getTargetResolution()); if (resolution <= 300) { return 300; } else { @@ -182,6 +182,14 @@ public class PCLPainter extends Abstract } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + //PCL cannot clip (only HP GL/2 can) + //If you need clipping support, switch to RenderingMode.BITMAP. + + } + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -209,7 +217,7 @@ public class PCLPainter extends Abstract final BorderProps before, final BorderProps after, final BorderProps start, final BorderProps end) throws IFException { if (isSpeedOptimized()) { - super.drawBorderRect(rect, before, after, start, end); + super.drawBorderRect(rect, before, after, start, end, null); return; } if (before != null || after != null || start != null || end != null) { @@ -529,4 +537,6 @@ public class PCLPainter extends Abstract gen.setCursorPos(transPoint.getX(), transPoint.getY()); } + + } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java Thu Sep 30 11:51:08 2010 @@ -22,6 +22,7 @@ package org.apache.fop.render.pdf; import java.awt.Color; import java.awt.Point; import java.awt.Rectangle; +import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,6 +54,7 @@ public class PDFBorderPainter extends Bo protected void drawBorderLine( // CSOK: ParameterNumber int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color col) { + //TODO lose scale? drawBorderLine(generator, x1 / 1000f, y1 / 1000f, x2 / 1000f, y2 / 1000f, horz, startOrBefore, style, col); } @@ -68,11 +70,12 @@ public class PDFBorderPainter extends Bo float colFactor; float w = x2 - x1; float h = y2 - y1; + /* if ((w < 0) || (h < 0)) { LOG.error("Negative extent received (w=" + w + ", h=" + h + "). Border won't be painted."); return; - } + }*/ switch (style) { case Constants.EN_DASHED: generator.setColor(col, false); @@ -291,6 +294,7 @@ public class PDFBorderPainter extends Bo } static final String format(int coordinate) { + //TODO lose scale? return format(coordinate / 1000f); } @@ -328,4 +332,38 @@ public class PDFBorderPainter extends Bo generator.add("Q\n"); } + /** {...@inheritdoc} */ + protected void cubicBezierTo(int p1x, int p1y, int p2x, int p2y, int p3x, int p3y) { + generator.add(format(p1x) + " " + format(p1y) + " " + format(p2x) + " " + format(p2y) + + " " + format(p3x) + " " + format(p3y) + " c "); + } + + + private void transformCoordinates(int a, int b, int c, int d, int e, int f) { + generator.add( "" + format(a) + " " + format(b) + " " + format(c) + " " + format(d) + + " " + format(e) + " " + format(f) + " cm "); + } + + private void transformCoordinates2(float a, float b, float c, float d, float e, float f) { + generator.add( "" + format(a) + " " + format(b) + " " + format(c) + " " + format(d) + + " " + format(e) + " " + format(f) + " cm "); + } + + /** {...@inheritdoc} */ + protected void rotateCoordinates(double angle) throws IOException { + float s = (float)Math.sin(angle); + float c = (float)Math.cos(angle); + transformCoordinates2(c, s, -s, c, 0, 0); + } + + /** {...@inheritdoc} */ + protected void translateCoordinates(int xTranslate, int yTranslate) throws IOException { + transformCoordinates(1000, 0, 0, 1000, xTranslate, yTranslate); + } + + /** {...@inheritdoc} */ + protected void scaleCoordinates(float xScale, float yScale) throws IOException { + transformCoordinates2(xScale, 0, 0, yScale, 0, 0); + } + } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/pdf/PDFPainter.java Thu Sep 30 11:51:08 2010 @@ -224,6 +224,20 @@ public class PDFPainter extends Abstract } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + + try { + borderPainter.clipBackground(rect, + bpsBefore, bpsAfter, bpsStart, bpsEnd); + } catch (IOException ioe) { + throw new IFException("I/O error while clipping background", ioe); + } + + } + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -256,17 +270,21 @@ public class PDFPainter extends Abstract /** {...@inheritdoc} */ public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after, - BorderProps start, BorderProps end) throws IFException { + BorderProps start, BorderProps end, Color innerBackgroundColor) throws IFException { if (before != null || after != null || start != null || end != null) { generator.endTextObject(); try { - this.borderPainter.drawBorders(rect, before, after, start, end); - } catch (IOException ioe) { - throw new IFException("I/O error while drawing borders", ioe); + this.borderPainter.drawBorders(rect, before, after, start, end, + innerBackgroundColor); + } catch (IFException ioe) { + throw new IFException("IF error while drawing borders", ioe); } } } + + + /** {...@inheritdoc} */ public void drawLine(Point start, Point end, int width, Color color, RuleStyle style) throws IFException { Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSBorderPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSBorderPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSBorderPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSBorderPainter.java Thu Sep 30 11:51:08 2010 @@ -327,4 +327,58 @@ public class PSBorderPainter extends Bor generator.restoreGraphicsState(); } + + + + /** {...@inheritdoc} */ + protected void cubicBezierTo(int p1x, int p1y, int p2x, int p2y, int p3x, int p3y) + throws IOException { + StringBuffer sb = new StringBuffer(); + sb.append(generator.formatDouble(toPoints(p1x))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(p1y))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(p2x))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(p2y))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(p3x))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(p3y))); + sb.append(" curveto "); + generator.writeln(sb.toString()); + + } + + /** {...@inheritdoc} */ + protected void rotateCoordinates(double angle) throws IOException { + StringBuffer sb = new StringBuffer(); + sb.append(generator.formatDouble(angle * 180d / Math.PI)); + sb.append(" "); + sb.append(" rotate "); + generator.writeln(sb.toString()); + } + + /** {...@inheritdoc} */ + protected void translateCoordinates(int xTranslate, int yTranslate) throws IOException { + StringBuffer sb = new StringBuffer(); + sb.append(generator.formatDouble(toPoints(xTranslate))); + sb.append(" "); + sb.append(generator.formatDouble(toPoints(yTranslate))); + sb.append(" "); + sb.append(" translate "); + generator.writeln(sb.toString()); + } + + /** {...@inheritdoc} */ + protected void scaleCoordinates(float xScale, float yScale) throws IOException { + StringBuffer sb = new StringBuffer(); + sb.append(generator.formatDouble(xScale)); + sb.append(" "); + sb.append(generator.formatDouble(yScale)); + sb.append(" "); + sb.append(" scale "); + generator.writeln(sb.toString()); + } + } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/render/ps/PSPainter.java Thu Sep 30 11:51:08 2010 @@ -209,6 +209,20 @@ public class PSPainter extends AbstractI } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, + BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + + try { + borderPainter.clipBackground(rect, + bpsBefore, bpsAfter, bpsStart, bpsEnd); + } catch (IOException ioe) { + throw new IFException("I/O error while clipping background", ioe); + } + + } + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -235,11 +249,12 @@ public class PSPainter extends AbstractI /** {...@inheritdoc} */ public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after, - BorderProps start, BorderProps end) throws IFException { + BorderProps start, BorderProps end, Color innerBackgroundColor) throws IFException { if (before != null || after != null || start != null || end != null) { try { endTextObject(); - this.borderPainter.drawBorders(rect, before, after, start, end); + this.borderPainter.drawBorders(rect, before, after, start, end, + innerBackgroundColor); } catch (IOException ioe) { throw new IFException("I/O error in drawBorderRect()", ioe); } Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/traits/BorderProps.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/traits/BorderProps.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/traits/BorderProps.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/java/org/apache/fop/traits/BorderProps.java Thu Sep 30 11:51:08 2010 @@ -47,6 +47,12 @@ public class BorderProps implements Seri public Color color; // CSOK: VisibilityModifier /** Border width */ public int width; // CSOK: VisibilityModifier + + private int radiusStart = 0; + private int radiusEnd = 0; + + + /** Border mode (one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER) */ public int mode; // CSOK: VisibilityModifier @@ -76,6 +82,37 @@ public class BorderProps implements Seri } /** + * + * @return the radius of the corner adjacent to the before or start border + */ + public int getRadiusStart() { + return radiusStart; + } + + /** + * + * @param radiusStart the radius of the corner adjacent to the before or start border + */ + public void setRadiusStart(int radiusStart) { + this.radiusStart = radiusStart; + } + + /** + * @return the radius of the corner adjacent to the after or end border + */ + public int getRadiusEnd() { + return radiusEnd; + } + + /** + * + * @param radiusEnd the radius of the corner adjacent to the after or end border + */ + public void setRadiusEnd(int radiusEnd) { + this.radiusEnd = radiusEnd; + } + + /** * @param bp the border properties or null * @return the effective width of the clipped part of the border */ @@ -112,7 +149,9 @@ public class BorderProps implements Seri return (style == other.style) && color.equals(other.color) && width == other.width - && mode == other.mode; + && mode == other.mode + && radiusStart == other.radiusStart + && radiusEnd == other.radiusEnd; } } return false; @@ -154,7 +193,18 @@ public class BorderProps implements Seri throw new IllegalArgumentException(e.getMessage()); } - return new BorderProps(style, width, c, mode); + BorderProps bp = new BorderProps(style, width, c, mode); + + found = m.find(); + if (found) { + int startRadius = Integer.parseInt(m.group()); + m.find(); + int endRadius = Integer.parseInt(m.group()); + bp.setRadiusStart(startRadius); + bp.setRadiusEnd(endRadius); + } + + return bp; } else { throw new IllegalArgumentException("BorderProps must be surrounded by parentheses"); } @@ -170,12 +220,24 @@ public class BorderProps implements Seri sbuf.append(','); sbuf.append(width); if (mode != SEPARATE) { - sbuf.append(','); if (mode == COLLAPSE_INNER) { - sbuf.append("collapse-inner"); + sbuf.append(",collapse-inner"); } else { - sbuf.append("collapse-outer"); + sbuf.append(",collapse-outer"); + } + } + + if (radiusStart != 0 || radiusEnd != 0) { + if (mode == SEPARATE) { + // Because of the corner radii properties the mode must be set + // so that the parameter index is consistent + sbuf.append(",separate"); } + sbuf.append(','); + sbuf.append(radiusStart); + + sbuf.append(','); + sbuf.append(radiusEnd); } sbuf.append(')'); return sbuf.toString(); Modified: xmlgraphics/fop/branches/Temp_RoundedCorners/src/sandbox/org/apache/fop/render/svg/SVGPainter.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_RoundedCorners/src/sandbox/org/apache/fop/render/svg/SVGPainter.java?rev=1003020&r1=1003019&r2=1003020&view=diff ============================================================================== --- xmlgraphics/fop/branches/Temp_RoundedCorners/src/sandbox/org/apache/fop/render/svg/SVGPainter.java (original) +++ xmlgraphics/fop/branches/Temp_RoundedCorners/src/sandbox/org/apache/fop/render/svg/SVGPainter.java Thu Sep 30 11:51:08 2010 @@ -30,7 +30,6 @@ import java.io.IOException; import java.util.Map; import org.w3c.dom.Document; - import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -268,6 +267,13 @@ public class SVGPainter extends Abstract } /** {...@inheritdoc} */ + public void clipBackground(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, + BorderProps bpsStart, BorderProps bpsEnd) throws IFException { + //TODO Implement me!!! + + } + + /** {...@inheritdoc} */ public void fillRect(Rectangle rect, Paint fill) throws IFException { if (fill == null) { return; @@ -406,4 +412,6 @@ public class SVGPainter extends Abstract } } + + } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
