diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-02-16 10:15:45 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-02-16 10:15:45 +0000 |
commit | 7d80d3db61adb7b58afa6081fc67a0f54b395177 (patch) | |
tree | 7d1644eed4df96c354dba3c03b5804697c966071 /src/java/org/apache/fop/traits | |
parent | 4d22fe218d96ffd1783fd3f4b978ccceae5d15a3 (diff) | |
download | xmlgraphics-fop-7d80d3db61adb7b58afa6081fc67a0f54b395177.tar.gz xmlgraphics-fop-7d80d3db61adb7b58afa6081fc67a0f54b395177.zip |
First step towards collapsing table borders:
- Mode on BorderProps controls painting behaviour.
- Extended toString() on BorderProps
- Painting the borders already works for all three modes (separate, collapsing-inner and collapsing-outer)
- ATM only inner borders are painted.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198432 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/traits')
-rw-r--r-- | src/java/org/apache/fop/traits/BorderProps.java | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java index 0ee763774..34a8d3d3b 100644 --- a/src/java/org/apache/fop/traits/BorderProps.java +++ b/src/java/org/apache/fop/traits/BorderProps.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.apache.fop.traits; import org.apache.fop.datatypes.ColorType; +import org.apache.fop.fo.Constants; import java.io.Serializable; @@ -28,24 +29,81 @@ import java.io.Serializable; */ public class BorderProps implements Serializable { + /** Separate border model */ + public static final int SEPARATE = 0; + /** Collapsing border model, for borders inside a table */ + public static final int COLLAPSE_INNER = 1; + /** Collapsing border model, for borders at the table's outer border */ + public static final int COLLAPSE_OUTER = 2; + + /** Border style (one of EN_*) */ public int style; // Enum for border style - public ColorType color; // Border color - public int width; // Border width + /** Border color */ + public ColorType color; + /** Border width */ + public int width; + /** Border mode (one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER) */ + public int mode; - public BorderProps(int style, int width, ColorType color) { + /** + * Constructs a new BorderProps instance. + * @param style border style (one of EN_*) + * @param width border width + * @param color border color + * @param mode border mode ((one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER) + */ + public BorderProps(int style, int width, ColorType color, int mode) { this.style = style; this.width = width; this.color = color; + this.mode = mode; } + /** + * @param bp the border properties or null + * @return the effective width of the clipped part of the border + */ + public static int getClippedWidth(BorderProps bp) { + if ((bp != null) && (bp.mode != SEPARATE)) { + return bp.width / 2; + } else { + return 0; + } + } + + private String getStyleString() { + switch (style) { + case Constants.EN_NONE: return "none"; + case Constants.EN_HIDDEN: return "hidden"; + case Constants.EN_DOTTED: return "dotted"; + case Constants.EN_DASHED: return "dashed"; + case Constants.EN_SOLID: return "solid"; + case Constants.EN_DOUBLE: return "double"; + case Constants.EN_GROOVE: return "groove"; + case Constants.EN_RIDGE: return "ridge"; + case Constants.EN_INSET: return "inset"; + case Constants.EN_OUTSET: return "outset"; + default: throw new IllegalStateException("Illegal border style: " + style); + } + } + + /** @see java.lang.Object#toString() */ public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append('('); - sbuf.append(style); // Should get a String value for this enum constant + sbuf.append(getStyleString()); sbuf.append(','); sbuf.append(color); sbuf.append(','); sbuf.append(width); + if (mode != SEPARATE) { + sbuf.append(','); + if (mode == COLLAPSE_INNER) { + sbuf.append("collapse-inner"); + } else { + sbuf.append("collapse-outer"); + } + } sbuf.append(')'); return sbuf.toString(); } |