[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...
Norman Richards
norman.richards at jboss.com
Thu Jan 11 00:32:06 EST 2007
User: nrichards
Date: 07/01/11 00:32:06
Modified: src/pdf/org/jboss/seam/pdf/ui ITextComponent.java
UICell.java UIDocument.java UIList.java
Added: src/pdf/org/jboss/seam/pdf/ui UIFooter.java
UIHeader.java UIHeaderFooter.java UIPageNumber.java
UIRectangle.java
Log:
add header/footer, refactor rectangle properties
Revision Changes Path
1.6 +3 -3 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.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ITextComponent.java 2 Jan 2007 03:40:32 -0000 1.5
+++ ITextComponent.java 11 Jan 2007 05:32:06 -0000 1.6
@@ -87,13 +87,13 @@
/**
* find the first parent that is an itext component of a given type
*/
- public ITextComponent findITextParent(UIComponent parent, Class c) {
+ public ITextComponent findITextParent(UIComponent parent, Class<?> c) {
if (parent == null) {
return null;
}
if (parent instanceof ITextComponent) {
- if (c==null || parent.getClass().equals(c)) {
+ if (c==null || c.isAssignableFrom(parent.getClass())) {
return (ITextComponent) parent;
}
}
1.7 +13 -119 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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- UICell.java 3 Jan 2007 19:45:34 -0000 1.6
+++ UICell.java 11 Jan 2007 05:32:06 -0000 1.7
@@ -10,7 +10,7 @@
import javax.faces.context.FacesContext;
public class UICell
- extends ITextComponent
+ extends UIRectangle
{
public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UICell";
@@ -37,39 +37,9 @@
Integer runDirection;
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;
- }
+ Integer rotation;
- public void setBorderWidthTop(Float borderWidthTop) {
- this.borderWidthTop = borderWidthTop;
- }
public void setGrayFill(Float grayFill) {
this.grayFill = grayFill;
@@ -167,30 +137,6 @@
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;
}
@@ -308,70 +254,18 @@
if (useAscender != null) {
cell.setUseAscender(useAscender);
}
- rotation = (Integer) valueBinding(context, "rotation", rotation);
- if (rotation != null) {
- cell.setRotation(rotation);
- }
-
- backgroundColor = (Color) valueBinding(context, "backgroundColor", backgroundColor);
- if (backgroundColor != null) {
- cell.setBackgroundColor(backgroundColor);
- }
-
- borderColor = (Color) valueBinding(context, "borderColor", borderColor);
- if (borderColor != null) {
- cell.setBorderColor(borderColor);
- }
-
- borderColorLeft = (Color) valueBinding(context, "borderColorLeft", borderColorLeft);
- if (borderColorLeft != null) {
- cell.setBorderColorLeft(borderColorLeft);
- }
-
- borderColorRight = (Color) valueBinding(context, "borderColorRight", borderColorRight);
- if (borderColorRight != null) {
- cell.setBorderColorRight(borderColorRight);
- }
-
- borderColorTop = (Color) valueBinding(context, "borderColorTop", borderColorTop);
- if (borderColorTop != null) {
- cell.setBorderColorTop(borderColorTop);
- }
-
- borderColorBottom = (Color) valueBinding(context, "borderColorBottom", borderColorBottom);
- if (borderColorBottom != null) {
- cell.setBorderColorBottom(borderColorBottom);
- }
-
- borderWidth = (Float) valueBinding(context, "borderWidth", borderWidth);
- if (borderWidth != null) {
- cell.setBorderWidth(borderWidth);
- }
-
- borderWidthLeft = (Float) valueBinding(context, "borderWidthLeft", borderWidthLeft);
- if (borderWidthLeft != null) {
- cell.setBorderWidthLeft(borderWidthLeft);
- }
-
- borderWidthRight = (Float) valueBinding(context, "borderWidthRight", borderWidthRight);
- if (borderWidthRight != null) {
- cell.setBorderWidthRight(borderWidthRight);
- }
-
- borderWidthTop = (Float) valueBinding(context, "borderWidthTop", borderWidthTop);
- if (borderWidthTop != null) {
- cell.setBorderWidthTop(borderWidthTop);
- }
-
- borderWidthBottom = (Float) valueBinding(context, "borderWidthBottom", borderWidthBottom);
- if (borderWidthBottom != null) {
- cell.setBorderWidthBottom(borderWidthBottom);
- }
grayFill = (Float) valueBinding(context, "grayFill", grayFill);
if (grayFill != null) {
cell.setGrayFill(grayFill);
}
+
+ rotation = (Integer) valueBinding(context, "rotation", rotation);
+ if (rotation != null) {
+ cell.setRotation(rotation);
+ }
+
+ applyRectangleProperties(context, cell);
}
private PdfPCell getDefaultCellFromTable() {
1.5 +2 -3 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIDocument.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- UIDocument.java 2 Jan 2007 03:40:32 -0000 1.4
+++ UIDocument.java 11 Jan 2007 05:32:06 -0000 1.5
@@ -67,7 +67,6 @@
public void createITextObject(FacesContext context) {
document = new Document();
-
// most of this needs to be done BEFORE document.open();
pageSize = (String) valueBinding(context, "pageSize", pageSize);
1.9 +0 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIList.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIList.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIList.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- UIList.java 9 Jan 2007 08:07:03 -0000 1.8
+++ UIList.java 11 Jan 2007 05:32:06 -0000 1.9
@@ -79,7 +79,6 @@
}
} else if (style.equalsIgnoreCase(STYLE_DINGBATS)) {
charNumber = (Integer) valueBinding(context, "charNumber", charNumber);
- System.out.println("charNumber is " + charNumber);
list = new ZapfDingbatsList(charNumber, (int) indent);
} else if (style.equalsIgnoreCase(STYLE_DINGBATS_NUMBER)) {
numberType = (Integer) valueBinding(context, "numberType", numberType);
1.1 date: 2007/01/11 05:32:06; author: nrichards; state: Exp;jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIFooter.java
Index: UIFooter.java
===================================================================
package org.jboss.seam.pdf.ui;
import com.lowagie.text.Document;
import com.lowagie.text.HeaderFooter;
public class UIFooter extends UIHeaderFooter {
@Override
public void handleHeaderFooter(HeaderFooter footer) {
Document document = findDocument();
if (document == null) {
throw new RuntimeException("cannot locate document object");
}
findDocument().setFooter(footer);
}
}
1.1 date: 2007/01/11 05:32:06; author: nrichards; state: Exp;jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIHeader.java
Index: UIHeader.java
===================================================================
package org.jboss.seam.pdf.ui;
import com.lowagie.text.Document;
import com.lowagie.text.HeaderFooter;
public class UIHeader extends UIHeaderFooter {
@Override
public void handleHeaderFooter(HeaderFooter header) {
Document document = findDocument();
if (document == null) {
throw new RuntimeException("cannot locate document object");
}
findDocument().setHeader(header);
}
}
1.1 date: 2007/01/11 05:32:06; author: nrichards; state: Exp;jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIHeaderFooter.java
Index: UIHeaderFooter.java
===================================================================
package org.jboss.seam.pdf.ui;
import java.io.IOException;
import javax.faces.context.FacesContext;
import org.jboss.seam.pdf.ITextUtils;
import com.lowagie.text.Font;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Phrase;
public abstract class UIHeaderFooter
extends UIRectangle
{
HeaderFooter header;
Phrase before;
Phrase after;
String alignment;
public UIHeaderFooter() {
super();
}
public void setAlignment(String alignment) {
this.alignment = alignment;
}
@Override
public void createITextObject(FacesContext context) {
before = defaultPhrase();
after = null;
}
@Override
public Object getITextObject() {
return null;
}
@Override
public void handleAdd(Object other) {
if (after == null) {
before.add(other);
} else {
after.add(other);
}
}
@Override
public void removeITextObject() {
before = null;
after = null;
}
public void markPage() {
after = defaultPhrase();
}
@Override
public void encodeEnd(FacesContext context) throws IOException {
HeaderFooter header;
if (after == null) {
header = new HeaderFooter(before, false);
} else {
header = new HeaderFooter(before, after);
}
alignment = (String) valueBinding(context, "alignment", alignment);
if (alignment != null) {
header.setAlignment(ITextUtils.alignmentValue(alignment));
}
applyRectangleProperties(context, header);
super.encodeEnd(context);
handleHeaderFooter(header);
}
public abstract void handleHeaderFooter(HeaderFooter item);
/**
* HeaderFooter derives the font for the number from the font of the before phrase.
* Worse still, there is no way to set the font after the phrase is created. The best we
* can do is get the surrounding font context and hope for the best.
*/
private Phrase defaultPhrase() {
Font font = getFont();
if (font == null) {
return new Phrase();
} else {
return new Phrase("", font);
}
}
}
1.1 date: 2007/01/11 05:32:06; author: nrichards; state: Exp;jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIPageNumber.java
Index: UIPageNumber.java
===================================================================
package org.jboss.seam.pdf.ui;
import java.io.IOException;
import javax.faces.context.FacesContext;
public class UIPageNumber extends ITextComponent {
@Override
public void createITextObject(FacesContext context) {
}
@Override
public Object getITextObject() {
return null;
}
@Override
public void handleAdd(Object other) {
throw new RuntimeException("header page number cannot contain other elements");
}
@Override
public void removeITextObject() {
}
@Override
public void encodeEnd(FacesContext context) throws IOException {
super.encodeEnd(context);
UIHeaderFooter header = (UIHeaderFooter) findITextParent(this, UIHeaderFooter.class);
if (header == null) {
throw new RuntimeException("pageNumber can only be used in the context of a header or footer");
}
header.markPage();
}
}
1.1 date: 2007/01/11 05:32:06; author: nrichards; state: Exp;jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIRectangle.java
Index: UIRectangle.java
===================================================================
package org.jboss.seam.pdf.ui;
import java.awt.Color;
import javax.faces.context.FacesContext;
import org.jboss.seam.pdf.ITextUtils;
import com.lowagie.text.Rectangle;
public abstract class UIRectangle
extends ITextComponent
{
protected Color borderColor;
protected Color borderColorLeft;
protected Color borderColorRight;
protected Color borderColorTop;
protected Color borderColorBottom;
protected Color backgroundColor;
protected Float borderWidth;
protected Float borderWidthLeft;
protected Float borderWidthRight;
protected Float borderWidthTop;
protected Float borderWidthBottom;
public UIRectangle() {
super();
}
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 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 void applyRectangleProperties(FacesContext context, Rectangle rectangle) {
backgroundColor = (Color) valueBinding(context, "backgroundColor", backgroundColor);
if (backgroundColor != null) {
rectangle.setBackgroundColor(backgroundColor);
}
borderColor = (Color) valueBinding(context, "borderColor", borderColor);
if (borderColor != null) {
rectangle.setBorderColor(borderColor);
}
borderColorLeft = (Color) valueBinding(context, "borderColorLeft", borderColorLeft);
if (borderColorLeft != null) {
rectangle.setBorderColorLeft(borderColorLeft);
}
borderColorRight = (Color) valueBinding(context, "borderColorRight", borderColorRight);
if (borderColorRight != null) {
rectangle.setBorderColorRight(borderColorRight);
}
borderColorTop = (Color) valueBinding(context, "borderColorTop", borderColorTop);
if (borderColorTop != null) {
rectangle.setBorderColorTop(borderColorTop);
}
borderColorBottom = (Color) valueBinding(context, "borderColorBottom", borderColorBottom);
if (borderColorBottom != null) {
rectangle.setBorderColorBottom(borderColorBottom);
}
borderWidth = (Float) valueBinding(context, "borderWidth", borderWidth);
if (borderWidth != null) {
rectangle.setBorderWidth(borderWidth);
}
borderWidthLeft = (Float) valueBinding(context, "borderWidthLeft", borderWidthLeft);
if (borderWidthLeft != null) {
rectangle.setBorderWidthLeft(borderWidthLeft);
}
borderWidthRight = (Float) valueBinding(context, "borderWidthRight", borderWidthRight);
if (borderWidthRight != null) {
rectangle.setBorderWidthRight(borderWidthRight);
}
borderWidthTop = (Float) valueBinding(context, "borderWidthTop", borderWidthTop);
if (borderWidthTop != null) {
rectangle.setBorderWidthTop(borderWidthTop);
}
borderWidthBottom = (Float) valueBinding(context, "borderWidthBottom", borderWidthBottom);
if (borderWidthBottom != null) {
rectangle.setBorderWidthBottom(borderWidthBottom);
}
}
}
More information about the jboss-cvs-commits
mailing list