[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...
Norman Richards
norman.richards at jboss.com
Sun Dec 31 01:50:06 EST 2006
User: nrichards
Date: 06/12/31 01:50:06
Modified: src/pdf/org/jboss/seam/pdf/ui ITextComponent.java
UICell.java UITable.java
Log:
improved tables
Revision Changes Path
1.3 +7 -10 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ITextComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ITextComponent.java 25 Dec 2006 16:17:54 -0000 1.2
+++ ITextComponent.java 31 Dec 2006 06:50:05 -0000 1.3
@@ -2,20 +2,15 @@
import javax.faces.*;
-import javax.faces.event.*;
import javax.faces.context.*;
-import javax.faces.convert.*;
import javax.faces.component.*;
-import javax.servlet.http.*;
-
-import java.awt.Color;
import java.io.*;
import java.util.List;
+import org.jboss.seam.pdf.ITextUtils;
import org.jboss.seam.ui.JSF;
import com.lowagie.text.*;
-import com.lowagie.text.pdf.*;
public abstract class ITextComponent
extends UIComponentBase
@@ -134,6 +129,7 @@
removeITextObject();
}
+ @SuppressWarnings("unchecked")
@Override
public void encodeChildren(FacesContext context)
throws IOException
@@ -143,12 +139,13 @@
if (child.getFamily().equals("facelets.LiteralText")) {
String text = replaceEntities(extractText(context, child));
Font font = getFont();
+ Chunk chunk = null;
if (font == null) {
- Chunk chunk = new Chunk(text);
- add(chunk);
+ chunk = new Chunk(text);
} else {
- add(new Chunk(text, getFont()));
+ chunk = new Chunk(text, getFont());
}
+ add(chunk);
} else {
encode(context, child);
}
1.3 +107 -12 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UICell.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UICell.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UICell.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UICell.java 26 Dec 2006 06:12:56 -0000 1.2
+++ UICell.java 31 Dec 2006 06:50:05 -0000 1.3
@@ -2,16 +2,11 @@
import org.jboss.seam.pdf.ITextUtils;
-import javax.faces.event.*;
-import javax.faces.context.*;
-import javax.faces.component.*;
-import javax.servlet.http.*;
-
-import java.io.*;
-
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
+import java.awt.Color;
+
public class UICell
extends ITextComponent
{
@@ -20,6 +15,7 @@
PdfPCell cell;
String horizontalAlignment;
String verticalAlignment;
+ Float padding;
Float paddingLeft;
Float paddingRight;
Float paddingTop;
@@ -40,7 +36,42 @@
Integer arabicOptions;
Boolean useAscender;
Integer rotation;
+ Color borderColor;
+ Color borderColorLeft;
+ Color borderColorRight;
+ Color borderColorTop;
+ Color borderColorBottom;
+ Color backgroundColor;
+ Float grayFill;
+ Float borderWidth;
+ Float borderWidthLeft;
+ Float borderWidthRight;
+ Float borderWidthTop;
+ Float borderWidthBottom;
+ public void setBorderWidth(Float borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ public void setBorderWidthBottom(Float borderWidthBottom) {
+ this.borderWidthBottom = borderWidthBottom;
+ }
+
+ public void setBorderWidthLeft(Float borderWidthLeft) {
+ this.borderWidthLeft = borderWidthLeft;
+ }
+
+ public void setBorderWidthRight(Float borderWidthRight) {
+ this.borderWidthRight = borderWidthRight;
+ }
+
+ public void setBorderWidthTop(Float borderWidthTop) {
+ this.borderWidthTop = borderWidthTop;
+ }
+
+ public void setGrayFill(Float grayFill) {
+ this.grayFill = grayFill;
+ }
public void setHorizontalAlignment(String horizontalAlignment) {
this.horizontalAlignment = horizontalAlignment;
@@ -50,6 +81,10 @@
this.verticalAlignment = verticalAlignment;
}
+ public void setPadding(Float padding) {
+ this.padding = padding;
+ }
+
public void setPaddingLeft(Float paddingLeft) {
this.paddingLeft = paddingLeft;
}
@@ -130,7 +165,29 @@
this.rotation = rotation;
}
+ public void setBackgroundColor(String backgroundColor) {
+ this.backgroundColor = ITextUtils.colorValue(backgroundColor);
+ }
+ public void setBorderColor(String borderColor) {
+ this.borderColor = ITextUtils.colorValue(borderColor);
+ }
+
+ public void setBorderColorBottom(String borderColorBottom) {
+ this.borderColorBottom = ITextUtils.colorValue(borderColorBottom);
+ }
+
+ public void setBorderColorLeft(String borderColorLeft) {
+ this.borderColorLeft = ITextUtils.colorValue(borderColorLeft) ;
+ }
+
+ public void setBorderColorRight(String borderColorRight) {
+ this.borderColorRight = ITextUtils.colorValue(borderColorRight);
+ }
+
+ public void setBorderColorTop(String borderColorTop) {
+ this.borderColorTop = ITextUtils.colorValue(borderColorTop);
+ }
public Object getITextObject() {
return cell;
@@ -145,11 +202,13 @@
if (horizontalAlignment != null) {
cell.setHorizontalAlignment(ITextUtils.alignmentValue(horizontalAlignment));
- System.out.println("---> " + cell.getHorizontalAlignment());
}
if (verticalAlignment != null) {
cell.setVerticalAlignment(ITextUtils.alignmentValue(verticalAlignment));
}
+ if (padding != null) {
+ cell.setPadding(padding);
+ }
if (paddingLeft != null) {
cell.setPaddingLeft(paddingLeft);
}
@@ -208,7 +267,42 @@
if (rotation != null) {
cell.setRotation(rotation);
}
-
+ if (backgroundColor!=null) {
+ cell.setBackgroundColor(backgroundColor);
+ }
+ if (borderColor!=null) {
+ cell.setBorderColor(borderColor);
+ }
+ if (borderColorLeft!=null) {
+ cell.setBorderColorLeft(borderColorLeft);
+ }
+ if (borderColorRight!=null) {
+ cell.setBorderColorRight(borderColorRight);
+ }
+ if (borderColorTop!=null) {
+ cell.setBorderColorTop(borderColorTop);
+ }
+ if (borderColorBottom!=null) {
+ cell.setBorderColorBottom(borderColorBottom);
+ }
+ if (borderWidth!=null) {
+ cell.setBorderWidth(borderWidth);
+ }
+ if (borderWidthLeft!=null) {
+ cell.setBorderWidthLeft(borderWidthLeft);
+ }
+ if (borderWidthRight!=null) {
+ cell.setBorderWidthRight(borderWidthRight);
+ }
+ if (borderWidthTop!=null) {
+ cell.setBorderWidthTop(borderWidthTop);
+ }
+ if (borderWidthBottom!=null) {
+ cell.setBorderWidthBottom(borderWidthBottom);
+ }
+ if (grayFill!=null) {
+ cell.setGrayFill(grayFill);
+ }
}
public void add(Object o) {
@@ -219,4 +313,5 @@
" to cell");
}
}
+
}
1.2 +139 -13 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UITable.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UITable.java 25 Dec 2006 16:17:54 -0000 1.1
+++ UITable.java 31 Dec 2006 06:50:05 -0000 1.2
@@ -1,11 +1,5 @@
package org.jboss.seam.pdf.ui;
-import javax.faces.event.*;
-import javax.faces.context.*;
-import javax.faces.component.*;
-import javax.servlet.http.*;
-import java.io.*;
-
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
@@ -15,9 +9,27 @@
public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UITable";
PdfPTable table;
+ String widths;
int columns = 1;
Integer headerRows = 0;
Integer footerRows = 0;
+ Float widthPercentage;
+ Integer horizontalAlignment;
+ Boolean skipFirstHeader;
+ Integer runDirection;
+ Boolean lockedWidth;
+ Boolean splitRows;
+ Float spacingBefore;
+ Float spacingAfter;
+ Boolean extendLastRow;
+ Boolean headersInEvent;
+ Boolean splitLate;
+ Boolean keepTogether;
+
+
+ public void setWidths(String Widths) {
+ this.widths = Widths;
+ }
public void setColumns(int columns) {
this.columns = columns;
@@ -31,6 +43,59 @@
this.footerRows = footerRows;
}
+ public void setExtendLastRow(Boolean extendLastRow) {
+ this.extendLastRow = extendLastRow;
+ }
+
+ public void setHeadersInEvent(Boolean headersInEvent) {
+ this.headersInEvent = headersInEvent;
+ }
+
+ public void setHorizontalAlignment(Integer horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public void setKeepTogether(Boolean keepTogether) {
+ this.keepTogether = keepTogether;
+ }
+
+ public void setLockedWidth(Boolean lockedWidth) {
+ this.lockedWidth = lockedWidth;
+ }
+
+ public void setRunDirection(Integer runDirection) {
+ this.runDirection = runDirection;
+ }
+
+ public void setSkipFirstHeader(Boolean skipFirstHeader) {
+ this.skipFirstHeader = skipFirstHeader;
+ }
+
+ public void setSpacingAfter(Float spacingAfter) {
+ this.spacingAfter = spacingAfter;
+ }
+
+ public void setSpacingBefore(Float spacingBefore) {
+ this.spacingBefore = spacingBefore;
+ }
+
+ public void setSplitLate(Boolean splitLate) {
+ this.splitLate = splitLate;
+ }
+
+ public void setSplitRows(Boolean splitRows) {
+ this.splitRows = splitRows;
+ }
+
+ public void setTable(PdfPTable table) {
+ this.table = table;
+ }
+
+ public void setWidthPercentage(Float widthPercentage) {
+ this.widthPercentage = widthPercentage;
+ }
+
+
public Object getITextObject() {
return table;
@@ -42,17 +107,78 @@
public void createITextObject() {
table = new PdfPTable(columns);
+
+ if (widths != null) {
+ try {
+ table.setWidths(stringToFloatArray(widths));
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
if (headerRows != null) {
- table.setHeaderRows(headerRows.intValue());
+ table.setHeaderRows(headerRows);
}
if (footerRows != null) {
- table.setFooterRows(footerRows.intValue());
+ table.setFooterRows(footerRows);
+ }
+ if (widthPercentage!=null) {
+ table.setWidthPercentage(widthPercentage);
+ }
+ if (horizontalAlignment!=null) {
+ table.setHorizontalAlignment(horizontalAlignment);
+ }
+ if (skipFirstHeader!=null) {
+ table.setSkipFirstHeader(skipFirstHeader);
+ }
+ if (runDirection!=null) {
+ table.setRunDirection(runDirection);
}
+ if (lockedWidth!=null) {
+ table.setLockedWidth(lockedWidth);
+ }
+ if (splitRows!=null) {
+ table.setSplitRows(splitRows);
+ }
+ if (spacingBefore!=null) {
+ table.setSpacingBefore(spacingBefore);
+ }
+ if (spacingAfter!=null) {
+ table.setSpacingAfter(spacingAfter);
+ }
+ if (extendLastRow!=null) {
+ table.setExtendLastRow(extendLastRow);
+ }
+ if (headersInEvent!=null) {
+ table.setHeadersInEvent(headersInEvent);
+ }
+ if (splitLate!=null) {
+ table.setSplitLate(splitLate);
+ }
+ if (keepTogether!=null) {
+ table.setKeepTogether(keepTogether);
+ }
+ }
+
+ private float[] stringToFloatArray(String widths) {
+ String[] parts = widths.split("\\s");
+ float[] values = new float[parts.length];
+ for (int i=0;i<parts.length;i++) {
+ values[i] = Float.valueOf(parts[i]);
+ }
+
+ return values;
}
public void add(Object o) {
if (o instanceof PdfPCell) {
table.addCell((PdfPCell) o);
+ } else if (o instanceof PdfPTable) {
+ table.addCell((PdfPTable) o);
+ } else if (o instanceof Phrase) {
+ table.addCell((Phrase) o);
+ } else if (o instanceof Image) {
+ table.addCell((Image) o);
} else {
throw new RuntimeException("Can't add " + o.getClass().getName() +
" to table");
More information about the jboss-cvs-commits
mailing list