[seam-commits] Seam SVN: r8856 - in trunk/src/pdf/org/jboss/seam/pdf: ui and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sat Aug 30 08:01:24 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-08-30 08:01:23 -0400 (Sat, 30 Aug 2008)
New Revision: 8856
Modified:
trunk/src/pdf/org/jboss/seam/pdf/ITextUtils.java
trunk/src/pdf/org/jboss/seam/pdf/KeyStoreConfig.java
trunk/src/pdf/org/jboss/seam/pdf/pdf-2.1.xsd
trunk/src/pdf/org/jboss/seam/pdf/ui/FormComponent.java
trunk/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarCode.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UICategoryChartBase.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UICell.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartSeries.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIColor.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIElement.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIField.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIFont.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIFooter.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIGraphics2D.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeader.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeaderFooter.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIHtmlText.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIImage.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIList.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIOutputText.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIPage.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIPageNumber.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIRectangle.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UISection.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIStroke.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UISwingComponent.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UITable.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UITitle.java
Log:
ws
Modified: trunk/src/pdf/org/jboss/seam/pdf/ITextUtils.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ITextUtils.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ITextUtils.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -8,108 +8,125 @@
import com.lowagie.text.PageSize;
import com.lowagie.text.Rectangle;
-public class ITextUtils {
- static Map<String,Color> colorMap = new HashMap<String,Color>();
+public class ITextUtils
+{
+ static Map<String, Color> colorMap = new HashMap<String, Color>();
- static {
- colorMap.put("white", Color.white);
- colorMap.put("gray", Color.gray);
- colorMap.put("lightgray", Color.lightGray);
- colorMap.put("darkgray", Color.darkGray);
- colorMap.put("black", Color.black);
- colorMap.put("red", Color.red);
- colorMap.put("pink", Color.pink);
- colorMap.put("yellow", Color.yellow);
- colorMap.put("green", Color.green);
- colorMap.put("magenta", Color.magenta);
- colorMap.put("cyan", Color.cyan);
- colorMap.put("blue", Color.blue);
- colorMap.put("orange", Color.orange);
- }
+ static
+ {
+ colorMap.put("white", Color.white);
+ colorMap.put("gray", Color.gray);
+ colorMap.put("lightgray", Color.lightGray);
+ colorMap.put("darkgray", Color.darkGray);
+ colorMap.put("black", Color.black);
+ colorMap.put("red", Color.red);
+ colorMap.put("pink", Color.pink);
+ colorMap.put("yellow", Color.yellow);
+ colorMap.put("green", Color.green);
+ colorMap.put("magenta", Color.magenta);
+ colorMap.put("cyan", Color.cyan);
+ colorMap.put("blue", Color.blue);
+ colorMap.put("orange", Color.orange);
+ }
+ /**
+ * not all itext objects accept a string value as input, so we'll copy that
+ * logic here.
+ */
+ public static int alignmentValue(String alignment)
+ {
+ return ElementTags.alignmentValue(alignment);
+ }
- /**
- * not all itext objects accept a string value as input,
- * so we'll copy that logic here.
- */
- public static int alignmentValue(String alignment) {
- return ElementTags.alignmentValue(alignment);
- }
+ public static Rectangle pageSizeValue(String name)
+ {
+ return PageSize.getRectangle(name);
+ }
- public static Rectangle pageSizeValue(String name) {
- return PageSize.getRectangle(name);
- }
+ /**
+ * return a color value from a string specification.
+ */
+ public static Color colorValue(String colorName)
+ {
+ if (colorName == null)
+ {
+ return null;
+ }
+ colorName = colorName.trim().toLowerCase();
- /**
- * return a color value from a string specification.
- */
- public static Color colorValue(String colorName) {
- if (colorName == null) {
- return null;
- }
+ Color color = colorMap.get(colorName);
- colorName = colorName.trim().toLowerCase();
+ if (color == null && colorName.startsWith("rgb"))
+ {
+ color = rgbStringToColor(colorName);
+ }
+ if (color == null)
+ {
+ color = Color.decode(colorName);
+ }
- Color color = colorMap.get(colorName);
+ return color;
+ }
- if (color == null && colorName.startsWith("rgb")) {
- color = rgbStringToColor(colorName);
- }
- if (color == null) {
- color = Color.decode(colorName);
- }
+ /*
+ * Returns color of the form rgb(r,g,b) or rgb(r,g,b,a) r,g,b,a values can be
+ * 0-255 or float values with a '%' sign
+ */
+ public static Color rgbStringToColor(String rgbString)
+ {
+ String rgb[] = rgbString.split(",");
- return color;
- }
+ if (rgb.length == 3)
+ {
+ return new Color(
+ parseSingleChanel(rgb[0]),
+ parseSingleChanel(rgb[1]),
+ parseSingleChanel(rgb[2]));
+ }
+ else if (rgb.length == 4)
+ {
+ return new Color(
+ parseSingleChanel(rgb[0]),
+ parseSingleChanel(rgb[1]),
+ parseSingleChanel(rgb[2]),
+ parseSingleChanel(rgb[3]));
+ }
- /*
- * Returns color of the form rgb(r,g,b) or rgb(r,g,b,a)
- * r,g,b,a values can be 0-255 or float values with a '%' sign
- */
- public static Color rgbStringToColor(String rgbString) {
- String rgb[] = rgbString.split(",");
-
- if (rgb.length == 3) {
- return new Color(parseSingleChanel(rgb[0]),
- parseSingleChanel(rgb[1]),
- parseSingleChanel(rgb[2]));
- } else if (rgb.length == 4) {
- return new Color(parseSingleChanel(rgb[0]),
- parseSingleChanel(rgb[1]),
- parseSingleChanel(rgb[2]),
- parseSingleChanel(rgb[3]));
- }
+ throw new RuntimeException("invalid rgb color specification: " + rgbString);
+ }
- throw new RuntimeException("invalid rgb color specification: " + rgbString);
- }
+ private static int parseSingleChanel(String chanel)
+ {
+ if (chanel.contains("%"))
+ {
+ float percent = Float.parseFloat(chanel.replaceAll("[^0-9\\.]", ""));
+ return (int) (255 * (percent / 100));
+ }
+ return Integer.parseInt(chanel.replaceAll("[^0-9]", ""));
+ }
- private static int parseSingleChanel(String chanel) {
- if (chanel.contains("%")) {
- float percent = Float.parseFloat(chanel.replaceAll("[^0-9\\.]",""));
- return (int)(255 * (percent / 100));
- }
- return Integer.parseInt(chanel.replaceAll("[^0-9]", ""));
- }
+ public static float[] stringToFloatArray(String text)
+ {
+ String[] parts = text.split("\\s");
+ float[] values = new float[parts.length];
+ for (int i = 0; i < parts.length; i++)
+ {
+ values[i] = Float.valueOf(parts[i]);
+ }
- public static float[] stringToFloatArray(String text) {
- String[] parts = text.split("\\s");
- float[] values = new float[parts.length];
- for (int i=0;i<parts.length;i++) {
- values[i] = Float.valueOf(parts[i]);
- }
+ return values;
+ }
- return values;
- }
+ public static int[] stringToIntArray(String text)
+ {
+ String[] parts = text.split("\\s");
+ int[] values = new int[parts.length];
+ for (int i = 0; i < parts.length; i++)
+ {
+ values[i] = Integer.valueOf(parts[i]);
+ }
-
- public static int[] stringToIntArray(String text) {
- String[] parts = text.split("\\s");
- int[] values = new int[parts.length];
- for (int i=0;i<parts.length;i++) {
- values[i] = Integer.valueOf(parts[i]);
- }
-
- return values;
- }
+ return values;
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/KeyStoreConfig.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/KeyStoreConfig.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/KeyStoreConfig.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -9,41 +9,55 @@
@Name("org.jboss.seam.pdf.pdfKeyStore")
@Install(false)
@Scope(ScopeType.APPLICATION)
-public class KeyStoreConfig {
- String keyStore = null;
- String keyStorePassword = null;
- String keyPassword = null;
- String keyAlias = null;
-
- public String getKeyStore() {
- return keyStore;
- }
- public void setKeyStore(String keyStore) {
- this.keyStore = keyStore;
- }
+public class KeyStoreConfig
+{
+ String keyStore = null;
+ String keyStorePassword = null;
+ String keyPassword = null;
+ String keyAlias = null;
- public String getKeyAlias() {
- return keyAlias;
- }
- public void setKeyAlias(String keyAlias) {
- this.keyAlias = keyAlias;
- }
-
- public String getKeyStorePassword() {
- return keyStorePassword;
- }
- public void setKeyStorePassword(String keyStorePassword) {
- this.keyStorePassword = keyStorePassword;
- }
-
- public String getKeyPassword() {
- return keyPassword;
- }
- public void setKeyPassword(String keyPassword) {
- this.keyPassword = keyPassword;
- }
-
- public static KeyStoreConfig instance() {
- return (KeyStoreConfig) Component.getInstance(KeyStoreConfig.class);
- }
+ public String getKeyStore()
+ {
+ return keyStore;
+ }
+
+ public void setKeyStore(String keyStore)
+ {
+ this.keyStore = keyStore;
+ }
+
+ public String getKeyAlias()
+ {
+ return keyAlias;
+ }
+
+ public void setKeyAlias(String keyAlias)
+ {
+ this.keyAlias = keyAlias;
+ }
+
+ public String getKeyStorePassword()
+ {
+ return keyStorePassword;
+ }
+
+ public void setKeyStorePassword(String keyStorePassword)
+ {
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ public String getKeyPassword()
+ {
+ return keyPassword;
+ }
+
+ public void setKeyPassword(String keyPassword)
+ {
+ this.keyPassword = keyPassword;
+ }
+
+ public static KeyStoreConfig instance()
+ {
+ return (KeyStoreConfig) Component.getInstance(KeyStoreConfig.class);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/pdf-2.1.xsd
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/pdf-2.1.xsd 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/pdf-2.1.xsd 2008-08-30 12:01:23 UTC (rev 8856)
@@ -5,23 +5,25 @@
xmlns:pdf="http://jboss.com/products/seam/pdf"
xmlns:components="http://jboss.com/products/seam/components"
attributeFormDefault="unqualified">
- <xs:import namespace="http://jboss.com/products/seam/components" schemaLocation="components-2.1.xsd"/>
+ <xs:import namespace="http://jboss.com/products/seam/components"
+ schemaLocation="components-2.1.xsd" />
- <xs:element name="key-store-config">
- <xs:annotation>
- <xs:documentation>
- The key stores holds the encryption keys for creating signed PDF documents
- </xs:documentation>
- </xs:annotation>
- <xs:complexType mixed="true">
- <xs:attributeGroup ref="components:attlist.component"/>
- <xs:attributeGroup ref="pdf:attlist.keystore"/>
- </xs:complexType>
- </xs:element>
- <xs:attributeGroup name="attlist.keystore">
- <xs:attribute name="key-store" type="components:string"/>
- <xs:attribute name="key-store-password" type="components:string"/>
- <xs:attribute name="key-password" type="components:string"/>
- <xs:attribute name="key-alias" type="components:string"/>
- </xs:attributeGroup>
+ <xs:element name="key-store-config">
+ <xs:annotation>
+ <xs:documentation>
+ The key stores holds the encryption keys for creating signed PDF
+ documents
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType mixed="true">
+ <xs:attributeGroup ref="components:attlist.component" />
+ <xs:attributeGroup ref="pdf:attlist.keystore" />
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.keystore">
+ <xs:attribute name="key-store" type="components:string" />
+ <xs:attribute name="key-store-password" type="components:string" />
+ <xs:attribute name="key-password" type="components:string" />
+ <xs:attribute name="key-alias" type="components:string" />
+ </xs:attributeGroup>
</xs:schema>
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/FormComponent.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/FormComponent.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/FormComponent.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -6,7 +6,7 @@
public abstract class FormComponent extends UIComponentBase
{
protected static final String FIELDS_KEY = "acrofields";
-
+
protected Object valueOf(String name, Object defaultValue)
{
Object value = defaultValue;
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -12,256 +12,291 @@
import org.jboss.seam.ui.util.JSF;
-
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.xml.simpleparser.EntitiesToUnicode;
-public abstract class ITextComponent
- extends UIComponentBase
+public abstract class ITextComponent extends UIComponentBase
{
- public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf";
-
- protected String inFacet;
- protected Object currentFacet;
-
- /**
- * get the current Itext object
- */
- abstract public Object getITextObject();
+ public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf";
- /**
- * signal that the component should create it's managed object
- * @throws IOException
- * @throws DocumentException
- */
- abstract public void createITextObject(FacesContext context) throws IOException, DocumentException;
+ protected String inFacet;
+ protected Object currentFacet;
- /**
- * remove the itext objext
- */
- abstract public void removeITextObject();
-
- /**
- * subcomponents should implement this to add child components
- * to themselves
- */
- abstract public void handleAdd(Object other);
-
- final public void add(Object other) {
- if (inFacet != null) {
- handleFacet(inFacet, other);
- } else {
- handleAdd(other);
- }
- }
-
- public void handleFacet(String facetName, Object obj) {
- currentFacet = obj;
- // facets.put(facetName,obj);
- }
+ /**
+ * get the current Itext object
+ */
+ abstract public Object getITextObject();
- /**
- * look up the tree for an itext font
- */
- public Font getFont() {
- UIFont fontComponent = (UIFont) findITextParent(this, UIFont.class);
- return fontComponent == null ? null : fontComponent.getFont();
- }
+ /**
+ * signal that the component should create it's managed object
+ *
+ * @throws IOException
+ * @throws DocumentException
+ */
+ abstract public void createITextObject(FacesContext context) throws IOException, DocumentException;
- /**
- * look up the tree for the itext document
- */
- public Document findDocument() {
- ITextComponent parent = findITextParent(this, UIDocument.class);
- if (parent != null) {
- return (Document) parent.getITextObject();
- } else {
- return null;
- }
- }
+ /**
+ * remove the itext objext
+ */
+ abstract public void removeITextObject();
- /**
- * find the first parent that is an itext component);
- */
- public ITextComponent findITextParent(UIComponent parent) {
- return findITextParent(parent, null);
- }
+ /**
+ * subcomponents should implement this to add child components to themselves
+ */
+ abstract public void handleAdd(Object other);
- /**
- * find the first parent that is an itext component of a given type
- */
- public ITextComponent findITextParent(UIComponent parent, Class<?> c) {
- if (parent == null) {
- return null;
- }
-
- if (parent instanceof ITextComponent) {
- if (c==null || c.isAssignableFrom(parent.getClass())) {
- return (ITextComponent) parent;
- }
- }
+ final public void add(Object other)
+ {
+ if (inFacet != null)
+ {
+ handleFacet(inFacet, other);
+ }
+ else
+ {
+ handleAdd(other);
+ }
+ }
- return findITextParent(parent.getParent(),c);
- }
+ public void handleFacet(String facetName, Object obj)
+ {
+ currentFacet = obj;
+ // facets.put(facetName,obj);
+ }
+ /**
+ * look up the tree for an itext font
+ */
+ public Font getFont()
+ {
+ UIFont fontComponent = (UIFont) findITextParent(this, UIFont.class);
+ return fontComponent == null ? null : fontComponent.getFont();
+ }
- /**
- * add a component (usually the current itext object) to the itext parent's itext object
- */
- public void addToITextParent(Object obj) {
- ITextComponent parent = findITextParent(getParent());
- if (parent != null) {
- parent.add(obj);
- } else {
- noITextParentFound();
- }
- }
+ /**
+ * look up the tree for the itext document
+ */
+ public Document findDocument()
+ {
+ ITextComponent parent = findITextParent(this, UIDocument.class);
+ if (parent != null)
+ {
+ return (Document) parent.getITextObject();
+ }
+ else
+ {
+ return null;
+ }
+ }
- public void noITextParentFound() {
- throw new RuntimeException("Couldn't find ITextComponent parent for component " +
- this.getClass().getName());
- }
+ /**
+ * find the first parent that is an itext component);
+ */
+ public ITextComponent findITextParent(UIComponent parent)
+ {
+ return findITextParent(parent, null);
+ }
- public Object processFacet(String facetName) {
- if (inFacet!=null && inFacet.equals(facetName)) {
- return null;
- }
-
- UIComponent facet = this.getFacet(facetName);
- Object result = null;
- if (facet != null) {
+ /**
+ * find the first parent that is an itext component of a given type
+ */
+ public ITextComponent findITextParent(UIComponent parent, Class<?> c)
+ {
+ if (parent == null)
+ {
+ return null;
+ }
+
+ if (parent instanceof ITextComponent)
+ {
+ if (c == null || c.isAssignableFrom(parent.getClass()))
+ {
+ return (ITextComponent) parent;
+ }
+ }
+
+ return findITextParent(parent.getParent(), c);
+ }
+
+ /**
+ * add a component (usually the current itext object) to the itext parent's
+ * itext object
+ */
+ public void addToITextParent(Object obj)
+ {
+ ITextComponent parent = findITextParent(getParent());
+ if (parent != null)
+ {
+ parent.add(obj);
+ }
+ else
+ {
+ noITextParentFound();
+ }
+ }
+
+ public void noITextParentFound()
+ {
+ throw new RuntimeException(
+ "Couldn't find ITextComponent parent for component " + this.getClass().getName());
+ }
+
+ public Object processFacet(String facetName)
+ {
+ if (inFacet != null && inFacet.equals(facetName))
+ {
+ return null;
+ }
+
+ UIComponent facet = this.getFacet(facetName);
+ Object result = null;
+ if (facet != null)
+ {
+ currentFacet = null;
+ inFacet = facetName;
+ try
+ {
+ encode(FacesContext.getCurrentInstance(), facet);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ inFacet = null;
+ result = currentFacet;
currentFacet = null;
- inFacet = facetName;
- try {
- encode(FacesContext.getCurrentInstance(), facet);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- inFacet = null;
- result = currentFacet;
- currentFacet = null;
- }
- }
- return result;
- }
-
- public Object valueBinding(FacesContext context,
- String property,
- Object defaultValue) {
- Object value = defaultValue;
- ValueExpression expression = getValueExpression(property);
+ }
+ }
+ return result;
+ }
- if (expression != null) {
- value = expression.getValue(context.getELContext());
- }
- return value;
- }
-
- public Object valueBinding(String property, Object defaultValue) {
- return valueBinding(FacesContext.getCurrentInstance(), property, defaultValue);
- }
-
- // ------------------------------------------------------
+ public Object valueBinding(FacesContext context, String property, Object defaultValue)
+ {
+ Object value = defaultValue;
+ ValueExpression expression = getValueExpression(property);
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
+ if (expression != null)
+ {
+ value = expression.getValue(context.getELContext());
+ }
+ return value;
+ }
- @Override
- public boolean getRendersChildren() {
- return true;
- }
+ public Object valueBinding(String property, Object defaultValue)
+ {
+ return valueBinding(FacesContext.getCurrentInstance(), property, defaultValue);
+ }
- @Override
- public void encodeBegin(FacesContext context)
- throws IOException
- {
- try
- {
- createITextObject(context);
- }
- catch (DocumentException e)
- {
- throw new FacesException(e);
- }
- }
+ // ------------------------------------------------------
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- Object obj = getITextObject();
- if (obj != null) {
- addToITextParent(getITextObject());
- }
- removeITextObject();
- }
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
- @SuppressWarnings("unchecked")
- @Override
- public void encodeChildren(FacesContext context)
- throws IOException
- {
- for (UIComponent child: this.getChildren()) {
- // ugly hack to be able to capture facelets text
- if (child.getFamily().equals("facelets.LiteralText")) {
- String text = EntitiesToUnicode.decodeString(extractText(context, child));
- Font font = getFont();
- Chunk chunk = null;
- if (font == null) {
- chunk = new Chunk(text);
- } else {
- chunk = new Chunk(text, getFont());
- }
- add(chunk);
- } else {
- encode(context, child);
+ @Override
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ try
+ {
+ createITextObject(context);
+ }
+ catch (DocumentException e)
+ {
+ throw new FacesException(e);
+ }
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ Object obj = getITextObject();
+ if (obj != null)
+ {
+ addToITextParent(getITextObject());
+ }
+ removeITextObject();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ for (UIComponent child : this.getChildren())
+ {
+ // ugly hack to be able to capture facelets text
+ if (child.getFamily().equals("facelets.LiteralText"))
+ {
+ String text = EntitiesToUnicode.decodeString(extractText(context, child));
+ Font font = getFont();
+ Chunk chunk = null;
+ if (font == null)
+ {
+ chunk = new Chunk(text);
}
- }
- }
+ else
+ {
+ chunk = new Chunk(text, getFont());
+ }
+ add(chunk);
+ }
+ else
+ {
+ encode(context, child);
+ }
+ }
+ }
- public String extractText(FacesContext context, UIComponent child)
- throws IOException
- {
- ResponseWriter response = context.getResponseWriter();
- StringWriter stringWriter = new StringWriter();
- ResponseWriter cachingResponseWriter = response.cloneWithWriter(stringWriter);
- context.setResponseWriter(cachingResponseWriter);
-
- JSF.renderChild(context, child);
+ public String extractText(FacesContext context, UIComponent child) throws IOException
+ {
+ ResponseWriter response = context.getResponseWriter();
+ StringWriter stringWriter = new StringWriter();
+ ResponseWriter cachingResponseWriter = response.cloneWithWriter(stringWriter);
+ context.setResponseWriter(cachingResponseWriter);
- context.setResponseWriter(response);
-
- return stringWriter.getBuffer().toString();
- }
+ JSF.renderChild(context, child);
+ context.setResponseWriter(response);
- @SuppressWarnings("unchecked")
- public void encode(FacesContext context,
- UIComponent component)
- throws IOException
- {
- if (!component.isRendered()) {
- return;
- }
+ return stringWriter.getBuffer().toString();
+ }
- component.encodeBegin(context);
+ @SuppressWarnings("unchecked")
+ public void encode(FacesContext context, UIComponent component) throws IOException
+ {
+ if (!component.isRendered())
+ {
+ return;
+ }
- if (component.getChildCount() > 0) {
- if (component.getRendersChildren()) {
- component.encodeChildren(context);
- } else {
- for (UIComponent child: component.getChildren()) {
- encode(context, child);
- }
+ component.encodeBegin(context);
+
+ if (component.getChildCount() > 0)
+ {
+ if (component.getRendersChildren())
+ {
+ component.encodeChildren(context);
+ }
+ else
+ {
+ for (UIComponent child : component.getChildren())
+ {
+ encode(context, child);
}
- }
+ }
+ }
- component.encodeEnd(context);
- }
+ component.encodeEnd(context);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnchor.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,50 +3,58 @@
import javax.faces.context.*;
import com.lowagie.text.*;
-public class UIAnchor
- extends ITextComponent
+public class UIAnchor extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIAnchor";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIAnchor";
- Anchor anchor;
+ Anchor anchor;
- String name;
- String reference;
+ String name;
+ String reference;
- public void setName(String name) {
- this.name = name;
- }
- public void setReference(String reference) {
- this.reference = reference;
- }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
- @Override
- public Object getITextObject() {
- return anchor;
- }
+ public void setReference(String reference)
+ {
+ this.reference = reference;
+ }
- @Override
- public void removeITextObject() {
- anchor = null;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return anchor;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- anchor = new Anchor();
+ @Override
+ public void removeITextObject()
+ {
+ anchor = null;
+ }
- name = (String) valueBinding(context, "name", name);
- if (name != null) {
- anchor.setName(name);
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ anchor = new Anchor();
- reference = (String) valueBinding(context, "reference", reference);
- if (reference != null) {
- anchor.setReference(reference);
- }
- }
+ name = (String) valueBinding(context, "name", name);
+ if (name != null)
+ {
+ anchor.setName(name);
+ }
- @Override
- public void handleAdd(Object o) {
- anchor.add(o);
- }
+ reference = (String) valueBinding(context, "reference", reference);
+ if (reference != null)
+ {
+ anchor.setReference(reference);
+ }
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ anchor.add(o);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -10,84 +10,74 @@
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.Dataset;
-public class UIBarChart
- extends UICategoryChartBase
+public class UIBarChart extends UICategoryChartBase
{
- private CategoryDataset dataset;
+ private CategoryDataset dataset;
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- }
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[1];
- values[0] = super.saveState(context);
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[1];
+ values[0] = super.saveState(context);
- return values;
- }
+ return values;
+ }
- @Override
- public void createDataset() {
- dataset = new DefaultCategoryDataset();
- }
+ @Override
+ public void createDataset()
+ {
+ dataset = new DefaultCategoryDataset();
+ }
+ // @Override
+ // public void configurePlot(Plot p) {
+ // super.configurePlot(p);
+ // }
+ @Override
+ public void configureRenderer(CategoryItemRenderer renderer)
+ {
+ super.configureRenderer(renderer);
+ if (renderer instanceof BarRenderer)
+ {
+ configureRenderer((BarRenderer) renderer);
+ }
+ }
-// @Override
-// public void configurePlot(Plot p) {
-// super.configurePlot(p);
-// }
+ public void configureRenderer(BarRenderer renderer)
+ {
+ }
+ @Override
+ public JFreeChart createChart(FacesContext context)
+ {
+ JFreeChart chart;
- @Override
- public void configureRenderer(CategoryItemRenderer renderer){
- super.configureRenderer(renderer);
- if (renderer instanceof BarRenderer) {
- configureRenderer((BarRenderer) renderer);
- }
- }
+ if (!getIs3D())
+ {
+ chart = ChartFactory.createBarChart(getTitle(), getDomainAxisLabel(), getRangeAxisLabel(), dataset, plotOrientation(getOrientation()), getLegend(), false, false);
+ }
+ else
+ {
+ chart = ChartFactory.createBarChart3D(getTitle(), getDomainAxisLabel(), getRangeAxisLabel(), dataset, plotOrientation(getOrientation()), getLegend(), false, false);
+ }
+ configureTitle(chart.getTitle());
+ configureLegend(chart.getLegend());
- public void configureRenderer(BarRenderer renderer) {
- }
+ return chart;
+ }
- @Override
- public JFreeChart createChart(FacesContext context) {
- JFreeChart chart;
-
- if (!getIs3D()) {
- chart = ChartFactory.createBarChart(getTitle(),
- getDomainAxisLabel(),
- getRangeAxisLabel(),
- dataset,
- plotOrientation(getOrientation()),
- getLegend(),
- false,
- false);
- } else {
- chart = ChartFactory.createBarChart3D(getTitle(),
- getDomainAxisLabel(),
- getRangeAxisLabel(),
- dataset,
- plotOrientation(getOrientation()),
- getLegend(),
- false,
- false);
- }
-
- configureTitle(chart.getTitle());
- configureLegend(chart.getLegend());
-
- return chart;
- }
-
- @Override
- public Dataset getDataset() {
- return dataset;
- }
+ @Override
+ public Dataset getDataset()
+ {
+ return dataset;
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarCode.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarCode.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIBarCode.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -22,323 +22,374 @@
import com.lowagie.text.Image;
import com.lowagie.text.pdf.*;
-
/**
* based on JBSEAM-1155 submission by user ivan
*/
-public class UIBarCode
- extends ITextComponent
+public class UIBarCode extends ITextComponent
{
-
- private Barcode barcode;
- private Object itextObject;
-
- private String type;
- private String code;
- private String codeType;
- private Float xpos;
- private Float ypos;
- private Float rotDegrees;
- private String altText;
- private Float barHeight;
- private Float textSize;
- private Float minBarWidth;
- private Float barMultiplier;
- String barColor;
- String textColor;
-
- public String getCode() {
- return (String) valueBinding("code", code);
- }
+ private Barcode barcode;
+ private Object itextObject;
- public void setCode(String code) {
- this.code = code;
- }
+ private String type;
+ private String code;
+ private String codeType;
+ private Float xpos;
+ private Float ypos;
+ private Float rotDegrees;
+ private String altText;
+ private Float barHeight;
+ private Float textSize;
+ private Float minBarWidth;
+ private Float barMultiplier;
- public String getType() {
- return (String) valueBinding("type", type);
- }
+ String barColor;
+ String textColor;
- public void setType(String type) {
- this.type = type;
- }
+ public String getCode()
+ {
+ return (String) valueBinding("code", code);
+ }
- public String getCodeType() {
- return (String) valueBinding("codeType", codeType);
- }
+ public void setCode(String code)
+ {
+ this.code = code;
+ }
- public void setCodeType(String codeType) {
- this.codeType = codeType;
- }
-
- public Float getRotDegrees(){
- return (Float) valueBinding("rotDegrees", rotDegrees);
- }
+ public String getType()
+ {
+ return (String) valueBinding("type", type);
+ }
- public void setRotDegrees(Float rotDegrees) {
- this.rotDegrees = rotDegrees;
- }
-
- public Float getXpos() {
- return (Float) valueBinding("xpos", xpos);
- }
+ public void setType(String type)
+ {
+ this.type = type;
+ }
- public void setXpos(Float xpos) {
- this.xpos = xpos;
- }
+ public String getCodeType()
+ {
+ return (String) valueBinding("codeType", codeType);
+ }
- public Float getYpos() {
- return (Float) valueBinding("ypos", ypos);
- }
+ public void setCodeType(String codeType)
+ {
+ this.codeType = codeType;
+ }
- public void setYpos(Float ypos) {
- this.ypos = ypos;
- }
+ public Float getRotDegrees()
+ {
+ return (Float) valueBinding("rotDegrees", rotDegrees);
+ }
- public String getAltText() {
- return (String) valueBinding("altText", altText);
- }
+ public void setRotDegrees(Float rotDegrees)
+ {
+ this.rotDegrees = rotDegrees;
+ }
- public void setAltText(String altText) {
- this.altText = altText;
- }
+ public Float getXpos()
+ {
+ return (Float) valueBinding("xpos", xpos);
+ }
- public Float getBarHeight() {
- return (Float) valueBinding("barHeight", barHeight);
- }
+ public void setXpos(Float xpos)
+ {
+ this.xpos = xpos;
+ }
- public void setBarHeight(Float barHeight) {
- this.barHeight = barHeight;
- }
+ public Float getYpos()
+ {
+ return (Float) valueBinding("ypos", ypos);
+ }
- public Float getBarMultiplier() {
- return (Float) valueBinding("barMultiplier", barMultiplier);
- }
+ public void setYpos(Float ypos)
+ {
+ this.ypos = ypos;
+ }
- public void setBarMultiplier(Float barMultiplier) {
- this.barMultiplier = barMultiplier;
- }
+ public String getAltText()
+ {
+ return (String) valueBinding("altText", altText);
+ }
- public Float getMinBarWidth() {
- return (Float) valueBinding("minBarWidth", minBarWidth);
- }
+ public void setAltText(String altText)
+ {
+ this.altText = altText;
+ }
- public void setMinBarWidth(Float minBarWidth) {
- this.minBarWidth = minBarWidth;
- }
+ public Float getBarHeight()
+ {
+ return (Float) valueBinding("barHeight", barHeight);
+ }
- public Float getTextSize() {
- return (Float) valueBinding("textSize", textSize);
- }
+ public void setBarHeight(Float barHeight)
+ {
+ this.barHeight = barHeight;
+ }
- public void setTextSize(Float textSize) {
- this.textSize = textSize;
- }
-
- public String getBarColor() {
- return (String) valueBinding("barColor", barColor);
- }
+ public Float getBarMultiplier()
+ {
+ return (Float) valueBinding("barMultiplier", barMultiplier);
+ }
- public void setBarColor(String barColor) {
- this.barColor = barColor;
- }
+ public void setBarMultiplier(Float barMultiplier)
+ {
+ this.barMultiplier = barMultiplier;
+ }
- public String getTextColor() {
- return (String) valueBinding("textColor", textColor);
- }
+ public Float getMinBarWidth()
+ {
+ return (Float) valueBinding("minBarWidth", minBarWidth);
+ }
- public void setTextColor(String textColor) {
- this.textColor = textColor;
- }
+ public void setMinBarWidth(Float minBarWidth)
+ {
+ this.minBarWidth = minBarWidth;
+ }
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
-
- type = (String) values[1];
- code = (String) values[2];
- xpos = (Float) values[5];
- ypos = (Float) values[6];
- rotDegrees = (Float) values[7];
- altText = (String) values[8];
- barHeight = (Float) values[9];
- textSize = (Float) values[10];
- minBarWidth = (Float) values[11];
- barMultiplier = (Float) values[12];
- codeType = (String) values[13];
- barColor = (String) values[14];
- textColor = (String) values[15];
- }
+ public Float getTextSize()
+ {
+ return (Float) valueBinding("textSize", textSize);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[16];
-
- values[0] = super.saveState(context);
- values[1] = type;
- values[2] = code;
- values[5] = xpos;
- values[6] = ypos;
- values[7] = rotDegrees;
- values[8] = altText;
- values[9] = barHeight;
- values[10] = textSize;
- values[11] = minBarWidth;
- values[12] = barMultiplier;
- values[13] = codeType;
- values[14] = barColor;
- values[15] = textColor;
-
- return values;
- }
-
-
- @Override
- public Object getITextObject() {
- return itextObject;
- }
+ public void setTextSize(Float textSize)
+ {
+ this.textSize = textSize;
+ }
- @Override
- public void createITextObject(FacesContext context) throws IOException {
- barcode = createBarcodeType(getType());
-
- barcode.setCode(getCode());
-
- Integer codeVal = lookupCodeType(getCodeType());
- if (codeVal != null) {
- barcode.setCodeType(codeVal);
- }
-
- if (getAltText() != null) {
- barcode.setAltText(getAltText());
- }
+ public String getBarColor()
+ {
+ return (String) valueBinding("barColor", barColor);
+ }
- if (getBarHeight() != null) {
- barcode.setBarHeight(getBarHeight());
- }
+ public void setBarColor(String barColor)
+ {
+ this.barColor = barColor;
+ }
- if (getBarMultiplier() != null) {
- barcode.setN(getBarMultiplier());
- }
-
- if (getMinBarWidth() != null) {
- barcode.setX(getMinBarWidth());
- }
+ public String getTextColor()
+ {
+ return (String) valueBinding("textColor", textColor);
+ }
-
- UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
-
- if (doc != null) {
- PdfWriter writer = (PdfWriter) doc.getWriter();
- PdfContentByte cb = writer.getDirectContent();
- Image image = barcode.createImageWithBarcode(cb,
- ITextUtils.colorValue(getBarColor()),
- ITextUtils.colorValue(getTextColor()));
-
- if (getRotDegrees() != null) {
- image.setRotationDegrees(getRotDegrees());
- }
- if (getXpos()!= null && getYpos()!=null) {
- image.setAbsolutePosition(getXpos(), getYpos());
- }
-
- itextObject = image;
- } else {
- Color bars = ITextUtils.colorValue(getBarColor());
- if (bars == null) {
- bars = Color.BLACK;
- }
- byte[] imageData = imageToByteArray(barcode.createAwtImage(bars, Color.WHITE));
- itextObject = new ImageWrapper(imageData, Type.IMAGE_JPEG);
- }
- }
+ public void setTextColor(String textColor)
+ {
+ this.textColor = textColor;
+ }
- private Integer lookupCodeType(String codeType) {
- if (codeType == null || codeType.length()==0) {
- return null;
- }
-
- try {
- Field field = Barcode.class.getDeclaredField(codeType.toUpperCase());
- return field.getInt(Barcode.class);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
- private Barcode createBarcodeType(String barcodeType) {
- if (barcodeType == null || barcodeType.length()==0) {
- return new Barcode128();
- }
-
- if (barcodeType.equalsIgnoreCase("code128")) {
- return new Barcode128();
- } else if (barcodeType.equalsIgnoreCase("code39")) {
- return new Barcode39();
- } else if (barcodeType.equalsIgnoreCase("codabar")) {
- return new BarcodeCodabar();
- } else if (barcodeType.equalsIgnoreCase("ean")) {
- return new BarcodeEAN();
- } else if (barcodeType.equalsIgnoreCase("inter25")) {
- return new BarcodeInter25();
- } else if (barcodeType.equalsIgnoreCase("postnet")) {
- return new BarcodePostnet();
- }
- throw new RuntimeException("Unknown barcode type " + barcodeType);
- }
+ type = (String) values[1];
+ code = (String) values[2];
+ xpos = (Float) values[5];
+ ypos = (Float) values[6];
+ rotDegrees = (Float) values[7];
+ altText = (String) values[8];
+ barHeight = (Float) values[9];
+ textSize = (Float) values[10];
+ minBarWidth = (Float) values[11];
+ barMultiplier = (Float) values[12];
+ codeType = (String) values[13];
+ barColor = (String) values[14];
+ textColor = (String) values[15];
+ }
- @Override
- public void removeITextObject() {
- itextObject = null;
- }
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[16];
- @Override
- public void handleAdd(Object other) {
- throw new RuntimeException("can't add " + other.getClass().getName() + " to barcode");
- }
-
- public static byte[] imageToByteArray(java.awt.Image image)
- throws IOException
- {
- BufferedImage bufferedImage = new BufferedImage(image.getWidth(null),
- image.getHeight(null),
- BufferedImage.TYPE_INT_RGB);
- Graphics gc = bufferedImage.createGraphics();
- gc.drawImage(image, 0, 0, null);
-
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ImageIO.write(bufferedImage, "jpeg", stream);
-
- return stream.toByteArray();
- }
-
- @Override
- public void noITextParentFound() {
- try {
- FacesContext context = FacesContext.getCurrentInstance();
- ResponseWriter response = context.getResponseWriter();
- response.startElement("img", null);
- GraphicImageStore store = GraphicImageStore.instance();
+ values[0] = super.saveState(context);
+ values[1] = type;
+ values[2] = code;
+ values[5] = xpos;
+ values[6] = ypos;
+ values[7] = rotDegrees;
+ values[8] = altText;
+ values[9] = barHeight;
+ values[10] = textSize;
+ values[11] = minBarWidth;
+ values[12] = barMultiplier;
+ values[13] = codeType;
+ values[14] = barColor;
+ values[15] = textColor;
- String key = store.put((ImageWrapper) itextObject);
- String url = context.getExternalContext().getRequestContextPath() +
- GraphicImageResource.GRAPHIC_IMAGE_RESOURCE_PATH + "/" + key + Type.IMAGE_JPEG.getExtension();
+ return values;
+ }
- response.writeAttribute("src", url, null);
+ @Override
+ public Object getITextObject()
+ {
+ return itextObject;
+ }
- response.endElement("img");
+ @Override
+ public void createITextObject(FacesContext context) throws IOException
+ {
+ barcode = createBarcodeType(getType());
- Manager.instance().beforeRedirect();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ barcode.setCode(getCode());
+ Integer codeVal = lookupCodeType(getCodeType());
+ if (codeVal != null)
+ {
+ barcode.setCodeType(codeVal);
+ }
-
+ if (getAltText() != null)
+ {
+ barcode.setAltText(getAltText());
+ }
+
+ if (getBarHeight() != null)
+ {
+ barcode.setBarHeight(getBarHeight());
+ }
+
+ if (getBarMultiplier() != null)
+ {
+ barcode.setN(getBarMultiplier());
+ }
+
+ if (getMinBarWidth() != null)
+ {
+ barcode.setX(getMinBarWidth());
+ }
+
+ UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
+
+ if (doc != null)
+ {
+ PdfWriter writer = (PdfWriter) doc.getWriter();
+ PdfContentByte cb = writer.getDirectContent();
+ Image image = barcode.createImageWithBarcode(cb, ITextUtils.colorValue(getBarColor()), ITextUtils.colorValue(getTextColor()));
+
+ if (getRotDegrees() != null)
+ {
+ image.setRotationDegrees(getRotDegrees());
+ }
+ if (getXpos() != null && getYpos() != null)
+ {
+ image.setAbsolutePosition(getXpos(), getYpos());
+ }
+
+ itextObject = image;
+ }
+ else
+ {
+ Color bars = ITextUtils.colorValue(getBarColor());
+ if (bars == null)
+ {
+ bars = Color.BLACK;
+ }
+ byte[] imageData = imageToByteArray(barcode.createAwtImage(bars, Color.WHITE));
+ itextObject = new ImageWrapper(imageData, Type.IMAGE_JPEG);
+ }
+ }
+
+ private Integer lookupCodeType(String codeType)
+ {
+ if (codeType == null || codeType.length() == 0)
+ {
+ return null;
+ }
+
+ try
+ {
+ Field field = Barcode.class.getDeclaredField(codeType.toUpperCase());
+ return field.getInt(Barcode.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Barcode createBarcodeType(String barcodeType)
+ {
+ if (barcodeType == null || barcodeType.length() == 0)
+ {
+ return new Barcode128();
+ }
+
+ if (barcodeType.equalsIgnoreCase("code128"))
+ {
+ return new Barcode128();
+ }
+ else if (barcodeType.equalsIgnoreCase("code39"))
+ {
+ return new Barcode39();
+ }
+ else if (barcodeType.equalsIgnoreCase("codabar"))
+ {
+ return new BarcodeCodabar();
+ }
+ else if (barcodeType.equalsIgnoreCase("ean"))
+ {
+ return new BarcodeEAN();
+ }
+ else if (barcodeType.equalsIgnoreCase("inter25"))
+ {
+ return new BarcodeInter25();
+ }
+ else if (barcodeType.equalsIgnoreCase("postnet"))
+ {
+ return new BarcodePostnet();
+ }
+ throw new RuntimeException("Unknown barcode type " + barcodeType);
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ itextObject = null;
+ }
+
+ @Override
+ public void handleAdd(Object other)
+ {
+ throw new RuntimeException("can't add " + other.getClass().getName() + " to barcode");
+ }
+
+ public static byte[] imageToByteArray(java.awt.Image image) throws IOException
+ {
+ BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
+ Graphics gc = bufferedImage.createGraphics();
+ gc.drawImage(image, 0, 0, null);
+
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ImageIO.write(bufferedImage, "jpeg", stream);
+
+ return stream.toByteArray();
+ }
+
+ @Override
+ public void noITextParentFound()
+ {
+ try
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ ResponseWriter response = context.getResponseWriter();
+ response.startElement("img", null);
+ GraphicImageStore store = GraphicImageStore.instance();
+
+ String key = store.put((ImageWrapper) itextObject);
+ String url = context.getExternalContext().getRequestContextPath() + GraphicImageResource.GRAPHIC_IMAGE_RESOURCE_PATH + "/" + key + Type.IMAGE_JPEG.getExtension();
+
+ response.writeAttribute("src", url, null);
+
+ response.endElement("img");
+
+ Manager.instance().beforeRedirect();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UICategoryChartBase.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UICategoryChartBase.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UICategoryChartBase.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -8,328 +8,382 @@
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
-public abstract class UICategoryChartBase
- extends UIChart
+public abstract class UICategoryChartBase extends UIChart
{
- private String orientation;
-
- private boolean legend;
- private boolean is3D = false;
+ private String orientation;
- private String title;
- private String titleBackgroundPaint;
- private String titlePaint;
+ private boolean legend;
+ private boolean is3D = false;
- private String legendBackgroundPaint;
- private String legendItemPaint;
+ private String title;
+ private String titleBackgroundPaint;
+ private String titlePaint;
- private String domainAxisLabel;
- private String domainAxisPaint;
- private Boolean domainGridlinesVisible;
- private String domainGridlinePaint;
- private String domainGridlineStroke;
-
- private String rangeAxisLabel;
- private String rangeAxisPaint;
- private Boolean rangeGridlinesVisible;
- private String rangeGridlinePaint;
- private String rangeGridlineStroke;
-
- public String getDomainAxisLabel() {
- return (String) valueBinding("domainAxisLabel", domainAxisLabel);
- }
+ private String legendBackgroundPaint;
+ private String legendItemPaint;
- public void setDomainAxisLabel(String categoryAxisLabel) {
- this.domainAxisLabel = categoryAxisLabel;
- }
+ private String domainAxisLabel;
+ private String domainAxisPaint;
+ private Boolean domainGridlinesVisible;
+ private String domainGridlinePaint;
+ private String domainGridlineStroke;
- public String getRangeAxisLabel() {
- return (String) valueBinding("rangeAxisLabel", rangeAxisLabel);
- }
+ private String rangeAxisLabel;
+ private String rangeAxisPaint;
+ private Boolean rangeGridlinesVisible;
+ private String rangeGridlinePaint;
+ private String rangeGridlineStroke;
- public void setRangeAxisLabel(String valueAxisLabel) {
- this.rangeAxisLabel = valueAxisLabel;
- }
+ public String getDomainAxisLabel()
+ {
+ return (String) valueBinding("domainAxisLabel", domainAxisLabel);
+ }
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getTitle() {
- return (String) valueBinding("title", title);
- }
-
- public void setOrientation(String orientation) {
- this.orientation = orientation;
- }
-
- public String getOrientation() {
- return (String) valueBinding("orientation", orientation);
- }
-
-
- public void setLegend(boolean legend) {
- this.legend = legend;
- }
-
- public boolean getLegend() {
- return (Boolean) valueBinding("legend", legend);
- }
+ public void setDomainAxisLabel(String categoryAxisLabel)
+ {
+ this.domainAxisLabel = categoryAxisLabel;
+ }
- public void setIs3D(boolean is3D) {
- this.is3D = true;
- }
-
- public boolean getIs3D() {
- return (Boolean) valueBinding("is3D", is3D);
- }
+ public String getRangeAxisLabel()
+ {
+ return (String) valueBinding("rangeAxisLabel", rangeAxisLabel);
+ }
- public void setTitleBackgroundPaint(String titleBackgroundPaint) {
- this.titleBackgroundPaint = titleBackgroundPaint;
- }
-
- public String getTitleBackgroundPaint() {
- return (String) valueBinding("titleBackgroundPaint", titleBackgroundPaint);
- }
+ public void setRangeAxisLabel(String valueAxisLabel)
+ {
+ this.rangeAxisLabel = valueAxisLabel;
+ }
- public void setTitlePaint(String titlePaint) {
- this.titlePaint = titlePaint;
- }
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
- public String getTitlePaint() {
- return (String) valueBinding("titlePaint", titlePaint);
- }
-
- public String getLegendBackgroundPaint() {
- return (String) valueBinding("legendBackgroundPaint", legendBackgroundPaint);
- }
+ public String getTitle()
+ {
+ return (String) valueBinding("title", title);
+ }
- public void setLegendBackgroundPaint(String legendBackgroundPaint) {
- this.legendBackgroundPaint = legendBackgroundPaint;
- }
+ public void setOrientation(String orientation)
+ {
+ this.orientation = orientation;
+ }
- public String getLegendItemPaint() {
- return (String) valueBinding("legendItemPaint", legendItemPaint);
- }
+ public String getOrientation()
+ {
+ return (String) valueBinding("orientation", orientation);
+ }
- public void setLegendItemPaint(String legendItemPaint) {
- this.legendItemPaint = legendItemPaint;
- }
-
- public String getDomainGridlinePaint() {
- return (String) valueBinding("domainGridlinePaint", domainGridlinePaint);
- }
+ public void setLegend(boolean legend)
+ {
+ this.legend = legend;
+ }
- public void setDomainGridlinePaint(String domainGridlinePaint) {
- this.domainGridlinePaint = domainGridlinePaint;
- }
+ public boolean getLegend()
+ {
+ return (Boolean) valueBinding("legend", legend);
+ }
- public String getDomainGridlineStroke() {
- return (String) valueBinding("domainGridlineStroke", domainGridlineStroke);
- }
+ public void setIs3D(boolean is3D)
+ {
+ this.is3D = true;
+ }
- public void setDomainGridlineStroke(String domainGridlineStroke) {
- this.domainGridlineStroke = domainGridlineStroke;
- }
+ public boolean getIs3D()
+ {
+ return (Boolean) valueBinding("is3D", is3D);
+ }
- public Boolean getDomainGridlinesVisible() {
- return (Boolean) valueBinding("domainGridlinesVisible", domainGridlinesVisible);
- }
+ public void setTitleBackgroundPaint(String titleBackgroundPaint)
+ {
+ this.titleBackgroundPaint = titleBackgroundPaint;
+ }
- public void setDomainGridlinesVisible(Boolean domainGridlinesVisible) {
- this.domainGridlinesVisible = domainGridlinesVisible;
- }
+ public String getTitleBackgroundPaint()
+ {
+ return (String) valueBinding("titleBackgroundPaint", titleBackgroundPaint);
+ }
- public String getRangeGridlinePaint() {
- return (String) valueBinding("rangeGridlinePaint", rangeGridlinePaint);
- }
+ public void setTitlePaint(String titlePaint)
+ {
+ this.titlePaint = titlePaint;
+ }
- public void setRangeGridlinePaint(String rangeGridlinePaint) {
- this.rangeGridlinePaint = rangeGridlinePaint;
- }
+ public String getTitlePaint()
+ {
+ return (String) valueBinding("titlePaint", titlePaint);
+ }
- public String getRangeGridlineStroke() {
- return (String) valueBinding("rangeGridlineStroke", rangeGridlineStroke);
- }
+ public String getLegendBackgroundPaint()
+ {
+ return (String) valueBinding("legendBackgroundPaint", legendBackgroundPaint);
+ }
- public void setRangeGridlineStroke(String rangeGridlineStroke) {
- this.rangeGridlineStroke = rangeGridlineStroke;
- }
+ public void setLegendBackgroundPaint(String legendBackgroundPaint)
+ {
+ this.legendBackgroundPaint = legendBackgroundPaint;
+ }
- public Boolean getRangeGridlinesVisible() {
- return (Boolean) valueBinding("rangeGridlinesVisible", rangeGridlinesVisible);
- }
+ public String getLegendItemPaint()
+ {
+ return (String) valueBinding("legendItemPaint", legendItemPaint);
+ }
- public void setRangeGridlinesVisible(Boolean rangeGridlinesVisible) {
- this.rangeGridlinesVisible = rangeGridlinesVisible;
- }
-
- public String getDomainAxisPaint() {
- return (String) valueBinding("domainAxisPaint", domainAxisPaint);
- }
+ public void setLegendItemPaint(String legendItemPaint)
+ {
+ this.legendItemPaint = legendItemPaint;
+ }
- public void setDomainAxisPaint(String domainAxisPaint) {
- this.domainAxisPaint = domainAxisPaint;
- }
+ public String getDomainGridlinePaint()
+ {
+ return (String) valueBinding("domainGridlinePaint", domainGridlinePaint);
+ }
- public String getRangeAxisPaint() {
- return (String) valueBinding("rangeAxisPaint", rangeAxisPaint);
- }
+ public void setDomainGridlinePaint(String domainGridlinePaint)
+ {
+ this.domainGridlinePaint = domainGridlinePaint;
+ }
- public void setRangeAxisPaint(String rangeAxisPaint) {
- this.rangeAxisPaint = rangeAxisPaint;
- }
+ public String getDomainGridlineStroke()
+ {
+ return (String) valueBinding("domainGridlineStroke", domainGridlineStroke);
+ }
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
-
- super.restoreState(context, values[0]);
-
- orientation = (String) values[1];
- legend = (Boolean) values[2];
- is3D = (Boolean) values[3];
- title = (String) values[4];
- titleBackgroundPaint = (String) values[5];
- titlePaint = (String) values[6];
- legendBackgroundPaint = (String) values[7];
- legendItemPaint = (String) values[8];
- domainAxisLabel = (String) values[9];
- domainAxisPaint = (String) values[10];
- domainGridlinesVisible = (Boolean) values[11];
- domainGridlinePaint = (String) values[12];
- domainGridlineStroke = (String) values[13];
- rangeAxisLabel = (String) values[14];
- rangeAxisPaint = (String) values[15];
- rangeGridlinesVisible = (Boolean) values[16];
- rangeGridlinePaint = (String) values[17];
- rangeGridlineStroke = (String) values[18];
- }
+ public void setDomainGridlineStroke(String domainGridlineStroke)
+ {
+ this.domainGridlineStroke = domainGridlineStroke;
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[19];
- values[0] = super.saveState(context);
- values[1] = orientation;
- values[2] = legend;
- values[3] = is3D;
- values[4] = title;
- values[5] = titleBackgroundPaint;
- values[6] = titlePaint;
- values[7] = legendBackgroundPaint;
- values[8] = legendItemPaint;
- values[9] = domainAxisLabel;
- values[10] = domainAxisPaint;
- values[11] = domainGridlinesVisible;
- values[12] = domainGridlinePaint;
- values[13] = domainGridlineStroke;
- values[14] = rangeAxisLabel;
- values[15] = rangeAxisPaint;
- values[16] = rangeGridlinesVisible;
- values[17] = rangeGridlinePaint;
- values[18] = rangeGridlineStroke;
+ public Boolean getDomainGridlinesVisible()
+ {
+ return (Boolean) valueBinding("domainGridlinesVisible", domainGridlinesVisible);
+ }
- return values;
- }
-
- @Override
- public void configurePlot(Plot plot) {
- super.configurePlot(plot);
- if (plot instanceof CategoryPlot) {
- configurePlot((CategoryPlot) plot);
- } else {
- System.out.println("UICATEGORYCHART --- unknown plot " + plot);
- }
- }
-
- public void configurePlot(CategoryPlot plot) {
- //plot.setAxisOffset(RectangleInsets)
- //plot.setDomainAxisLocation(arg0);
- //plot.setRangeAxisLocation(arg0);
-
- if (getDomainGridlinesVisible() != null) {
- plot.setDomainGridlinesVisible(getDomainGridlinesVisible());
- }
-
- if (findColor(getDomainGridlinePaint()) != null) {
- plot.setDomainGridlinePaint(findColor(getDomainGridlinePaint()));
- }
- if (findStroke(getDomainGridlineStroke()) != null) {
- plot.setDomainGridlineStroke(findStroke(getDomainGridlineStroke()));
- }
- if (findColor(getDomainAxisPaint()) != null) {
- plot.getDomainAxis().setLabelPaint(findColor(getDomainAxisPaint()));
- }
-
- if (getRangeGridlinesVisible() != null) {
- plot.setRangeGridlinesVisible(getRangeGridlinesVisible());
- }
- if (findColor(getRangeGridlinePaint())!=null) {
- plot.setRangeGridlinePaint(findColor(getRangeGridlinePaint()));
- }
- if (findStroke(getRangeGridlineStroke())!=null) {
- plot.setRangeGridlineStroke(findStroke(getRangeGridlineStroke()));
- }
- if (findColor(getRangeAxisPaint()) != null) {
- plot.getRangeAxis().setLabelPaint(findColor(getRangeAxisPaint()));
- }
- configureRenderer(plot.getRenderer());
- }
-
-
- public void configureRenderer(CategoryItemRenderer renderer){
- //renderer.setItemMargin(0.0);
-
-// renderer.setBase(arg0);
-// renderer.setBaseFillPaint(arg0);
-// renderer.setBaseItemLabelFont(arg0);
-// renderer.setBaseItemLabelPaint(arg0);
-// renderer.setBaseItemLabelsVisible(arg0);
-// renderer.setBaseOutlinePaint(arg0);
-// renderer.setBaseOutlineStroke(arg0);
-// renderer.setBaseSeriesVisible(arg0);
-// renderer.setBaseSeriesVisibleInLegend(arg0);
-// renderer.setBaseShape(arg0);
-// renderer.setBaseStroke();
-// renderer.setFillPaint(arg0);
-// renderer.setItemLabelFont(arg0);
-// renderer.setItemLabelPaint(arg0);
-// renderer.setItemLabelsVisible(arg0);
-// renderer.setItemMargin(arg0);
-// renderer.setOutlinePaint(arg0)
-// renderer.setOutlineStroke(arg0)
-// renderer.setPaint(arg0);
-// renderer.setStroke(arg0);
-
-
-
- //renderer.setBaseOutlineStroke(new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10f,
- //new float[] {10,3}, 0));
- }
-
- public void configureTitle(TextTitle chartTitle) {
- if (chartTitle!=null) {
- if (findColor(getTitleBackgroundPaint()) != null) {
- chartTitle.setBackgroundPaint(findColor(getTitleBackgroundPaint()));
- }
-
- if (findColor(getTitlePaint()) != null) {
- chartTitle.setPaint(findColor(getTitlePaint()));
- }
- }
- }
-
- void configureLegend(LegendTitle chartLegend) {
- if (chartLegend!=null) {
- if (findColor(getLegendBackgroundPaint())!=null) {
- chartLegend.setBackgroundPaint(findColor(getLegendBackgroundPaint()));
- }
- if (findColor(getLegendItemPaint())!= null) {
- chartLegend.setItemPaint(findColor(getLegendItemPaint()));
- }
- }
- }
+ public void setDomainGridlinesVisible(Boolean domainGridlinesVisible)
+ {
+ this.domainGridlinesVisible = domainGridlinesVisible;
+ }
+ public String getRangeGridlinePaint()
+ {
+ return (String) valueBinding("rangeGridlinePaint", rangeGridlinePaint);
+ }
+
+ public void setRangeGridlinePaint(String rangeGridlinePaint)
+ {
+ this.rangeGridlinePaint = rangeGridlinePaint;
+ }
+
+ public String getRangeGridlineStroke()
+ {
+ return (String) valueBinding("rangeGridlineStroke", rangeGridlineStroke);
+ }
+
+ public void setRangeGridlineStroke(String rangeGridlineStroke)
+ {
+ this.rangeGridlineStroke = rangeGridlineStroke;
+ }
+
+ public Boolean getRangeGridlinesVisible()
+ {
+ return (Boolean) valueBinding("rangeGridlinesVisible", rangeGridlinesVisible);
+ }
+
+ public void setRangeGridlinesVisible(Boolean rangeGridlinesVisible)
+ {
+ this.rangeGridlinesVisible = rangeGridlinesVisible;
+ }
+
+ public String getDomainAxisPaint()
+ {
+ return (String) valueBinding("domainAxisPaint", domainAxisPaint);
+ }
+
+ public void setDomainAxisPaint(String domainAxisPaint)
+ {
+ this.domainAxisPaint = domainAxisPaint;
+ }
+
+ public String getRangeAxisPaint()
+ {
+ return (String) valueBinding("rangeAxisPaint", rangeAxisPaint);
+ }
+
+ public void setRangeAxisPaint(String rangeAxisPaint)
+ {
+ this.rangeAxisPaint = rangeAxisPaint;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+
+ super.restoreState(context, values[0]);
+
+ orientation = (String) values[1];
+ legend = (Boolean) values[2];
+ is3D = (Boolean) values[3];
+ title = (String) values[4];
+ titleBackgroundPaint = (String) values[5];
+ titlePaint = (String) values[6];
+ legendBackgroundPaint = (String) values[7];
+ legendItemPaint = (String) values[8];
+ domainAxisLabel = (String) values[9];
+ domainAxisPaint = (String) values[10];
+ domainGridlinesVisible = (Boolean) values[11];
+ domainGridlinePaint = (String) values[12];
+ domainGridlineStroke = (String) values[13];
+ rangeAxisLabel = (String) values[14];
+ rangeAxisPaint = (String) values[15];
+ rangeGridlinesVisible = (Boolean) values[16];
+ rangeGridlinePaint = (String) values[17];
+ rangeGridlineStroke = (String) values[18];
+ }
+
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[19];
+ values[0] = super.saveState(context);
+ values[1] = orientation;
+ values[2] = legend;
+ values[3] = is3D;
+ values[4] = title;
+ values[5] = titleBackgroundPaint;
+ values[6] = titlePaint;
+ values[7] = legendBackgroundPaint;
+ values[8] = legendItemPaint;
+ values[9] = domainAxisLabel;
+ values[10] = domainAxisPaint;
+ values[11] = domainGridlinesVisible;
+ values[12] = domainGridlinePaint;
+ values[13] = domainGridlineStroke;
+ values[14] = rangeAxisLabel;
+ values[15] = rangeAxisPaint;
+ values[16] = rangeGridlinesVisible;
+ values[17] = rangeGridlinePaint;
+ values[18] = rangeGridlineStroke;
+
+ return values;
+ }
+
+ @Override
+ public void configurePlot(Plot plot)
+ {
+ super.configurePlot(plot);
+ if (plot instanceof CategoryPlot)
+ {
+ configurePlot((CategoryPlot) plot);
+ }
+ else
+ {
+ System.out.println("UICATEGORYCHART --- unknown plot " + plot);
+ }
+ }
+
+ public void configurePlot(CategoryPlot plot)
+ {
+ // plot.setAxisOffset(RectangleInsets)
+ // plot.setDomainAxisLocation(arg0);
+ // plot.setRangeAxisLocation(arg0);
+
+ if (getDomainGridlinesVisible() != null)
+ {
+ plot.setDomainGridlinesVisible(getDomainGridlinesVisible());
+ }
+
+ if (findColor(getDomainGridlinePaint()) != null)
+ {
+ plot.setDomainGridlinePaint(findColor(getDomainGridlinePaint()));
+ }
+ if (findStroke(getDomainGridlineStroke()) != null)
+ {
+ plot.setDomainGridlineStroke(findStroke(getDomainGridlineStroke()));
+ }
+ if (findColor(getDomainAxisPaint()) != null)
+ {
+ plot.getDomainAxis().setLabelPaint(findColor(getDomainAxisPaint()));
+ }
+
+ if (getRangeGridlinesVisible() != null)
+ {
+ plot.setRangeGridlinesVisible(getRangeGridlinesVisible());
+ }
+ if (findColor(getRangeGridlinePaint()) != null)
+ {
+ plot.setRangeGridlinePaint(findColor(getRangeGridlinePaint()));
+ }
+ if (findStroke(getRangeGridlineStroke()) != null)
+ {
+ plot.setRangeGridlineStroke(findStroke(getRangeGridlineStroke()));
+ }
+ if (findColor(getRangeAxisPaint()) != null)
+ {
+ plot.getRangeAxis().setLabelPaint(findColor(getRangeAxisPaint()));
+ }
+ configureRenderer(plot.getRenderer());
+ }
+
+ public void configureRenderer(CategoryItemRenderer renderer)
+ {
+ // renderer.setItemMargin(0.0);
+
+ // renderer.setBase(arg0);
+ // renderer.setBaseFillPaint(arg0);
+ // renderer.setBaseItemLabelFont(arg0);
+ // renderer.setBaseItemLabelPaint(arg0);
+ // renderer.setBaseItemLabelsVisible(arg0);
+ // renderer.setBaseOutlinePaint(arg0);
+ // renderer.setBaseOutlineStroke(arg0);
+ // renderer.setBaseSeriesVisible(arg0);
+ // renderer.setBaseSeriesVisibleInLegend(arg0);
+ // renderer.setBaseShape(arg0);
+ // renderer.setBaseStroke();
+ // renderer.setFillPaint(arg0);
+ // renderer.setItemLabelFont(arg0);
+ // renderer.setItemLabelPaint(arg0);
+ // renderer.setItemLabelsVisible(arg0);
+ // renderer.setItemMargin(arg0);
+ // renderer.setOutlinePaint(arg0)
+ // renderer.setOutlineStroke(arg0)
+ // renderer.setPaint(arg0);
+ // renderer.setStroke(arg0);
+
+ // renderer.setBaseOutlineStroke(new BasicStroke(2f,
+ // BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10f,
+ // new float[] {10,3}, 0));
+ }
+
+ public void configureTitle(TextTitle chartTitle)
+ {
+ if (chartTitle != null)
+ {
+ if (findColor(getTitleBackgroundPaint()) != null)
+ {
+ chartTitle.setBackgroundPaint(findColor(getTitleBackgroundPaint()));
+ }
+
+ if (findColor(getTitlePaint()) != null)
+ {
+ chartTitle.setPaint(findColor(getTitlePaint()));
+ }
+ }
+ }
+
+ void configureLegend(LegendTitle chartLegend)
+ {
+ if (chartLegend != null)
+ {
+ if (findColor(getLegendBackgroundPaint()) != null)
+ {
+ chartLegend.setBackgroundPaint(findColor(getLegendBackgroundPaint()));
+ }
+ if (findColor(getLegendItemPaint()) != null)
+ {
+ chartLegend.setItemPaint(findColor(getLegendItemPaint()));
+ }
+ }
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UICell.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UICell.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UICell.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -7,293 +7,352 @@
import javax.faces.context.FacesContext;
-public class UICell
- extends UIRectangle
+public class UICell extends UIRectangle
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UICell";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UICell";
- PdfPCell cell;
- String horizontalAlignment;
- String verticalAlignment;
- Float padding;
- Float paddingLeft;
- Float paddingRight;
- Float paddingTop;
- Float paddingBottom;
- Boolean useBorderPadding;
- Float leading;
- Float multipliedLeading;
- Float indent;
- Float extraParagraphSpace;
- Float fixedHeight;
- Boolean noWrap;
- Float minimumHeight;
- Integer colspan;
- Float followingIndent;
- Float rightIndent;
- Integer spaceCharRatio;
- Integer runDirection;
- Integer arabicOptions;
- Boolean useAscender;
- Float grayFill;
- Integer rotation;
-
- boolean hasContent = false;
-
- public void setGrayFill(Float grayFill) {
- this.grayFill = grayFill;
- }
+ PdfPCell cell;
+ String horizontalAlignment;
+ String verticalAlignment;
+ Float padding;
+ Float paddingLeft;
+ Float paddingRight;
+ Float paddingTop;
+ Float paddingBottom;
+ Boolean useBorderPadding;
+ Float leading;
+ Float multipliedLeading;
+ Float indent;
+ Float extraParagraphSpace;
+ Float fixedHeight;
+ Boolean noWrap;
+ Float minimumHeight;
+ Integer colspan;
+ Float followingIndent;
+ Float rightIndent;
+ Integer spaceCharRatio;
+ Integer runDirection;
+ Integer arabicOptions;
+ Boolean useAscender;
+ Float grayFill;
+ Integer rotation;
- public void setHorizontalAlignment(String horizontalAlignment) {
- this.horizontalAlignment = horizontalAlignment;
- }
+ boolean hasContent = false;
- public void setVerticalAlignment(String verticalAlignment) {
- this.verticalAlignment = verticalAlignment;
- }
+ public void setGrayFill(Float grayFill)
+ {
+ this.grayFill = grayFill;
+ }
- public void setPadding(Float padding) {
- this.padding = padding;
- }
-
- public void setPaddingLeft(Float paddingLeft) {
- this.paddingLeft = paddingLeft;
- }
+ public void setHorizontalAlignment(String horizontalAlignment)
+ {
+ this.horizontalAlignment = horizontalAlignment;
+ }
- public void setPaddingRight(Float paddingRight) {
- this.paddingRight = paddingRight;
- }
+ public void setVerticalAlignment(String verticalAlignment)
+ {
+ this.verticalAlignment = verticalAlignment;
+ }
- public void setPaddingTop(Float paddingTop) {
- this.paddingTop = paddingTop;
- }
+ public void setPadding(Float padding)
+ {
+ this.padding = padding;
+ }
- public void setPaddingBottom(Float paddingBottom) {
- this.paddingBottom = paddingBottom;
- }
+ public void setPaddingLeft(Float paddingLeft)
+ {
+ this.paddingLeft = paddingLeft;
+ }
- public void setUseBorderPadding(Boolean useBorderPadding) {
- this.useBorderPadding = useBorderPadding;
- }
+ public void setPaddingRight(Float paddingRight)
+ {
+ this.paddingRight = paddingRight;
+ }
- public void setLeading(Float leading) {
- this.leading = leading;
- }
+ public void setPaddingTop(Float paddingTop)
+ {
+ this.paddingTop = paddingTop;
+ }
- public void setMultipliedLeading(Float multipliedLeading) {
- this.multipliedLeading = multipliedLeading;
- }
+ public void setPaddingBottom(Float paddingBottom)
+ {
+ this.paddingBottom = paddingBottom;
+ }
- public void setIndent(Float indent) {
- this.indent = indent;
- }
+ public void setUseBorderPadding(Boolean useBorderPadding)
+ {
+ this.useBorderPadding = useBorderPadding;
+ }
- public void setExtraParagraphSpace(Float extraParagraphSpace) {
- this.extraParagraphSpace = extraParagraphSpace;
- }
+ public void setLeading(Float leading)
+ {
+ this.leading = leading;
+ }
- public void setFixedHeight(Float fixedHeight) {
- this.fixedHeight = fixedHeight;
- }
+ public void setMultipliedLeading(Float multipliedLeading)
+ {
+ this.multipliedLeading = multipliedLeading;
+ }
- public void setNoWrap(Boolean noWrap) {
- this.noWrap = noWrap;
- }
+ public void setIndent(Float indent)
+ {
+ this.indent = indent;
+ }
- public void setMinimumHeight(Float minimumHeight) {
- this.minimumHeight = minimumHeight;
- }
+ public void setExtraParagraphSpace(Float extraParagraphSpace)
+ {
+ this.extraParagraphSpace = extraParagraphSpace;
+ }
- public void setColspan(Integer colspan) {
- this.colspan = colspan;
- }
+ public void setFixedHeight(Float fixedHeight)
+ {
+ this.fixedHeight = fixedHeight;
+ }
- public void setFollowingIndent(Float followingIndent) {
- this.followingIndent = followingIndent;
- }
+ public void setNoWrap(Boolean noWrap)
+ {
+ this.noWrap = noWrap;
+ }
- public void setRightIndent(Float rightIndent) {
- this.rightIndent = rightIndent;
- }
+ public void setMinimumHeight(Float minimumHeight)
+ {
+ this.minimumHeight = minimumHeight;
+ }
- public void setSpaceCharRatio(Integer spaceCharRatio) {
- this.spaceCharRatio = spaceCharRatio;
- }
+ public void setColspan(Integer colspan)
+ {
+ this.colspan = colspan;
+ }
- public void setRunDirection(Integer runDirection) {
- this.runDirection = runDirection;
- }
+ public void setFollowingIndent(Float followingIndent)
+ {
+ this.followingIndent = followingIndent;
+ }
- public void setArabicOptions(Integer arabicOptions) {
- this.arabicOptions = arabicOptions;
- }
+ public void setRightIndent(Float rightIndent)
+ {
+ this.rightIndent = rightIndent;
+ }
- public void setUseAscender(Boolean useAscender) {
- this.useAscender = useAscender;
- }
-
- public void setRotation(Integer rotation) {
- this.rotation = rotation;
- }
+ public void setSpaceCharRatio(Integer spaceCharRatio)
+ {
+ this.spaceCharRatio = spaceCharRatio;
+ }
- @Override
- public Object getITextObject() {
- return cell;
- }
+ public void setRunDirection(Integer runDirection)
+ {
+ this.runDirection = runDirection;
+ }
- @Override
- public void removeITextObject() {
- cell = null;
- }
+ public void setArabicOptions(Integer arabicOptions)
+ {
+ this.arabicOptions = arabicOptions;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- PdfPCell defaultCell = getDefaultCellFromTable();
- if (defaultCell != null) {
- cell = new PdfPCell(defaultCell);
- } else {
- cell = new PdfPCell();
- }
-
- horizontalAlignment = (String) valueBinding(context, "horizontalAlignment", horizontalAlignment);
- if (horizontalAlignment != null) {
- cell.setHorizontalAlignment(ITextUtils.alignmentValue(horizontalAlignment));
- }
-
- verticalAlignment = (String) valueBinding(context, "verticalAlignment", verticalAlignment);
- if (verticalAlignment != null) {
- cell.setVerticalAlignment(ITextUtils.alignmentValue(verticalAlignment));
- }
-
- padding = (Float) valueBinding(context, "padding", padding);
- if (padding != null) {
- cell.setPadding(padding);
- }
-
- paddingLeft = (Float) valueBinding(context, "paddingLeft", paddingLeft);
- if (paddingLeft != null) {
- cell.setPaddingLeft(paddingLeft);
- }
-
- paddingRight = (Float) valueBinding(context, "paddingRight", paddingRight);
- if (paddingRight != null) {
- cell.setPaddingRight(paddingRight);
- }
-
- paddingTop = (Float) valueBinding(context, "paddingTop", paddingTop);
- if (paddingTop != null) {
- cell.setPaddingTop(paddingTop);
- }
-
- paddingBottom = (Float) valueBinding(context, "paddingBottom", paddingBottom);
- if (paddingBottom != null) {
- cell.setPaddingBottom(paddingBottom);
- }
-
- useBorderPadding = (Boolean) valueBinding(context, "useBorderPadding", useBorderPadding);
- if (useBorderPadding != null) {
- cell.setUseBorderPadding(useBorderPadding);
- }
-
- leading = (Float) valueBinding(context, "leading", leading);
- multipliedLeading = (Float) valueBinding(context, "multipliedLeading", multipliedLeading);
- if (leading != null || multipliedLeading != null) {
- cell.setLeading(leading == null ? 0 : leading.floatValue(),
- multipliedLeading==null ? 0 : multipliedLeading.floatValue());
- }
-
- indent = (Float) valueBinding(context, "indent", indent);
- if (indent != null) {
- cell.setIndent(indent);
- }
-
- extraParagraphSpace = (Float) valueBinding(context, "extraParagraphSpace", extraParagraphSpace);
- if (extraParagraphSpace != null) {
- cell.setExtraParagraphSpace(extraParagraphSpace);
- }
-
- fixedHeight = (Float) valueBinding(context, "fixedHeight", fixedHeight);
- if (fixedHeight != null) {
- cell.setFixedHeight(fixedHeight);
- }
-
- noWrap = (Boolean) valueBinding(context, "noWrap", noWrap);
- if (noWrap != null) {
- cell.setNoWrap(noWrap);
- }
-
- minimumHeight = (Float) valueBinding(context, "minimumHeight", minimumHeight);
- if (minimumHeight != null) {
- cell.setMinimumHeight(minimumHeight);
- }
-
- colspan = (Integer) valueBinding(context, "colspan", colspan);
- if (colspan != null) {
- cell.setColspan(colspan);
- }
-
- followingIndent = (Float) valueBinding(context, "followingIndent", followingIndent);
- if (followingIndent != null) {
- cell.setFollowingIndent(followingIndent);
- }
- rightIndent = (Float) valueBinding(context, "rightIndent", rightIndent);
- if (rightIndent != null) {
- cell.setRightIndent(rightIndent);
- }
- spaceCharRatio = (Integer) valueBinding(context, "spaceCharRatio", spaceCharRatio);
- if (spaceCharRatio != null) {
- cell.setSpaceCharRatio(spaceCharRatio);
- }
- runDirection = (Integer) valueBinding(context, "runDirection", runDirection);
- if (runDirection != null) {
- cell.setRunDirection(runDirection);
- }
- arabicOptions = (Integer) valueBinding(context, "arabicOptions", arabicOptions);
- if (arabicOptions != null) {
- cell.setArabicOptions(arabicOptions);
- }
- useAscender = (Boolean) valueBinding(context, "useAscender", useAscender);
- if (useAscender != null) {
- cell.setUseAscender(useAscender);
- }
-
- 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);
- }
+ public void setUseAscender(Boolean useAscender)
+ {
+ this.useAscender = useAscender;
+ }
- private PdfPCell getDefaultCellFromTable() {
- UITable parentTable = (UITable) findITextParent(this, UITable.class);
- if (parentTable != null) {
- return parentTable.getDefaultCellFacet();
- }
- return null;
- }
+ public void setRotation(Integer rotation)
+ {
+ this.rotation = rotation;
+ }
- @Override
- public void handleAdd(Object o) {
- if (!hasContent && o instanceof Image) {
- // added by user request, but it mages the logic here rather ugly.
- cell.setImage((Image) o);
-
- } else if (o instanceof Element) {
- if (cell.getImage() != null) {
- cell.addElement(cell.getImage());
- }
- cell.addElement((Element) o);
- } else {
- throw new RuntimeException("Can't add " + o.getClass().getName() +
- " to cell");
- }
- hasContent = true;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return cell;
+ }
+ @Override
+ public void removeITextObject()
+ {
+ cell = null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ PdfPCell defaultCell = getDefaultCellFromTable();
+ if (defaultCell != null)
+ {
+ cell = new PdfPCell(defaultCell);
+ }
+ else
+ {
+ cell = new PdfPCell();
+ }
+
+ horizontalAlignment = (String) valueBinding(context, "horizontalAlignment", horizontalAlignment);
+ if (horizontalAlignment != null)
+ {
+ cell.setHorizontalAlignment(ITextUtils.alignmentValue(horizontalAlignment));
+ }
+
+ verticalAlignment = (String) valueBinding(context, "verticalAlignment", verticalAlignment);
+ if (verticalAlignment != null)
+ {
+ cell.setVerticalAlignment(ITextUtils.alignmentValue(verticalAlignment));
+ }
+
+ padding = (Float) valueBinding(context, "padding", padding);
+ if (padding != null)
+ {
+ cell.setPadding(padding);
+ }
+
+ paddingLeft = (Float) valueBinding(context, "paddingLeft", paddingLeft);
+ if (paddingLeft != null)
+ {
+ cell.setPaddingLeft(paddingLeft);
+ }
+
+ paddingRight = (Float) valueBinding(context, "paddingRight", paddingRight);
+ if (paddingRight != null)
+ {
+ cell.setPaddingRight(paddingRight);
+ }
+
+ paddingTop = (Float) valueBinding(context, "paddingTop", paddingTop);
+ if (paddingTop != null)
+ {
+ cell.setPaddingTop(paddingTop);
+ }
+
+ paddingBottom = (Float) valueBinding(context, "paddingBottom", paddingBottom);
+ if (paddingBottom != null)
+ {
+ cell.setPaddingBottom(paddingBottom);
+ }
+
+ useBorderPadding = (Boolean) valueBinding(context, "useBorderPadding", useBorderPadding);
+ if (useBorderPadding != null)
+ {
+ cell.setUseBorderPadding(useBorderPadding);
+ }
+
+ leading = (Float) valueBinding(context, "leading", leading);
+ multipliedLeading = (Float) valueBinding(context, "multipliedLeading", multipliedLeading);
+ if (leading != null || multipliedLeading != null)
+ {
+ cell.setLeading(leading == null ? 0 : leading.floatValue(), multipliedLeading == null ? 0 : multipliedLeading.floatValue());
+ }
+
+ indent = (Float) valueBinding(context, "indent", indent);
+ if (indent != null)
+ {
+ cell.setIndent(indent);
+ }
+
+ extraParagraphSpace = (Float) valueBinding(context, "extraParagraphSpace", extraParagraphSpace);
+ if (extraParagraphSpace != null)
+ {
+ cell.setExtraParagraphSpace(extraParagraphSpace);
+ }
+
+ fixedHeight = (Float) valueBinding(context, "fixedHeight", fixedHeight);
+ if (fixedHeight != null)
+ {
+ cell.setFixedHeight(fixedHeight);
+ }
+
+ noWrap = (Boolean) valueBinding(context, "noWrap", noWrap);
+ if (noWrap != null)
+ {
+ cell.setNoWrap(noWrap);
+ }
+
+ minimumHeight = (Float) valueBinding(context, "minimumHeight", minimumHeight);
+ if (minimumHeight != null)
+ {
+ cell.setMinimumHeight(minimumHeight);
+ }
+
+ colspan = (Integer) valueBinding(context, "colspan", colspan);
+ if (colspan != null)
+ {
+ cell.setColspan(colspan);
+ }
+
+ followingIndent = (Float) valueBinding(context, "followingIndent", followingIndent);
+ if (followingIndent != null)
+ {
+ cell.setFollowingIndent(followingIndent);
+ }
+ rightIndent = (Float) valueBinding(context, "rightIndent", rightIndent);
+ if (rightIndent != null)
+ {
+ cell.setRightIndent(rightIndent);
+ }
+ spaceCharRatio = (Integer) valueBinding(context, "spaceCharRatio", spaceCharRatio);
+ if (spaceCharRatio != null)
+ {
+ cell.setSpaceCharRatio(spaceCharRatio);
+ }
+ runDirection = (Integer) valueBinding(context, "runDirection", runDirection);
+ if (runDirection != null)
+ {
+ cell.setRunDirection(runDirection);
+ }
+ arabicOptions = (Integer) valueBinding(context, "arabicOptions", arabicOptions);
+ if (arabicOptions != null)
+ {
+ cell.setArabicOptions(arabicOptions);
+ }
+ useAscender = (Boolean) valueBinding(context, "useAscender", useAscender);
+ if (useAscender != null)
+ {
+ cell.setUseAscender(useAscender);
+ }
+
+ 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()
+ {
+ UITable parentTable = (UITable) findITextParent(this, UITable.class);
+ if (parentTable != null)
+ {
+ return parentTable.getDefaultCellFacet();
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ if (!hasContent && o instanceof Image)
+ {
+ // added by user request, but it mages the logic here rather ugly.
+ cell.setImage((Image) o);
+
+ }
+ else if (o instanceof Element)
+ {
+ if (cell.getImage() != null)
+ {
+ cell.addElement(cell.getImage());
+ }
+ cell.addElement((Element) o);
+ }
+ else
+ {
+ throw new RuntimeException("Can't add " + o.getClass().getName() + " to cell");
+ }
+ hasContent = true;
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIChapter.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,31 +3,34 @@
import javax.faces.context.*;
import com.lowagie.text.*;
-public class UIChapter
- extends UISection
+public class UIChapter extends UISection
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIChapter";
-
- Integer number = 1;
-
- public Chapter getChapter() {
- return (Chapter) getSection();
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-
- @Override
- public Object getITextObject() {
- return section;
- }
-
- // removeITextObject, handleAdd set by parent
-
- @Override
- public void createITextObject(FacesContext context) {
- number = (Integer) valueBinding(context, "number", number);
- section = new Chapter("",number);
- }
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIChapter";
+
+ Integer number = 1;
+
+ public Chapter getChapter()
+ {
+ return (Chapter) getSection();
+ }
+
+ public void setNumber(Integer number)
+ {
+ this.number = number;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return section;
+ }
+
+ // removeITextObject, handleAdd set by parent
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ number = (Integer) valueBinding(context, "number", number);
+ section = new Chapter("", number);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -28,323 +28,369 @@
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
-public abstract class UIChart
- extends ITextComponent
+public abstract class UIChart extends ITextComponent
{
- private Image image = null;
- private JFreeChart chart = null;
- private byte[] imageData;
-
- private int height = 300;
- private int width = 400;
-
- private String borderBackgroundPaint;
- private String borderPaint;
- private String borderStroke;
- private boolean borderVisible = true;
-
- private String plotBackgroundPaint;
- private Float plotBackgroundAlpha;
- private Float plotForegroundAlpha;
- private String plotOutlineStroke;
- private String plotOutlinePaint;
-
-
-
- public void setHeight(int height) {
- this.height = height;
- }
-
- public int getHeight() {
- return (Integer) valueBinding(FacesContext.getCurrentInstance(), "height", height);
- }
+ private Image image = null;
+ private JFreeChart chart = null;
+ private byte[] imageData;
- public void setWidth(int width) {
- this.width = width;
- }
-
- public int getWidth() {
- return (Integer) valueBinding(FacesContext.getCurrentInstance(), "width", width);
- }
-
- public void setBorderBackgroundPaint(String backgroundPaint) {
- this.borderBackgroundPaint = backgroundPaint;
- }
-
- public String getBorderBackgroundPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "borderBackgroundPaint", borderBackgroundPaint);
- }
-
- public void setBorderPaint(String borderPaint) {
- this.borderPaint = borderPaint;
- }
-
- public String getBorderPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "borderPaint", borderPaint);
- }
-
- public void setBorderStroke(String borderStroke) {
- this.borderStroke = borderStroke;
- }
-
- public String getBorderStroke() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "borderStroke", borderStroke);
- }
-
- public void setBorderVisible(boolean borderVisible) {
- this.borderVisible = borderVisible;
- }
-
- public boolean getBorderVisible() {
- return (Boolean) valueBinding(FacesContext.getCurrentInstance(), "borderVisible", borderVisible);
- }
-
+ private int height = 300;
+ private int width = 400;
- public void setPlotBackgroundAlpha(Float plotBackgroundAlpha) {
- this.plotBackgroundAlpha = plotBackgroundAlpha;
- }
+ private String borderBackgroundPaint;
+ private String borderPaint;
+ private String borderStroke;
+ private boolean borderVisible = true;
- public Float getPlotBackgroundAlpha() {
- return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundAlpha", plotBackgroundAlpha);
- }
-
- public void setPlotBackgroundPaint(String plotBackgroundPaint) {
- this.plotBackgroundPaint = plotBackgroundPaint;
- }
-
- public String getPlotBackgroundPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundPaint", plotBackgroundPaint);
- }
+ private String plotBackgroundPaint;
+ private Float plotBackgroundAlpha;
+ private Float plotForegroundAlpha;
+ private String plotOutlineStroke;
+ private String plotOutlinePaint;
- public void setPlotForegroundAlpha(Float plotForegroundAlpha) {
- this.plotForegroundAlpha = plotForegroundAlpha;
- }
- public Float getPlotForegroundAlpha() {
- return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotForegroundAlpha", plotForegroundAlpha);
- }
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
- public void setPlotOutlinePaint(String plotOutlinePaint) {
- this.plotOutlinePaint = plotOutlinePaint;
- }
-
- public String getPlotOutlinePaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlinePaint", plotOutlinePaint);
- }
-
- public void setPlotOutlineStroke(String plotOutlineStroke) {
- this.plotOutlineStroke = plotOutlineStroke;
- }
-
- public String getPlotOutlineStroke() {
- return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlineStroke", plotOutlineStroke);
- }
-
-
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
-
- height = (Integer) values[1];
- width = (Integer) values[2];
- borderBackgroundPaint = (String) values[3];
- borderPaint = (String) values[4];
- borderStroke = (String) values[5];
- borderVisible = (Boolean) values[6];
- plotBackgroundPaint = (String) values[7];
- plotBackgroundAlpha = (Float) values[8];
- plotForegroundAlpha = (Float) values[9];
- plotOutlineStroke = (String) values[10];
- plotOutlinePaint = (String) values[11];
- }
+ public int getHeight()
+ {
+ return (Integer) valueBinding(FacesContext.getCurrentInstance(), "height", height);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[12];
-
- values[0] = super.saveState(context);
- values[1] = height;
- values[2] = width;
- values[3] = borderBackgroundPaint;
- values[4] = borderPaint;
- values[5] = borderStroke;
- values[6] = borderVisible;
- values[7] = plotBackgroundPaint;
- values[8] = plotBackgroundAlpha;
- values[9] = plotForegroundAlpha;
- values[10] = plotOutlineStroke;
- values[11] = plotOutlinePaint;
-
- return values;
- }
-
-
- public static Paint findColor(String name) {
- if (name == null || name.length() == 0) {
- return null;
- }
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(name);
-
- if (component != null) {
- if (component instanceof UIColor) {
- return ((UIColor) component).getPaint();
- } else {
- throw new RuntimeException();
- }
- }
-
- return ITextUtils.colorValue(name);
- }
-
- public static Stroke findStroke(String id) {
- if (id == null || id.length() ==0) {
- return null;
- }
-
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(id);
+ public void setWidth(int width)
+ {
+ this.width = width;
+ }
- if (component instanceof UIStroke) {
- return ((UIStroke) component).getStroke();
- } else {
- throw new RuntimeException();
+ public int getWidth()
+ {
+ return (Integer) valueBinding(FacesContext.getCurrentInstance(), "width", width);
+ }
- }
- }
-
- public abstract JFreeChart createChart(FacesContext context);
- public JFreeChart getChart() {
- return chart;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
-
- if (getBorderBackgroundPaint() != null) {
- chart.setBackgroundPaint(findColor(getBorderBackgroundPaint()));
- }
-
- if (getBorderPaint() != null) {
- chart.setBorderPaint(findColor(getBorderPaint()));
- }
-
- if (getBorderStroke() != null) {
- chart.setBorderStroke(findStroke(getBorderStroke()));
- }
+ public void setBorderBackgroundPaint(String backgroundPaint)
+ {
+ this.borderBackgroundPaint = backgroundPaint;
+ }
- chart.setBorderVisible(getBorderVisible());
-
- configurePlot(chart.getPlot());
-
-
- try {
- UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
- if (doc != null) {
- PdfWriter writer = (PdfWriter) doc.getWriter();
- PdfContentByte cb = writer.getDirectContent();
- PdfTemplate tp = cb.createTemplate(getWidth(), getHeight());
- Graphics2D g2 = tp.createGraphics(getWidth(), getHeight(), new DefaultFontMapper());
- chart.draw(g2, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
- g2.dispose();
+ public String getBorderBackgroundPaint()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderBackgroundPaint", borderBackgroundPaint);
+ }
- image = new ImgTemplate(tp);
- } else {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ChartUtilities.writeChartAsJPEG(stream, chart, getWidth(), getHeight());
+ public void setBorderPaint(String borderPaint)
+ {
+ this.borderPaint = borderPaint;
+ }
- imageData = stream.toByteArray();
- stream.close();
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-
+ public String getBorderPaint()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderPaint", borderPaint);
+ }
- public void configurePlot(Plot plot) {
- if (getPlotBackgroundAlpha() != null) {
- plot.setBackgroundAlpha(getPlotBackgroundAlpha());
- }
- if (getPlotForegroundAlpha() != null) {
- plot.setForegroundAlpha(getPlotForegroundAlpha());
- }
- if (getPlotBackgroundPaint() != null) {
- plot.setBackgroundPaint(findColor(getPlotBackgroundPaint()));
- }
- if (getPlotOutlinePaint() != null) {
- plot.setOutlinePaint(findColor(getPlotOutlinePaint()));
- }
- if (getPlotOutlineStroke() != null) {
- plot.setOutlineStroke(findStroke(getPlotOutlineStroke()));
- }
- }
-
- public PlotOrientation plotOrientation(String orientation) {
- if (orientation != null && orientation.equalsIgnoreCase("horizontal")) {
- return PlotOrientation.HORIZONTAL;
- } else {
- return PlotOrientation.VERTICAL;
- }
- }
-
- @Override
- public void encodeBegin(FacesContext context)
- throws IOException
- {
- // bypass super to avoid createITextObject() before the chart is ready
- createDataset();
- chart = createChart(context);
- }
-
-
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- // call create here so that we'll have a valid chart
- createITextObject(context);
+ public void setBorderStroke(String borderStroke)
+ {
+ this.borderStroke = borderStroke;
+ }
- if (imageData != null) {
- ResponseWriter response = context.getResponseWriter();
- response.startElement("img", null);
- GraphicImageStore store = GraphicImageStore.instance();
- String key = store.put(new ImageWrapper(imageData, Type.IMAGE_JPEG));
- String url = context.getExternalContext().getRequestContextPath() +
- GraphicImageResource.GRAPHIC_IMAGE_RESOURCE_PATH + "/" + key + Type.IMAGE_JPEG.getExtension();
+ public String getBorderStroke()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderStroke", borderStroke);
+ }
- response.writeAttribute("src", url, null);
-
- response.writeAttribute("height", getHeight(), null);
- response.writeAttribute("width", getWidth(), null);
+ public void setBorderVisible(boolean borderVisible)
+ {
+ this.borderVisible = borderVisible;
+ }
- response.endElement("img");
+ public boolean getBorderVisible()
+ {
+ return (Boolean) valueBinding(FacesContext.getCurrentInstance(), "borderVisible", borderVisible);
+ }
- Manager.instance().beforeRedirect();
- }
-
- super.encodeEnd(context);
- }
-
+ public void setPlotBackgroundAlpha(Float plotBackgroundAlpha)
+ {
+ this.plotBackgroundAlpha = plotBackgroundAlpha;
+ }
- @Override
- public Object getITextObject() {
- return image;
- }
+ public Float getPlotBackgroundAlpha()
+ {
+ return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundAlpha", plotBackgroundAlpha);
+ }
- @Override
- public void handleAdd(Object arg0) {
- throw new RuntimeException("No children allowed");
- }
+ public void setPlotBackgroundPaint(String plotBackgroundPaint)
+ {
+ this.plotBackgroundPaint = plotBackgroundPaint;
+ }
- @Override
- public void removeITextObject() {
- image = null;
- chart = null;
- }
+ public String getPlotBackgroundPaint()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundPaint", plotBackgroundPaint);
+ }
-
- public abstract void createDataset();
- public abstract Dataset getDataset();
+ public void setPlotForegroundAlpha(Float plotForegroundAlpha)
+ {
+ this.plotForegroundAlpha = plotForegroundAlpha;
+ }
+
+ public Float getPlotForegroundAlpha()
+ {
+ return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotForegroundAlpha", plotForegroundAlpha);
+ }
+
+ public void setPlotOutlinePaint(String plotOutlinePaint)
+ {
+ this.plotOutlinePaint = plotOutlinePaint;
+ }
+
+ public String getPlotOutlinePaint()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlinePaint", plotOutlinePaint);
+ }
+
+ public void setPlotOutlineStroke(String plotOutlineStroke)
+ {
+ this.plotOutlineStroke = plotOutlineStroke;
+ }
+
+ public String getPlotOutlineStroke()
+ {
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlineStroke", plotOutlineStroke);
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+
+ height = (Integer) values[1];
+ width = (Integer) values[2];
+ borderBackgroundPaint = (String) values[3];
+ borderPaint = (String) values[4];
+ borderStroke = (String) values[5];
+ borderVisible = (Boolean) values[6];
+ plotBackgroundPaint = (String) values[7];
+ plotBackgroundAlpha = (Float) values[8];
+ plotForegroundAlpha = (Float) values[9];
+ plotOutlineStroke = (String) values[10];
+ plotOutlinePaint = (String) values[11];
+ }
+
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[12];
+
+ values[0] = super.saveState(context);
+ values[1] = height;
+ values[2] = width;
+ values[3] = borderBackgroundPaint;
+ values[4] = borderPaint;
+ values[5] = borderStroke;
+ values[6] = borderVisible;
+ values[7] = plotBackgroundPaint;
+ values[8] = plotBackgroundAlpha;
+ values[9] = plotForegroundAlpha;
+ values[10] = plotOutlineStroke;
+ values[11] = plotOutlinePaint;
+
+ return values;
+ }
+
+ public static Paint findColor(String name)
+ {
+ if (name == null || name.length() == 0)
+ {
+ return null;
+ }
+ UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(name);
+
+ if (component != null)
+ {
+ if (component instanceof UIColor)
+ {
+ return ((UIColor) component).getPaint();
+ }
+ else
+ {
+ throw new RuntimeException();
+ }
+ }
+
+ return ITextUtils.colorValue(name);
+ }
+
+ public static Stroke findStroke(String id)
+ {
+ if (id == null || id.length() == 0)
+ {
+ return null;
+ }
+
+ UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(id);
+
+ if (component instanceof UIStroke)
+ {
+ return ((UIStroke) component).getStroke();
+ }
+ else
+ {
+ throw new RuntimeException();
+
+ }
+ }
+
+ public abstract JFreeChart createChart(FacesContext context);
+
+ public JFreeChart getChart()
+ {
+ return chart;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+
+ if (getBorderBackgroundPaint() != null)
+ {
+ chart.setBackgroundPaint(findColor(getBorderBackgroundPaint()));
+ }
+
+ if (getBorderPaint() != null)
+ {
+ chart.setBorderPaint(findColor(getBorderPaint()));
+ }
+
+ if (getBorderStroke() != null)
+ {
+ chart.setBorderStroke(findStroke(getBorderStroke()));
+ }
+
+ chart.setBorderVisible(getBorderVisible());
+
+ configurePlot(chart.getPlot());
+
+ try
+ {
+ UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
+ if (doc != null)
+ {
+ PdfWriter writer = (PdfWriter) doc.getWriter();
+ PdfContentByte cb = writer.getDirectContent();
+ PdfTemplate tp = cb.createTemplate(getWidth(), getHeight());
+ Graphics2D g2 = tp.createGraphics(getWidth(), getHeight(), new DefaultFontMapper());
+ chart.draw(g2, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
+ g2.dispose();
+
+ image = new ImgTemplate(tp);
+ }
+ else
+ {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ChartUtilities.writeChartAsJPEG(stream, chart, getWidth(), getHeight());
+
+ imageData = stream.toByteArray();
+ stream.close();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void configurePlot(Plot plot)
+ {
+ if (getPlotBackgroundAlpha() != null)
+ {
+ plot.setBackgroundAlpha(getPlotBackgroundAlpha());
+ }
+ if (getPlotForegroundAlpha() != null)
+ {
+ plot.setForegroundAlpha(getPlotForegroundAlpha());
+ }
+ if (getPlotBackgroundPaint() != null)
+ {
+ plot.setBackgroundPaint(findColor(getPlotBackgroundPaint()));
+ }
+ if (getPlotOutlinePaint() != null)
+ {
+ plot.setOutlinePaint(findColor(getPlotOutlinePaint()));
+ }
+ if (getPlotOutlineStroke() != null)
+ {
+ plot.setOutlineStroke(findStroke(getPlotOutlineStroke()));
+ }
+ }
+
+ public PlotOrientation plotOrientation(String orientation)
+ {
+ if (orientation != null && orientation.equalsIgnoreCase("horizontal"))
+ {
+ return PlotOrientation.HORIZONTAL;
+ }
+ else
+ {
+ return PlotOrientation.VERTICAL;
+ }
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ // bypass super to avoid createITextObject() before the chart is ready
+ createDataset();
+ chart = createChart(context);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ // call create here so that we'll have a valid chart
+ createITextObject(context);
+
+ if (imageData != null)
+ {
+ ResponseWriter response = context.getResponseWriter();
+ response.startElement("img", null);
+ GraphicImageStore store = GraphicImageStore.instance();
+ String key = store.put(new ImageWrapper(imageData, Type.IMAGE_JPEG));
+ String url = context.getExternalContext().getRequestContextPath() + GraphicImageResource.GRAPHIC_IMAGE_RESOURCE_PATH + "/" + key + Type.IMAGE_JPEG.getExtension();
+
+ response.writeAttribute("src", url, null);
+
+ response.writeAttribute("height", getHeight(), null);
+ response.writeAttribute("width", getWidth(), null);
+
+ response.endElement("img");
+
+ Manager.instance().beforeRedirect();
+ }
+
+ super.encodeEnd(context);
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return image;
+ }
+
+ @Override
+ public void handleAdd(Object arg0)
+ {
+ throw new RuntimeException("No children allowed");
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ image = null;
+ chart = null;
+ }
+
+ public abstract void createDataset();
+
+ public abstract Dataset getDataset();
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -10,193 +10,221 @@
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DefaultPieDataset;
-public class UIChartData
- extends ITextComponent
-{
- private String key;
- private String series;
- private Object value;
- private Float explodedPercent;
-
- private String sectionPaint;
- private String sectionOutlinePaint;
- private String sectionOutlineStroke;
-
- public Object getValue() {
- return valueBinding("value", value);
- }
+public class UIChartData extends ITextComponent
+{
+ private String key;
+ private String series;
+ private Object value;
+ private Float explodedPercent;
- public void setValue(Object value) {
- this.value = value;
- }
-
- public Number getNumericValue() {
- Object val = getValue();
- if (val instanceof Number) {
- return (Number) getValue();
- } else if (val instanceof String) {
- return new BigDecimal((String)val);
- } else {
- throw new RuntimeException("Can't convert " + val.getClass().getName() + " to numeric value");
- }
- }
+ private String sectionPaint;
+ private String sectionOutlinePaint;
+ private String sectionOutlineStroke;
- public String getKey() {
- return (String) valueBinding("key", key);
- }
+ public Object getValue()
+ {
+ return valueBinding("value", value);
+ }
- public void setKey(String key) {
- this.key = key;
- }
-
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+ public Number getNumericValue()
+ {
+ Object val = getValue();
+ if (val instanceof Number)
+ {
+ return (Number) getValue();
+ }
+ else if (val instanceof String)
+ {
+ return new BigDecimal((String) val);
+ }
+ else
+ {
+ throw new RuntimeException("Can't convert " + val.getClass().getName() + " to numeric value");
+ }
+ }
- public String getSeries() {
- String value = (String) valueBinding("series", series);
- if (value == null) {
- UIChartSeries series = (UIChartSeries) findITextParent(this, UIChartSeries.class);
- value = series.getKey();
- }
- return value;
- }
+ public String getKey()
+ {
+ return (String) valueBinding("key", key);
+ }
- public void setSeries(String series) {
- this.series = series;
- }
-
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
- public void setValue(Double value) {
- this.value = value;
- }
+ public String getSeries()
+ {
+ String value = (String) valueBinding("series", series);
+ if (value == null)
+ {
+ UIChartSeries series = (UIChartSeries) findITextParent(this, UIChartSeries.class);
+ value = series.getKey();
+ }
+ return value;
+ }
- public Float getExplodedPercent() {
- return (Float) valueBinding("explodedPercent", explodedPercent);
- }
+ public void setSeries(String series)
+ {
+ this.series = series;
+ }
- public void setExplodedPercent(Float explodedPercent) {
- this.explodedPercent = explodedPercent;
- }
-
+ public void setValue(Double value)
+ {
+ this.value = value;
+ }
- public String getSectionOutlinePaint() {
- return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
- }
+ public Float getExplodedPercent()
+ {
+ return (Float) valueBinding("explodedPercent", explodedPercent);
+ }
- public void setSectionOutlinePaint(String sectionOutlinePaint) {
- this.sectionOutlinePaint = sectionOutlinePaint;
- }
+ public void setExplodedPercent(Float explodedPercent)
+ {
+ this.explodedPercent = explodedPercent;
+ }
- public String getSectionOutlineStroke() {
- return (String) valueBinding("sectionOutlineStroke", sectionOutlineStroke);
- }
+ public String getSectionOutlinePaint()
+ {
+ return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
+ }
- public void setSectionOutlineStroke(String sectionOutlineStroke) {
- this.sectionOutlineStroke = sectionOutlineStroke;
- }
+ public void setSectionOutlinePaint(String sectionOutlinePaint)
+ {
+ this.sectionOutlinePaint = sectionOutlinePaint;
+ }
- public String getSectionPaint() {
- return (String) valueBinding("sectionPaint", sectionPaint);
- }
+ public String getSectionOutlineStroke()
+ {
+ return (String) valueBinding("sectionOutlineStroke", sectionOutlineStroke);
+ }
- public void setSectionPaint(String sectionPaint) {
- this.sectionPaint = sectionPaint;
- }
+ public void setSectionOutlineStroke(String sectionOutlineStroke)
+ {
+ this.sectionOutlineStroke = sectionOutlineStroke;
+ }
-
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
-
- key = (String) values[1];
- //columnKey = (String) values[2];
- series = (String) values[3];
- value = values[4];
- explodedPercent = (Float) values[5];
- sectionPaint = (String) values[6];
- sectionOutlinePaint = (String) values[7];
- sectionOutlineStroke = (String) values[8];
- }
+ public String getSectionPaint()
+ {
+ return (String) valueBinding("sectionPaint", sectionPaint);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[9];
+ public void setSectionPaint(String sectionPaint)
+ {
+ this.sectionPaint = sectionPaint;
+ }
- values[0] = super.saveState(context);
- values[1] = key;
- //values[2] = columnKey;
- values[3] = series;
- values[4] = value;
- values[5] = explodedPercent;
- values[6] = sectionPaint;
- values[7] = sectionOutlinePaint;
- values[8] = sectionOutlineStroke;
-
- return values;
- }
-
-
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- super.encodeEnd(context);
-
- UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
- if (chart != null) {
- Dataset dataset = chart.getDataset();
-
- if (dataset instanceof DefaultPieDataset) {
- DefaultPieDataset piedata = (DefaultPieDataset) dataset;
- piedata.setValue(getKey(), getNumericValue());
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
- PiePlot plot = (PiePlot) chart.getChart().getPlot();
-
- if (getExplodedPercent() != null) {
- plot.setExplodePercent(getKey(), getExplodedPercent());
- }
-
- if (UIChart.findColor(getSectionPaint()) != null) {
- plot.setSectionPaint(getKey(), UIChart.findColor(getSectionPaint()));
- }
-
- if (UIChart.findColor(getSectionOutlinePaint()) != null) {
- plot.setSectionOutlinePaint(getKey(), UIChart.findColor(getSectionOutlinePaint()));
- }
-
- if (UIChart.findStroke(getSectionOutlineStroke()) != null) {
- plot.setSectionOutlineStroke(getKey(), UIChart.findStroke(getSectionOutlineStroke()));
- }
- } else if (dataset instanceof DefaultCategoryDataset) {
- DefaultCategoryDataset data = (DefaultCategoryDataset) dataset;
-
- //CategoryPlot plot = (CategoryPlot) chart.getChart().getPlot();
- data.addValue(getNumericValue(), getSeries(), getKey());
- } else {
- throw new RuntimeException("Cannot add data to dataset of type " + dataset.getClass());
- }
- }
- }
-
- @Override
- public void createITextObject(FacesContext context) {
-
- }
+ key = (String) values[1];
+ // columnKey = (String) values[2];
+ series = (String) values[3];
+ value = values[4];
+ explodedPercent = (Float) values[5];
+ sectionPaint = (String) values[6];
+ sectionOutlinePaint = (String) values[7];
+ sectionOutlineStroke = (String) values[8];
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[9];
- @Override
- public void handleAdd(Object other) {
-
- }
+ values[0] = super.saveState(context);
+ values[1] = key;
+ // values[2] = columnKey;
+ values[3] = series;
+ values[4] = value;
+ values[5] = explodedPercent;
+ values[6] = sectionPaint;
+ values[7] = sectionOutlinePaint;
+ values[8] = sectionOutlineStroke;
- @Override
- public void removeITextObject() {
-
- }
+ return values;
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ super.encodeEnd(context);
+
+ UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
+ if (chart != null)
+ {
+ Dataset dataset = chart.getDataset();
+
+ if (dataset instanceof DefaultPieDataset)
+ {
+ DefaultPieDataset piedata = (DefaultPieDataset) dataset;
+ piedata.setValue(getKey(), getNumericValue());
+
+ PiePlot plot = (PiePlot) chart.getChart().getPlot();
+
+ if (getExplodedPercent() != null)
+ {
+ plot.setExplodePercent(getKey(), getExplodedPercent());
+ }
+
+ if (UIChart.findColor(getSectionPaint()) != null)
+ {
+ plot.setSectionPaint(getKey(), UIChart.findColor(getSectionPaint()));
+ }
+
+ if (UIChart.findColor(getSectionOutlinePaint()) != null)
+ {
+ plot.setSectionOutlinePaint(getKey(), UIChart.findColor(getSectionOutlinePaint()));
+ }
+
+ if (UIChart.findStroke(getSectionOutlineStroke()) != null)
+ {
+ plot.setSectionOutlineStroke(getKey(), UIChart.findStroke(getSectionOutlineStroke()));
+ }
+ }
+ else if (dataset instanceof DefaultCategoryDataset)
+ {
+ DefaultCategoryDataset data = (DefaultCategoryDataset) dataset;
+
+ // CategoryPlot plot = (CategoryPlot) chart.getChart().getPlot();
+ data.addValue(getNumericValue(), getSeries(), getKey());
+ }
+ else
+ {
+ throw new RuntimeException("Cannot add data to dataset of type " + dataset.getClass());
+ }
+ }
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
+
+ @Override
+ public void handleAdd(Object other)
+ {
+
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartSeries.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartSeries.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIChartSeries.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -11,187 +11,217 @@
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.Dataset;
-public class UIChartSeries
- extends ITextComponent
+public class UIChartSeries extends ITextComponent
{
- private String key;
- private String seriesPaint;
- private String seriesFillPaint;
- private String seriesOutlinePaint;
- private String seriesOutlineStroke;
- private String seriesStroke;
- private Boolean seriesVisible;
- private Boolean seriesVisibleInLegend;
-
- public String getKey() {
- return (String) valueBinding("key", key);
- }
+ private String key;
+ private String seriesPaint;
+ private String seriesFillPaint;
+ private String seriesOutlinePaint;
+ private String seriesOutlineStroke;
+ private String seriesStroke;
+ private Boolean seriesVisible;
+ private Boolean seriesVisibleInLegend;
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getSeriesPaint() {
- return (String) valueBinding("seriesPaint", seriesPaint);
- }
+ public String getKey()
+ {
+ return (String) valueBinding("key", key);
+ }
- public void setSeriesPaint(String seriesPaint) {
- this.seriesPaint = seriesPaint;
- }
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
- public String getSeriesFillPaint() {
- return (String) valueBinding("seriesFillPaint", seriesFillPaint);
- }
+ public String getSeriesPaint()
+ {
+ return (String) valueBinding("seriesPaint", seriesPaint);
+ }
- public void setSeriesFillPaint(String seriesFillPaint) {
- this.seriesFillPaint = seriesFillPaint;
- }
+ public void setSeriesPaint(String seriesPaint)
+ {
+ this.seriesPaint = seriesPaint;
+ }
- public String getSeriesOutlinePaint() {
- return (String) valueBinding("seriesOutlinePaint", seriesOutlinePaint);
- }
+ public String getSeriesFillPaint()
+ {
+ return (String) valueBinding("seriesFillPaint", seriesFillPaint);
+ }
- public void setSeriesOutlinePaint(String seriesOutlinePaint) {
- this.seriesOutlinePaint = seriesOutlinePaint;
- }
+ public void setSeriesFillPaint(String seriesFillPaint)
+ {
+ this.seriesFillPaint = seriesFillPaint;
+ }
- public String getSeriesOutlineStroke() {
- return (String) valueBinding("seriesOutlineStroke", seriesOutlineStroke);
- }
+ public String getSeriesOutlinePaint()
+ {
+ return (String) valueBinding("seriesOutlinePaint", seriesOutlinePaint);
+ }
- public void setSeriesOutlineStroke(String seriesOutlineStroke) {
- this.seriesOutlineStroke = seriesOutlineStroke;
- }
+ public void setSeriesOutlinePaint(String seriesOutlinePaint)
+ {
+ this.seriesOutlinePaint = seriesOutlinePaint;
+ }
- public String getSeriesStroke() {
- return (String) valueBinding("seriesStroke", seriesStroke);
- }
+ public String getSeriesOutlineStroke()
+ {
+ return (String) valueBinding("seriesOutlineStroke", seriesOutlineStroke);
+ }
- public void setSeriesStroke(String seriesStroke) {
- this.seriesStroke = seriesStroke;
- }
+ public void setSeriesOutlineStroke(String seriesOutlineStroke)
+ {
+ this.seriesOutlineStroke = seriesOutlineStroke;
+ }
- public Boolean getSeriesVisible() {
- return (Boolean) valueBinding("seriesVisible", seriesVisible);
- }
+ public String getSeriesStroke()
+ {
+ return (String) valueBinding("seriesStroke", seriesStroke);
+ }
- public void setSeriesVisible(Boolean seriesVisible) {
- this.seriesVisible = seriesVisible;
- }
+ public void setSeriesStroke(String seriesStroke)
+ {
+ this.seriesStroke = seriesStroke;
+ }
- public Boolean getSeriesVisibleInLegend() {
- return (Boolean) valueBinding("seriesVisibleInLegend", seriesVisibleInLegend);
- }
+ public Boolean getSeriesVisible()
+ {
+ return (Boolean) valueBinding("seriesVisible", seriesVisible);
+ }
- public void setSeriesVisibleInLegend(Boolean seriesVisibleInLegend) {
- this.seriesVisibleInLegend = seriesVisibleInLegend;
- }
+ public void setSeriesVisible(Boolean seriesVisible)
+ {
+ this.seriesVisible = seriesVisible;
+ }
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
-
- key = (String) values[1];
- seriesPaint = (String) values[2];
- seriesFillPaint = (String) values[3];
- seriesOutlinePaint = (String) values[4];
- seriesOutlineStroke = (String) values[5];
- seriesStroke = (String) values[6];
- seriesVisible = (Boolean) values[7];
- seriesVisibleInLegend = (Boolean) values[8];
- }
+ public Boolean getSeriesVisibleInLegend()
+ {
+ return (Boolean) valueBinding("seriesVisibleInLegend", seriesVisibleInLegend);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[9];
+ public void setSeriesVisibleInLegend(Boolean seriesVisibleInLegend)
+ {
+ this.seriesVisibleInLegend = seriesVisibleInLegend;
+ }
- values[0] = super.saveState(context);
- values[1] = key;
- values[2] = seriesPaint;
- values[3] = seriesFillPaint;
- values[4] = seriesOutlinePaint;
- values[5] = seriesOutlineStroke;
- values[6] = seriesStroke;
- values[7] = seriesVisible;
- values[8] = seriesVisibleInLegend;
-
- return values;
- }
-
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
- Dataset dataset = chart.getDataset();
- if (chart != null) {
- Plot p = chart.getChart().getPlot();
- if (p instanceof CategoryPlot) {
- CategoryPlot plot = (CategoryPlot) p;
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
- int seriesIndex = ((CategoryDataset) dataset).getRowIndex(getKey());
+ key = (String) values[1];
+ seriesPaint = (String) values[2];
+ seriesFillPaint = (String) values[3];
+ seriesOutlinePaint = (String) values[4];
+ seriesOutlineStroke = (String) values[5];
+ seriesStroke = (String) values[6];
+ seriesVisible = (Boolean) values[7];
+ seriesVisibleInLegend = (Boolean) values[8];
+ }
- CategoryItemRenderer renderer = plot.getRenderer();
-
- // CategoryRenderer
- if (renderer instanceof AbstractRenderer) {
- configureSeries((AbstractRenderer) renderer,seriesIndex);
- } else {
- System.out.println("render is not AbtractRenderer" + renderer);
- }
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[9];
+
+ values[0] = super.saveState(context);
+ values[1] = key;
+ values[2] = seriesPaint;
+ values[3] = seriesFillPaint;
+ values[4] = seriesOutlinePaint;
+ values[5] = seriesOutlineStroke;
+ values[6] = seriesStroke;
+ values[7] = seriesVisible;
+ values[8] = seriesVisibleInLegend;
+
+ return values;
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
+ Dataset dataset = chart.getDataset();
+ if (chart != null)
+ {
+ Plot p = chart.getChart().getPlot();
+ if (p instanceof CategoryPlot)
+ {
+ CategoryPlot plot = (CategoryPlot) p;
+
+ int seriesIndex = ((CategoryDataset) dataset).getRowIndex(getKey());
+
+ CategoryItemRenderer renderer = plot.getRenderer();
+
+ // CategoryRenderer
+ if (renderer instanceof AbstractRenderer)
+ {
+ configureSeries((AbstractRenderer) renderer, seriesIndex);
}
- }
+ else
+ {
+ System.out.println("render is not AbtractRenderer" + renderer);
+ }
+ }
+ }
- }
-
-
- private void configureSeries(AbstractRenderer renderer, int seriesIndex) {
- if (getSeriesPaint() != null) {
- renderer.setSeriesPaint(seriesIndex, UIChart.findColor(getSeriesPaint()));
- }
+ }
- if (getSeriesFillPaint() != null) {
- renderer.setSeriesFillPaint(seriesIndex, UIChart.findColor(getSeriesFillPaint()));
- }
+ private void configureSeries(AbstractRenderer renderer, int seriesIndex)
+ {
+ if (getSeriesPaint() != null)
+ {
+ renderer.setSeriesPaint(seriesIndex, UIChart.findColor(getSeriesPaint()));
+ }
- if (getSeriesOutlinePaint() != null) {
- renderer.setSeriesOutlinePaint(seriesIndex, UIChart.findColor(getSeriesOutlinePaint()));
- }
+ if (getSeriesFillPaint() != null)
+ {
+ renderer.setSeriesFillPaint(seriesIndex, UIChart.findColor(getSeriesFillPaint()));
+ }
- if (getSeriesOutlineStroke() != null) {
- renderer.setSeriesOutlineStroke(seriesIndex, UIChart.findStroke(getSeriesOutlineStroke()));
- }
+ if (getSeriesOutlinePaint() != null)
+ {
+ renderer.setSeriesOutlinePaint(seriesIndex, UIChart.findColor(getSeriesOutlinePaint()));
+ }
- if (getSeriesStroke() != null) {
- renderer.setSeriesStroke(seriesIndex, UIChart.findStroke(getSeriesStroke()));
- }
-
- if (getSeriesVisible() != null) {
- renderer.setSeriesVisible(seriesIndex, getSeriesVisible());
- }
-
- if (getSeriesVisibleInLegend() != null) {
- renderer.setSeriesVisibleInLegend(seriesIndex, getSeriesVisibleInLegend());
- }
- }
+ if (getSeriesOutlineStroke() != null)
+ {
+ renderer.setSeriesOutlineStroke(seriesIndex, UIChart.findStroke(getSeriesOutlineStroke()));
+ }
- @Override
- public void createITextObject(FacesContext context) {
- }
+ if (getSeriesStroke() != null)
+ {
+ renderer.setSeriesStroke(seriesIndex, UIChart.findStroke(getSeriesStroke()));
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ if (getSeriesVisible() != null)
+ {
+ renderer.setSeriesVisible(seriesIndex, getSeriesVisible());
+ }
- @Override
- public void removeITextObject() {
- }
-
- @Override
- public void handleAdd(Object other) {
- }
+ if (getSeriesVisibleInLegend() != null)
+ {
+ renderer.setSeriesVisibleInLegend(seriesIndex, getSeriesVisibleInLegend());
+ }
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ }
+
+ @Override
+ public void handleAdd(Object other)
+ {
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIColor.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIColor.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIColor.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -10,74 +10,86 @@
import org.jboss.seam.pdf.ITextUtils;
-public class UIColor
- extends UIComponentBase
+public class UIColor extends UIComponentBase
{
- String color;
- String color2;
-
- String point;
- String point2;
-
- public void setColor(String color) {
- this.color = color;
- }
-
- public String getColor() {
- return (color != null) ? color : (String) evalExpression("color");
- }
-
- public void setColor2(String color2) {
- this.color2 = color2;
- }
-
- public String getColor2() {
- return (color2 != null) ? color2 : (String) evalExpression("color2");
- }
-
- public void setPoint(String point) {
- this.point = point;
- }
-
- public String getPoint() {
- return (point != null) ? point : (String) evalExpression("point");
- }
-
- public void setPoint2(String point2) {
- this.point2 = point2;
- }
-
- public String getPoint2() {
- return (point2 != null) ? point2 : (String) evalExpression("point2");
- }
+ String color;
+ String color2;
- @Override
- public String getFamily() {
- return ITextComponent.COMPONENT_FAMILY;
- }
-
- public Object evalExpression(String el) {
- ValueExpression expr = getValueExpression(el);
- return (expr == null) ?
- null : expr.getValue(FacesContext.getCurrentInstance().getELContext());
- }
+ String point;
+ String point2;
- public Point2D pointValue(String string) {
- Point2D point = new Point2D.Float();
- float[] vals = ITextUtils.stringToFloatArray(string);
- point.setLocation(vals[0],vals[1]);
- return point;
- }
-
- public Paint getPaint() {
- String c1 = getColor();
- String c2 = getColor2();
-
- if (c2 == null) {
- return ITextUtils.colorValue(c1);
- } else {
- return new GradientPaint(pointValue(getPoint()),ITextUtils.colorValue(c1),
- pointValue(getPoint()),ITextUtils.colorValue(c2));
- }
- }
+ public void setColor(String color)
+ {
+ this.color = color;
+ }
+
+ public String getColor()
+ {
+ return (color != null) ? color : (String) evalExpression("color");
+ }
+
+ public void setColor2(String color2)
+ {
+ this.color2 = color2;
+ }
+
+ public String getColor2()
+ {
+ return (color2 != null) ? color2 : (String) evalExpression("color2");
+ }
+
+ public void setPoint(String point)
+ {
+ this.point = point;
+ }
+
+ public String getPoint()
+ {
+ return (point != null) ? point : (String) evalExpression("point");
+ }
+
+ public void setPoint2(String point2)
+ {
+ this.point2 = point2;
+ }
+
+ public String getPoint2()
+ {
+ return (point2 != null) ? point2 : (String) evalExpression("point2");
+ }
+
+ @Override
+ public String getFamily()
+ {
+ return ITextComponent.COMPONENT_FAMILY;
+ }
+
+ public Object evalExpression(String el)
+ {
+ ValueExpression expr = getValueExpression(el);
+ return (expr == null) ? null : expr.getValue(FacesContext.getCurrentInstance().getELContext());
+ }
+
+ public Point2D pointValue(String string)
+ {
+ Point2D point = new Point2D.Float();
+ float[] vals = ITextUtils.stringToFloatArray(string);
+ point.setLocation(vals[0], vals[1]);
+ return point;
+ }
+
+ public Paint getPaint()
+ {
+ String c1 = getColor();
+ String c2 = getColor2();
+
+ if (c2 == null)
+ {
+ return ITextUtils.colorValue(c1);
+ }
+ else
+ {
+ return new GradientPaint(pointValue(getPoint()), ITextUtils.colorValue(c1), pointValue(getPoint()), ITextUtils.colorValue(c2));
+ }
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -26,336 +26,397 @@
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.rtf.RtfWriter2;
-public class UIDocument
- extends ITextComponent
+public class UIDocument extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIDocument";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIDocument";
- public static DocumentType PDF = new DocumentType("pdf", "application/pdf");
- public static DocumentType RTF = new DocumentType("rtf", "text/rtf");
- public static DocumentType HTML = new DocumentType("html", "text/html");
-
- DocWriter writer;
- Document document;
- ByteArrayOutputStream stream;
+ public static DocumentType PDF = new DocumentType("pdf", "application/pdf");
+ public static DocumentType RTF = new DocumentType("rtf", "text/rtf");
+ public static DocumentType HTML = new DocumentType("html", "text/html");
- DocumentType documentType;
+ DocWriter writer;
+ Document document;
+ ByteArrayOutputStream stream;
- String type;
- String title;
- String subject;
- String keywords;
- String author;
- String creator;
- String orientation;
+ DocumentType documentType;
- String pageSize;
- String margins;
- Boolean marginMirroring;
+ String type;
+ String title;
+ String subject;
+ String keywords;
+ String author;
+ String creator;
+ String orientation;
- String disposition;
- String fileName;
-
- boolean sendRedirect = true;
+ String pageSize;
+ String margins;
+ Boolean marginMirroring;
- UISignature signatureField;
+ String disposition;
+ String fileName;
- public void setDisposition(String disposition) {
- this.disposition = disposition;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
+ boolean sendRedirect = true;
- public void setType(String type) {
- this.type = type;
- }
+ UISignature signatureField;
- public void setMargins(String margins) {
- this.margins = margins;
- }
+ public void setDisposition(String disposition)
+ {
+ this.disposition = disposition;
+ }
- public void setPageSize(String pageSize) {
- this.pageSize = pageSize;
- }
+ public void setFileName(String fileName)
+ {
+ this.fileName = fileName;
+ }
- public void setMarginMirroring(Boolean marginMirroring) {
- this.marginMirroring = marginMirroring;
- }
+ public void setType(String type)
+ {
+ this.type = type;
+ }
- public void setAuthor(String author) {
- this.author = author;
- }
+ public void setMargins(String margins)
+ {
+ this.margins = margins;
+ }
- public void setCreator(String creator) {
- this.creator = creator;
- }
+ public void setPageSize(String pageSize)
+ {
+ this.pageSize = pageSize;
+ }
- public void setKeywords(String keywords) {
- this.keywords = keywords;
- }
+ public void setMarginMirroring(Boolean marginMirroring)
+ {
+ this.marginMirroring = marginMirroring;
+ }
- public void setSubject(String subject) {
- this.subject = subject;
- }
+ public void setAuthor(String author)
+ {
+ this.author = author;
+ }
- public void setTitle(String title) {
- this.title = title;
- }
+ public void setCreator(String creator)
+ {
+ this.creator = creator;
+ }
- public void setOrientation(String orientation) {
- this.orientation = orientation;
- }
+ public void setKeywords(String keywords)
+ {
+ this.keywords = keywords;
+ }
+ public void setSubject(String subject)
+ {
+ this.subject = subject;
+ }
- public void setSendRedirect(boolean sendRedirect) {
- this.sendRedirect = sendRedirect;
- }
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
- public boolean getSendRedirect() {
- return sendRedirect;
- }
+ public void setOrientation(String orientation)
+ {
+ this.orientation = orientation;
+ }
+ public void setSendRedirect(boolean sendRedirect)
+ {
+ this.sendRedirect = sendRedirect;
+ }
- @Override
- public Object getITextObject() {
- return document;
- }
+ public boolean getSendRedirect()
+ {
+ return sendRedirect;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- type = (String) valueBinding(context, "type", type);
- documentType = documentTypeForName(type);
+ @Override
+ public Object getITextObject()
+ {
+ return document;
+ }
- document = new Document();
- // most of this needs to be done BEFORE document.open();
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ type = (String) valueBinding(context, "type", type);
+ documentType = documentTypeForName(type);
- pageSize = (String) valueBinding(context, "pageSize", pageSize);
- if (pageSize != null) {
- document.setPageSize(ITextUtils.pageSizeValue(pageSize));
- }
+ document = new Document();
+ // most of this needs to be done BEFORE document.open();
- orientation = (String) valueBinding(context, "orientation", orientation);
- if (orientation != null) {
- if (orientation.equalsIgnoreCase("portrait")) {
- // do nothing
- } else if (orientation.equalsIgnoreCase("landscape")) {
- Rectangle currentSize = document.getPageSize();
- document.setPageSize(new Rectangle(currentSize.getHeight(),
- currentSize.getWidth()));
- } else {
- throw new RuntimeException("orientation value " + orientation + "unknown");
- }
- }
+ pageSize = (String) valueBinding(context, "pageSize", pageSize);
+ if (pageSize != null)
+ {
+ document.setPageSize(ITextUtils.pageSizeValue(pageSize));
+ }
- margins = (String) valueBinding(context, "margins", margins);
- if (margins != null) {
- float[] vals = ITextUtils.stringToFloatArray(margins);
- if (vals.length != 4) {
- throw new RuntimeException("margins must contain 4 float values");
- }
+ orientation = (String) valueBinding(context, "orientation", orientation);
+ if (orientation != null)
+ {
+ if (orientation.equalsIgnoreCase("portrait"))
+ {
+ // do nothing
+ }
+ else if (orientation.equalsIgnoreCase("landscape"))
+ {
+ Rectangle currentSize = document.getPageSize();
+ document.setPageSize(new Rectangle(currentSize.getHeight(), currentSize.getWidth()));
+ }
+ else
+ {
+ throw new RuntimeException("orientation value " + orientation + "unknown");
+ }
+ }
- document.setMargins(vals[0], vals[1], vals[2], vals[3]);
- }
+ margins = (String) valueBinding(context, "margins", margins);
+ if (margins != null)
+ {
+ float[] vals = ITextUtils.stringToFloatArray(margins);
+ if (vals.length != 4)
+ {
+ throw new RuntimeException("margins must contain 4 float values");
+ }
- marginMirroring = (Boolean) valueBinding(context, "marginMirroring", marginMirroring);
- if (marginMirroring != null) {
- document.setMarginMirroring(marginMirroring);
- }
- }
+ document.setMargins(vals[0], vals[1], vals[2], vals[3]);
+ }
- protected void initMetaData(FacesContext context) {
- title = (String) valueBinding(context, "title", title);
- if (title != null) {
- document.addTitle(title);
- }
+ marginMirroring = (Boolean) valueBinding(context, "marginMirroring", marginMirroring);
+ if (marginMirroring != null)
+ {
+ document.setMarginMirroring(marginMirroring);
+ }
+ }
- subject = (String) valueBinding(context, "subject", subject);
- if (subject != null) {
- document.addSubject(subject);
- }
+ protected void initMetaData(FacesContext context)
+ {
+ title = (String) valueBinding(context, "title", title);
+ if (title != null)
+ {
+ document.addTitle(title);
+ }
- keywords = (String) valueBinding(context, "keywords", keywords);
- if (keywords != null) {
- document.addKeywords(keywords);
- }
+ subject = (String) valueBinding(context, "subject", subject);
+ if (subject != null)
+ {
+ document.addSubject(subject);
+ }
- author = (String) valueBinding(context, "author", author);
- if (author != null) {
- document.addAuthor(author);
- }
+ keywords = (String) valueBinding(context, "keywords", keywords);
+ if (keywords != null)
+ {
+ document.addKeywords(keywords);
+ }
- creator = (String) valueBinding(context, "creator", creator);
- if (creator != null) {
- document.addCreator(creator);
- }
- }
+ author = (String) valueBinding(context, "author", author);
+ if (author != null)
+ {
+ document.addAuthor(author);
+ }
- @Override
- public void removeITextObject() {
- document = null;
- }
+ creator = (String) valueBinding(context, "creator", creator);
+ if (creator != null)
+ {
+ document.addCreator(creator);
+ }
+ }
- @Override
- public void handleAdd(Object o) {
- if (o instanceof Element) {
- try {
- document.add((Element) o);
- } catch (DocumentException e) {
- throw new RuntimeException(e);
- }
- } else {
- throw new IllegalArgumentException("cannot add " + o);
- }
- }
+ @Override
+ public void removeITextObject()
+ {
+ document = null;
+ }
- public void addSignature(UISignature signatureField) {
- this.signatureField = signatureField;
- }
+ @Override
+ public void handleAdd(Object o)
+ {
+ if (o instanceof Element)
+ {
+ try
+ {
+ document.add((Element) o);
+ }
+ catch (DocumentException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("cannot add " + o);
+ }
+ }
-
- @Override
- public void encodeBegin(FacesContext context)
- throws IOException
- {
- super.encodeBegin(context);
+ public void addSignature(UISignature signatureField)
+ {
+ this.signatureField = signatureField;
+ }
- stream = new ByteArrayOutputStream();
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
- try {
- writer = createWriterForStream(stream);
+ stream = new ByteArrayOutputStream();
- initMetaData(context);
- processHeaders();
+ try
+ {
+ writer = createWriterForStream(stream);
- document.open();
- } catch (DocumentException e) {
+ initMetaData(context);
+ processHeaders();
+
+ document.open();
+ }
+ catch (DocumentException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void processHeaders()
+ {
+ Object facet = getFacet("header");
+
+ if (facet == null)
+ {
+ return;
+ }
+
+ if (facet instanceof UIComponent)
+ {
+ try
+ {
+ encode(FacesContext.getCurrentInstance(), (UIComponent) facet);
+ }
+ catch (Exception e)
+ {
throw new RuntimeException(e);
- }
- }
-
-
- protected void processHeaders() {
- Object facet = getFacet("header");
+ }
+ }
+ }
- if (facet == null) {
- return;
- }
+ protected String baseNameForViewId(String viewId)
+ {
+ int pos = viewId.lastIndexOf("/");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(pos + 1);
+ }
- if (facet instanceof UIComponent) {
- try {
- encode(FacesContext.getCurrentInstance(), (UIComponent) facet);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
+ pos = viewId.lastIndexOf(".");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(0, pos);
+ }
+ return viewId;
+ }
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ document.close();
- protected String baseNameForViewId(String viewId) {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1) {
- viewId = viewId.substring(pos+1);
- }
+ byte[] bytes = stream.toByteArray();
- pos = viewId.lastIndexOf(".");
- if (pos!=-1) {
- viewId = viewId.substring(0,pos);
- }
+ if (signatureField != null)
+ {
+ bytes = signatureField.sign(bytes);
+ }
- return viewId;
- }
+ String viewId = Pages.getViewId(context);
+ String baseName = baseNameForViewId(viewId);
-
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- document.close();
+ DocumentData documentData = new DocumentData(baseName, documentType, bytes);
+ String dispositionValue = (String) valueBinding(context, "disposition", disposition);
+ if (dispositionValue != null)
+ {
+ documentData.setDisposition(dispositionValue);
+ }
- byte[] bytes = stream.toByteArray();
+ String fileNameValue = (String) valueBinding(context, "fileName", fileName);
+ if (fileNameValue != null)
+ {
+ documentData.setFilename(fileNameValue);
+ }
- if (signatureField != null) {
- bytes = signatureField.sign(bytes);
- }
-
- String viewId = Pages.getViewId(context);
- String baseName = baseNameForViewId(viewId);
-
- DocumentData documentData = new DocumentData(baseName, documentType, bytes);
- String dispositionValue = (String) valueBinding(context, "disposition", disposition);
- if (dispositionValue != null) {
- documentData.setDisposition(dispositionValue);
- }
-
- String fileNameValue = (String) valueBinding(context, "fileName", fileName);
- if (fileNameValue != null) {
- documentData.setFilename(fileNameValue);
- }
+ if (sendRedirect)
+ {
+ DocumentStore store = DocumentStore.instance();
+ String id = store.newId();
- if (sendRedirect) {
- DocumentStore store = DocumentStore.instance();
- String id = store.newId();
+ String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
+ url = Manager.instance().encodeConversationId(url, viewId);
- String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
- url = Manager.instance().encodeConversationId(url, viewId);
+ store.saveData(id, documentData);
- store.saveData(id, documentData);
-
- removeITextObject();
+ removeITextObject();
- context.getExternalContext().redirect(url);
- } else {
- UIComponent parent = getParent();
+ context.getExternalContext().redirect(url);
+ }
+ else
+ {
+ UIComponent parent = getParent();
- if (parent instanceof ValueHolder) {
- ValueHolder holder = (ValueHolder) parent;
- holder.setValue(documentData);
- }
- }
- }
+ if (parent instanceof ValueHolder)
+ {
+ ValueHolder holder = (ValueHolder) parent;
+ holder.setValue(documentData);
+ }
+ }
+ }
+ public DocWriter getWriter()
+ {
+ return writer;
+ }
- public DocWriter getWriter() {
- return writer;
- }
-
- public PdfContentByte getPdfContent() {
- PdfWriter writer = (PdfWriter) getWriter();
- return writer.getDirectContent();
- }
-
- public PdfTemplate createPdfTemplate(float width, float height) {
- return getPdfContent().createTemplate(width, height);
- }
-
- private DocumentType documentTypeForName(String typeName) {
- if (typeName != null) {
- if (typeName.equalsIgnoreCase("pdf")) {
- return PDF;
- } else if (typeName.equalsIgnoreCase("rtf")) {
- return RTF;
- } else if (typeName.equalsIgnoreCase("html")) {
- return HTML;
- }
- }
- return PDF;
- }
-
+ public PdfContentByte getPdfContent()
+ {
+ PdfWriter writer = (PdfWriter) getWriter();
+ return writer.getDirectContent();
+ }
- protected DocWriter createWriterForStream(OutputStream stream)
- throws DocumentException
- {
- if (documentType == PDF) {
- return PdfWriter.getInstance(document, stream);
- } else if (documentType == RTF) {
- return RtfWriter2.getInstance(document, stream);
- } else if (documentType == HTML) {
- return HtmlWriter.getInstance(document, stream);
- }
-
- throw new IllegalArgumentException("unknown document type");
- }
+ public PdfTemplate createPdfTemplate(float width, float height)
+ {
+ return getPdfContent().createTemplate(width, height);
+ }
+
+ private DocumentType documentTypeForName(String typeName)
+ {
+ if (typeName != null)
+ {
+ if (typeName.equalsIgnoreCase("pdf"))
+ {
+ return PDF;
+ }
+ else if (typeName.equalsIgnoreCase("rtf"))
+ {
+ return RTF;
+ }
+ else if (typeName.equalsIgnoreCase("html"))
+ {
+ return HTML;
+ }
+ }
+ return PDF;
+ }
+
+ protected DocWriter createWriterForStream(OutputStream stream) throws DocumentException
+ {
+ if (documentType == PDF)
+ {
+ return PdfWriter.getInstance(document, stream);
+ }
+ else if (documentType == RTF)
+ {
+ return RtfWriter2.getInstance(document, stream);
+ }
+ else if (documentType == HTML)
+ {
+ return HtmlWriter.getInstance(document, stream);
+ }
+
+ throw new IllegalArgumentException("unknown document type");
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIElement.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIElement.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIElement.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -4,33 +4,37 @@
import com.lowagie.text.Element;
-public class UIElement
- extends ITextComponent
+public class UIElement extends ITextComponent
{
- Element element;
-
- public void setValue(Element element) {
- this.element = element;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- element = (Element) valueBinding(context, "value", element);
- }
+ Element element;
- @Override
- public Object getITextObject() {
- return element;
- }
+ public void setValue(Element element)
+ {
+ this.element = element;
+ }
- @Override
- public void handleAdd(Object other) {
- throw new RuntimeException("No children allowed");
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ element = (Element) valueBinding(context, "value", element);
+ }
- @Override
- public void removeITextObject() {
- element = null;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return element;
+ }
+ @Override
+ public void handleAdd(Object other)
+ {
+ throw new RuntimeException("No children allowed");
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ element = null;
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIField.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIField.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIField.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -14,10 +14,10 @@
public class UIField extends FormComponent
{
public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf.UIField";
-
+
private String name;
private String value;
-
+
@Override
public void encodeBegin(FacesContext facesContext) throws IOException
{
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIFont.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIFont.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIFont.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -4,99 +4,118 @@
import org.jboss.seam.pdf.ITextUtils;
import com.lowagie.text.*;
-public class UIFont
- extends ITextComponent
+public class UIFont extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIParagraph";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIParagraph";
- Font font;
-
- String name;
- String encoding;
- int size = Font.UNDEFINED;
- String style;
- String color;
+ Font font;
- public String getName() {
- return (String) valueBinding("name", name);
- }
+ String name;
+ String encoding;
+ int size = Font.UNDEFINED;
+ String style;
+ String color;
- public void setFamily(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getEncoding() {
- return (String) valueBinding("encoding", encoding);
- }
+ public String getName()
+ {
+ return (String) valueBinding("name", name);
+ }
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
+ public void setFamily(String name)
+ {
+ this.name = name;
+ }
- public int getSize() {
- return (Integer) valueBinding("size", size);
- }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
- public void setSize(int size) {
- this.size = size;
- }
+ public String getEncoding()
+ {
+ return (String) valueBinding("encoding", encoding);
+ }
- public void setStyle(String style) {
- this.style = style;
- }
- public String getStyle() {
- return (String) valueBinding("style", style);
- }
-
- public String getColor() {
- return (String) valueBinding("color", color);
- }
+ public void setEncoding(String encoding)
+ {
+ this.encoding = encoding;
+ }
- public void setColor(String color) {
- this.color = color;
- }
-
-
- @Override
- public Font getFont() {
- return font;
- }
-
- @Override
- public Object getITextObject() {
- return null; // we don't add to this component, so skip
- }
+ public int getSize()
+ {
+ return (Integer) valueBinding("size", size);
+ }
- @Override
- public void removeITextObject() {
- font = null;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- if (encoding == null) {
- font = FontFactory.getFont(getName(), getSize());
- } else {
- font = FontFactory.getFont(getName(), getEncoding(), getSize());
- }
-
- if (getStyle() != null) {
- font.setStyle(getStyle());
- }
-
- if (getColor() != null) {
- font.setColor(ITextUtils.colorValue(getColor()));
- }
- }
+ public void setSize(int size)
+ {
+ this.size = size;
+ }
- @Override
- public void handleAdd(Object o) {
- addToITextParent(o);
- }
+ public void setStyle(String style)
+ {
+ this.style = style;
+ }
+ public String getStyle()
+ {
+ return (String) valueBinding("style", style);
+ }
+ public String getColor()
+ {
+ return (String) valueBinding("color", color);
+ }
+
+ public void setColor(String color)
+ {
+ this.color = color;
+ }
+
+ @Override
+ public Font getFont()
+ {
+ return font;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return null; // we don't add to this component, so skip
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ font = null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ if (encoding == null)
+ {
+ font = FontFactory.getFont(getName(), getSize());
+ }
+ else
+ {
+ font = FontFactory.getFont(getName(), getEncoding(), getSize());
+ }
+
+ if (getStyle() != null)
+ {
+ font.setStyle(getStyle());
+ }
+
+ if (getColor() != null)
+ {
+ font.setColor(ITextUtils.colorValue(getColor()));
+ }
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ addToITextParent(o);
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIFooter.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIFooter.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIFooter.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,13 +3,16 @@
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);
- }
+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);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -24,16 +24,16 @@
public class UIForm extends FormComponent
{
public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf.UIForm";
-
+
private Log log = Logging.getLog(getClass());
-
+
private String URL;
-
+
PdfReader reader;
PdfStamper stamper;
AcroFields fields;
ByteArrayOutputStream buffer;
-
+
public String getURL()
{
return (String) valueOf("URL", URL);
@@ -43,7 +43,7 @@
{
URL = url;
}
-
+
@Override
public void encodeBegin(FacesContext facesContext) throws IOException
{
@@ -73,7 +73,7 @@
{
throw new FacesException("Could not flush PDF", e);
}
-
+
String viewId = Pages.getViewId(facesContext);
String baseName = baseNameForViewId(viewId);
DocumentStore store = DocumentStore.instance();
@@ -87,7 +87,6 @@
facesContext.getExternalContext().redirect(url);
}
-
public static String baseNameForViewId(String viewId)
{
int pos = viewId.lastIndexOf("/");
@@ -103,8 +102,8 @@
}
return viewId;
- }
-
+ }
+
@Override
public String getFamily()
{
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIGraphics2D.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIGraphics2D.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIGraphics2D.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -9,62 +9,73 @@
import com.lowagie.text.ImgTemplate;
import com.lowagie.text.pdf.PdfTemplate;
-public abstract class UIGraphics2D
- extends ITextComponent
+public abstract class UIGraphics2D extends ITextComponent
{
- private Image image = null;
+ private Image image = null;
- private int height = 300;
- private int width = 400;
+ private int height = 300;
+ private int width = 400;
- public void setHeight(int height) {
- this.height = height;
- }
-
- public int getHeight() {
- return (Integer) valueBinding("height", height);
- }
+ public void setHeight(int height)
+ {
+ this.height = height;
+ }
- public void setWidth(int width) {
- this.width = width;
- }
-
- public int getWidth() {
- return (Integer) valueBinding("width", width);
- }
+ public int getHeight()
+ {
+ return (Integer) valueBinding("height", height);
+ }
- @Override
- public void createITextObject(FacesContext context) {
- UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
- if (doc != null) {
- PdfTemplate tp = doc.createPdfTemplate(getWidth(), getHeight());
- Graphics2D g2 = tp.createGraphics(getWidth(), getHeight());
+ public void setWidth(int width)
+ {
+ this.width = width;
+ }
- render(g2);
- g2.dispose();
+ public int getWidth()
+ {
+ return (Integer) valueBinding("width", width);
+ }
- try {
- image = new ImgTemplate(tp);
- } catch (BadElementException e) {
- throw new RuntimeException(e);
- }
- }
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
+ if (doc != null)
+ {
+ PdfTemplate tp = doc.createPdfTemplate(getWidth(), getHeight());
+ Graphics2D g2 = tp.createGraphics(getWidth(), getHeight());
- public abstract void render(Graphics2D g2);
+ render(g2);
+ g2.dispose();
- @Override
- public void handleAdd(Object arg0) {
- throw new RuntimeException("No children allowed");
- }
+ try
+ {
+ image = new ImgTemplate(tp);
+ }
+ catch (BadElementException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
- @Override
- public void removeITextObject() {
- image = null;
- }
+ public abstract void render(Graphics2D g2);
- @Override
- public Object getITextObject() {
- return image;
- }
+ @Override
+ public void handleAdd(Object arg0)
+ {
+ throw new RuntimeException("No children allowed");
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ image = null;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return image;
+ }
}
\ No newline at end of file
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeader.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeader.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeader.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,15 +3,17 @@
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);
- }
+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);
+ }
}
-
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeaderFooter.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeaderFooter.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIHeaderFooter.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -10,87 +10,106 @@
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Phrase;
-public abstract class UIHeaderFooter
- extends UIRectangle
+public abstract class UIHeaderFooter extends UIRectangle
{
- HeaderFooter header;
- Phrase before;
- Phrase after;
+ HeaderFooter header;
+ Phrase before;
+ Phrase after;
- String alignment;
-
- public UIHeaderFooter() {
- super();
- }
+ String alignment;
- public void setAlignment(String alignment) {
- this.alignment = alignment;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- before = defaultPhrase();
- after = null;
- }
+ public UIHeaderFooter()
+ {
+ super();
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ public void setAlignment(String alignment)
+ {
+ this.alignment = alignment;
+ }
- @Override
- public void handleAdd(Object other) {
- if (after == null) {
- before.add(other);
- } else {
- after.add(other);
- }
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ before = defaultPhrase();
+ after = null;
+ }
- @Override
- public void removeITextObject() {
- before = null;
- after = null;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
- public void markPage() {
- after = defaultPhrase();
- }
+ @Override
+ public void handleAdd(Object other)
+ {
+ if (after == null)
+ {
+ before.add(other);
+ }
+ else
+ {
+ after.add(other);
+ }
+ }
- @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);
- }
- }
+ @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);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIHtmlText.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIHtmlText.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIHtmlText.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -15,133 +15,151 @@
import com.lowagie.text.html.simpleparser.HTMLWorker;
import com.lowagie.text.html.simpleparser.StyleSheet;
-public class UIHtmlText
- extends ITextComponent
- implements ValueHolder
+public class UIHtmlText extends ITextComponent implements ValueHolder
{
- private Converter converter;
- private Object localValue;
+ private Converter converter;
+ private Object localValue;
- @Override
- public boolean getRendersChildren() {
- return true;
- }
-
- @Override
- public void encodeChildren(FacesContext context)
- throws IOException
- {
- ResponseWriter writer = context.getResponseWriter();
-
- StringWriter stringWriter = new StringWriter();
- ResponseWriter cachingResponseWriter = writer.cloneWithWriter(stringWriter);
- context.setResponseWriter(cachingResponseWriter);
- JSF.renderChildren(context, this);
- context.setResponseWriter(writer);
-
- String output = stringWriter.getBuffer().toString();
- addFromHtml(output);
- }
-
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- Object value = getValue();
- if (value!=null) {
- addFromHtml(convert(context,value));
- }
-
- super.encodeEnd(context);
- }
+ @Override
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+ @Override
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ ResponseWriter writer = context.getResponseWriter();
- private void addFromHtml(String html)
- throws IOException
- {
- for (Object o: HTMLWorker.parseToList(new StringReader(html), getStyle())) {
- addToITextParent(o);
- }
+ StringWriter stringWriter = new StringWriter();
+ ResponseWriter cachingResponseWriter = writer.cloneWithWriter(stringWriter);
+ context.setResponseWriter(cachingResponseWriter);
+ JSF.renderChildren(context, this);
+ context.setResponseWriter(writer);
- //paragraph.addAll(HTMLWorker.parseToList(new StringReader(html), getStyle()));
- }
+ String output = stringWriter.getBuffer().toString();
+ addFromHtml(output);
+ }
- /**
- * XXX - this needs some work
- */
- private StyleSheet getStyle() {
- StyleSheet styles = new StyleSheet();
- styles.loadTagStyle("body", "leading", "16,0");
- return styles;
- }
-
-
- protected String convert(FacesContext context, Object value) {
- Converter myConverter = converterForValue(context, value);
- if (myConverter != null) {
- return myConverter.getAsString(context, this, value);
- } else if (value != null) {
- return value.toString();
- } else {
- return "";
- }
- }
-
- protected Converter converterForValue(FacesContext ctx, Object value) {
- if (converter != null) {
- return converter;
- }
-
- if (value != null) {
- try {
- return ctx.getApplication().createConverter(value.getClass());
- } catch (FacesException e) {
- // no converter defined - no problem
- }
- }
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ Object value = getValue();
+ if (value != null)
+ {
+ addFromHtml(convert(context, value));
+ }
- return null;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
+ super.encodeEnd(context);
+ }
- }
+ private void addFromHtml(String html) throws IOException
+ {
+ for (Object o : HTMLWorker.parseToList(new StringReader(html), getStyle()))
+ {
+ addToITextParent(o);
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ // paragraph.addAll(HTMLWorker.parseToList(new StringReader(html),
+ // getStyle()));
+ }
- @Override
- public void removeITextObject() {
- }
-
- @Override
- public void handleAdd(Object other)
- {
- throw new RuntimeException("illegal child element");
- }
-
- public Converter getConverter() {
- return converter;
- }
+ /**
+ * XXX - this needs some work
+ */
+ private StyleSheet getStyle()
+ {
+ StyleSheet styles = new StyleSheet();
+ styles.loadTagStyle("body", "leading", "16,0");
+ return styles;
+ }
- public void setConverter(Converter converter) {
- this.converter = converter;
- }
-
- public Object getValue() {
- return valueBinding(FacesContext.getCurrentInstance(), "value", localValue);
- }
+ protected String convert(FacesContext context, Object value)
+ {
+ Converter myConverter = converterForValue(context, value);
+ if (myConverter != null)
+ {
+ return myConverter.getAsString(context, this, value);
+ }
+ else if (value != null)
+ {
+ return value.toString();
+ }
+ else
+ {
+ return "";
+ }
+ }
- public void setValue(Object value) {
- this.localValue = value;
- }
+ protected Converter converterForValue(FacesContext ctx, Object value)
+ {
+ if (converter != null)
+ {
+ return converter;
+ }
- public Object getLocalValue() {
- return localValue;
- }
+ if (value != null)
+ {
+ try
+ {
+ return ctx.getApplication().createConverter(value.getClass());
+ }
+ catch (FacesException e)
+ {
+ // no converter defined - no problem
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ }
+
+ @Override
+ public void handleAdd(Object other)
+ {
+ throw new RuntimeException("illegal child element");
+ }
+
+ public Converter getConverter()
+ {
+ return converter;
+ }
+
+ public void setConverter(Converter converter)
+ {
+ this.converter = converter;
+ }
+
+ public Object getValue()
+ {
+ return valueBinding(FacesContext.getCurrentInstance(), "value", localValue);
+ }
+
+ public void setValue(Object value)
+ {
+ this.localValue = value;
+ }
+
+ public Object getLocalValue()
+ {
+ return localValue;
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIImage.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIImage.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIImage.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -12,220 +12,261 @@
import com.lowagie.text.DocumentException;
import com.lowagie.text.Image;
-public class UIImage
- extends UIRectangle
+public class UIImage extends UIRectangle
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIImage";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIImage";
- Image image;
-
- Object value;
- float rotation;
- float height;
- float width;
- String alignment;
- String alt;
-
- Float indentationLeft;
- Float indentationRight;
- Float spacingBefore;
- Float spacingAfter;
- Float widthPercentage;
- Float initialRotation;
- String dpi;
- String scalePercent;
-
- Boolean wrap;
- Boolean underlying;
-
- java.awt.Image imageData;
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- public void setRotation(float rotation) {
- this.rotation = rotation;
- }
+ Image image;
- public void setHeight(float height) {
- this.height = height;
- }
+ Object value;
+ float rotation;
+ float height;
+ float width;
+ String alignment;
+ String alt;
- public void setWidth(float width) {
- this.width = width;
- }
+ Float indentationLeft;
+ Float indentationRight;
+ Float spacingBefore;
+ Float spacingAfter;
+ Float widthPercentage;
+ Float initialRotation;
+ String dpi;
+ String scalePercent;
- public void setAlignment(String alignment) {
- this.alignment = alignment;
- }
+ Boolean wrap;
+ Boolean underlying;
- public void setAlt(String alt) {
- this.alt = alt;
- }
+ java.awt.Image imageData;
- public void setWrap(Boolean wrap) {
- this.wrap = wrap;
- }
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
- public void setUnderlying(Boolean underlying) {
- this.underlying = underlying;
- }
+ public void setRotation(float rotation)
+ {
+ this.rotation = rotation;
+ }
- public void setDpi(String dpi) {
- this.dpi = dpi;
- }
+ public void setHeight(float height)
+ {
+ this.height = height;
+ }
- public void setIndentationLeft(Float indentationLeft) {
- this.indentationLeft = indentationLeft;
- }
+ public void setWidth(float width)
+ {
+ this.width = width;
+ }
- public void setIndentationRight(Float indentationRight) {
- this.indentationRight = indentationRight;
- }
+ public void setAlignment(String alignment)
+ {
+ this.alignment = alignment;
+ }
- public void setInitialRotation(Float initialRotation) {
- this.initialRotation = initialRotation;
- }
+ public void setAlt(String alt)
+ {
+ this.alt = alt;
+ }
- public void setSpacingAfter(Float spacingAfter) {
- this.spacingAfter = spacingAfter;
- }
+ public void setWrap(Boolean wrap)
+ {
+ this.wrap = wrap;
+ }
- public void setSpacingBefore(Float spacingBefore) {
- this.spacingBefore = spacingBefore;
- }
+ public void setUnderlying(Boolean underlying)
+ {
+ this.underlying = underlying;
+ }
- public void setWidthPercentage(Float widthPercentage) {
- this.widthPercentage = widthPercentage;
- }
-
- public void setScalePercent(String scalePercent) {
- this.scalePercent = scalePercent;
- }
-
- @Override
- public Object getITextObject() {
- return image;
- }
-
- @Override
- public void removeITextObject() {
- image = null;
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public void createITextObject(FacesContext context) throws IOException, DocumentException {
- value = valueBinding(context, "value", value);
-
- // instance() doesn't work here - we need a new instance
- org.jboss.seam.ui.graphicImage.Image seamImage = new org.jboss.seam.ui.graphicImage.Image();
- if (value instanceof BufferedImage) {
- seamImage.setBufferedImage((BufferedImage)value);
- } else {
- seamImage.setInput(value);
- }
+ public void setDpi(String dpi)
+ {
+ this.dpi = dpi;
+ }
- for (UIComponent cmp : this.getChildren()) {
- if (cmp instanceof ImageTransform) {
- ImageTransform imageTransform = (ImageTransform) cmp;
- imageTransform.applyTransform(seamImage);
- }
- }
+ public void setIndentationLeft(Float indentationLeft)
+ {
+ this.indentationLeft = indentationLeft;
+ }
- byte[] data = seamImage.getImage();
- image = Image.getInstance(data);
-
-
- rotation = (Float) valueBinding(context, "rotation", rotation);
- if (rotation != 0) {
- image.setRotationDegrees(rotation);
- }
+ public void setIndentationRight(Float indentationRight)
+ {
+ this.indentationRight = indentationRight;
+ }
- height = (Float) valueBinding(context, "height", height);
- width = (Float) valueBinding(context, "width", width);
- if (height>0 || width > 0) {
- image.scaleAbsolute(width, height);
- }
+ public void setInitialRotation(Float initialRotation)
+ {
+ this.initialRotation = initialRotation;
+ }
- int alignmentValue = 0;
-
- alignment = (String) valueBinding(context, "alignment", alignment);
- if (alignment != null) {
- alignmentValue = (ITextUtils.alignmentValue(alignment));
- }
-
- wrap = (Boolean) valueBinding(context, "wrap", wrap);
- if (wrap!=null && wrap.booleanValue()) {
- alignmentValue |= Image.TEXTWRAP;
- }
-
- underlying = (Boolean) valueBinding(context, "underlying", underlying);
- if (underlying!= null && underlying.booleanValue()) {
- alignmentValue |= Image.UNDERLYING;
- }
+ public void setSpacingAfter(Float spacingAfter)
+ {
+ this.spacingAfter = spacingAfter;
+ }
- image.setAlignment(alignmentValue);
+ public void setSpacingBefore(Float spacingBefore)
+ {
+ this.spacingBefore = spacingBefore;
+ }
- alt = (String) valueBinding(context, "alt", alt);
- if (alt != null) {
- image.setAlt(alt);
- }
-
- indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
- if (indentationLeft != null) {
- image.setIndentationLeft(indentationLeft);
- }
+ public void setWidthPercentage(Float widthPercentage)
+ {
+ this.widthPercentage = widthPercentage;
+ }
- indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
- if (indentationRight != null) {
- image.setIndentationRight(indentationRight);
- }
-
- spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
- if (spacingBefore != null) {
- image.setSpacingBefore(spacingBefore);
- }
-
- spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
- if (spacingAfter != null) {
- image.setSpacingAfter(spacingAfter);
- }
- widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage);
- if (widthPercentage != null) {
- image.setWidthPercentage(widthPercentage);
- }
-
- initialRotation = (Float) valueBinding(context, "initialRotation", initialRotation);
- if (initialRotation != null) {
- image.setInitialRotation(initialRotation);
- }
-
- dpi = (String) valueBinding(context, "dpi", dpi);
- if (dpi != null) {
- int[] dpiValues = ITextUtils.stringToIntArray(dpi);
- image.setDpi(dpiValues[0], dpiValues[1]);
+ public void setScalePercent(String scalePercent)
+ {
+ this.scalePercent = scalePercent;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return image;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ image = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void createITextObject(FacesContext context) throws IOException, DocumentException
+ {
+ value = valueBinding(context, "value", value);
+
+ // instance() doesn't work here - we need a new instance
+ org.jboss.seam.ui.graphicImage.Image seamImage = new org.jboss.seam.ui.graphicImage.Image();
+ if (value instanceof BufferedImage)
+ {
+ seamImage.setBufferedImage((BufferedImage) value);
+ }
+ else
+ {
+ seamImage.setInput(value);
+ }
+
+ for (UIComponent cmp : this.getChildren())
+ {
+ if (cmp instanceof ImageTransform)
+ {
+ ImageTransform imageTransform = (ImageTransform) cmp;
+ imageTransform.applyTransform(seamImage);
}
-
- applyRectangleProperties(context, image);
-
- scalePercent = (String) valueBinding(context, "scalePercent", scalePercent);
- if (scalePercent != null) {
- float[] scale = ITextUtils.stringToFloatArray(scalePercent);
- if (scale.length == 1) {
- image.scalePercent(scale[0]);
- } else if (scale.length == 2) {
- image.scalePercent(scale[0], scale[1]);
- } else {
- throw new RuntimeException("scalePercent must contain one or two scale percentages");
- }
- }
- }
+ }
- @Override
- public void handleAdd(Object o) {
- throw new RuntimeException("can't add " + o.getClass().getName() + " to image");
- }
+ byte[] data = seamImage.getImage();
+ image = Image.getInstance(data);
+
+ rotation = (Float) valueBinding(context, "rotation", rotation);
+ if (rotation != 0)
+ {
+ image.setRotationDegrees(rotation);
+ }
+
+ height = (Float) valueBinding(context, "height", height);
+ width = (Float) valueBinding(context, "width", width);
+ if (height > 0 || width > 0)
+ {
+ image.scaleAbsolute(width, height);
+ }
+
+ int alignmentValue = 0;
+
+ alignment = (String) valueBinding(context, "alignment", alignment);
+ if (alignment != null)
+ {
+ alignmentValue = (ITextUtils.alignmentValue(alignment));
+ }
+
+ wrap = (Boolean) valueBinding(context, "wrap", wrap);
+ if (wrap != null && wrap.booleanValue())
+ {
+ alignmentValue |= Image.TEXTWRAP;
+ }
+
+ underlying = (Boolean) valueBinding(context, "underlying", underlying);
+ if (underlying != null && underlying.booleanValue())
+ {
+ alignmentValue |= Image.UNDERLYING;
+ }
+
+ image.setAlignment(alignmentValue);
+
+ alt = (String) valueBinding(context, "alt", alt);
+ if (alt != null)
+ {
+ image.setAlt(alt);
+ }
+
+ indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
+ if (indentationLeft != null)
+ {
+ image.setIndentationLeft(indentationLeft);
+ }
+
+ indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
+ if (indentationRight != null)
+ {
+ image.setIndentationRight(indentationRight);
+ }
+
+ spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
+ if (spacingBefore != null)
+ {
+ image.setSpacingBefore(spacingBefore);
+ }
+
+ spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
+ if (spacingAfter != null)
+ {
+ image.setSpacingAfter(spacingAfter);
+ }
+ widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage);
+ if (widthPercentage != null)
+ {
+ image.setWidthPercentage(widthPercentage);
+ }
+
+ initialRotation = (Float) valueBinding(context, "initialRotation", initialRotation);
+ if (initialRotation != null)
+ {
+ image.setInitialRotation(initialRotation);
+ }
+
+ dpi = (String) valueBinding(context, "dpi", dpi);
+ if (dpi != null)
+ {
+ int[] dpiValues = ITextUtils.stringToIntArray(dpi);
+ image.setDpi(dpiValues[0], dpiValues[1]);
+ }
+
+ applyRectangleProperties(context, image);
+
+ scalePercent = (String) valueBinding(context, "scalePercent", scalePercent);
+ if (scalePercent != null)
+ {
+ float[] scale = ITextUtils.stringToFloatArray(scalePercent);
+ if (scale.length == 1)
+ {
+ image.scalePercent(scale[0]);
+ }
+ else if (scale.length == 2)
+ {
+ image.scalePercent(scale[0], scale[1]);
+ }
+ else
+ {
+ throw new RuntimeException("scalePercent must contain one or two scale percentages");
+ }
+ }
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ throw new RuntimeException("can't add " + o.getClass().getName() + " to image");
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -9,77 +9,68 @@
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.Dataset;
-public class UILineChart
- extends UICategoryChartBase
+public class UILineChart extends UICategoryChartBase
{
- CategoryDataset dataset;
-
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- }
+ CategoryDataset dataset;
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[1];
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ }
- values[0] = super.saveState(context);
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[1];
- return values;
- }
-
- @Override
- public void createDataset() {
- dataset = new DefaultCategoryDataset();
- }
+ values[0] = super.saveState(context);
- @Override
- public JFreeChart createChart(FacesContext context) {
- JFreeChart chart;
-
- if (!getIs3D()) {
- chart = ChartFactory.createLineChart(getTitle(),
- getDomainAxisLabel(),
- getRangeAxisLabel(),
- dataset,
- plotOrientation(getOrientation()),
- getLegend(),
- false,
- false);
- } else {
- chart = ChartFactory.createLineChart3D(getTitle(),
- getDomainAxisLabel(),
- getRangeAxisLabel(),
- dataset,
- plotOrientation(getOrientation()),
- getLegend(),
- false,
- false);
- }
-
- configureTitle(chart.getTitle());
- configureLegend(chart.getLegend());
-
- return chart;
- }
+ return values;
+ }
-// @Override
-// public void configurePlot(Plot p) {
-// super.configurePlot(p);
-// }
-
-
- @Override
- public void configureRenderer(CategoryItemRenderer renderer){
- super.configureRenderer(renderer);
- }
-
- @Override
- public Dataset getDataset() {
- return dataset;
- }
+ @Override
+ public void createDataset()
+ {
+ dataset = new DefaultCategoryDataset();
+ }
+ @Override
+ public JFreeChart createChart(FacesContext context)
+ {
+ JFreeChart chart;
+
+ if (!getIs3D())
+ {
+ chart = ChartFactory.createLineChart(getTitle(), getDomainAxisLabel(), getRangeAxisLabel(), dataset, plotOrientation(getOrientation()), getLegend(), false, false);
+ }
+ else
+ {
+ chart = ChartFactory.createLineChart3D(getTitle(), getDomainAxisLabel(), getRangeAxisLabel(), dataset, plotOrientation(getOrientation()), getLegend(), false, false);
+ }
+
+ configureTitle(chart.getTitle());
+ configureLegend(chart.getLegend());
+
+ return chart;
+ }
+
+ // @Override
+ // public void configurePlot(Plot p) {
+ // super.configurePlot(p);
+ // }
+
+ @Override
+ public void configureRenderer(CategoryItemRenderer renderer)
+ {
+ super.configureRenderer(renderer);
+ }
+
+ @Override
+ public Dataset getDataset()
+ {
+ return dataset;
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIList.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIList.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIList.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,111 +3,136 @@
import javax.faces.context.*;
import com.lowagie.text.*;
-public class UIList
- extends ITextComponent
+public class UIList extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIList";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIList";
- public static final String STYLE_NUMBERED = "NUMBERED";
- public static final String STYLE_LETTERED = "LETTERED";
- public static final String STYLE_GREEK = "GREEK";
- public static final String STYLE_ROMAN = "ROMAN";
- public static final String STYLE_DINGBATS = "ZAPFDINGBATS";
- public static final String STYLE_DINGBATS_NUMBER = "ZAPFDINGBATS_NUMBER";
-
- List list;
+ public static final String STYLE_NUMBERED = "NUMBERED";
+ public static final String STYLE_LETTERED = "LETTERED";
+ public static final String STYLE_GREEK = "GREEK";
+ public static final String STYLE_ROMAN = "ROMAN";
+ public static final String STYLE_DINGBATS = "ZAPFDINGBATS";
+ public static final String STYLE_DINGBATS_NUMBER = "ZAPFDINGBATS_NUMBER";
- String style;
- String listSymbol;
- float indent = 20;
- Boolean lowerCase = false;
- Integer charNumber;
- Integer numberType = 0;
-
- public void setStyle(String style) {
- this.style = style;
- }
-
- public void setIndent(float indent) {
- this.indent = indent;
- }
+ List list;
- public void setListSymbol(String listSymbol) {
- this.listSymbol = listSymbol;
- }
-
- /* for dingbats symbol list */
- public void setCharNumber(Integer charNumber) {
- this.charNumber = charNumber;
- }
-
- /* for dingbats number list */
- public void setNumberType(Integer numberType) {
- this.numberType = numberType;
- }
-
- /* for ROMAN,GREEK */
- public void setLowerCase(Boolean lowerCase) {
- this.lowerCase = lowerCase;
- }
+ String style;
+ String listSymbol;
+ float indent = 20;
+ Boolean lowerCase = false;
+ Integer charNumber;
+ Integer numberType = 0;
- @Override
- public Object getITextObject() {
- return list;
- }
+ public void setStyle(String style)
+ {
+ this.style = style;
+ }
- @Override
- public void removeITextObject() {
- list = null;
- }
+ public void setIndent(float indent)
+ {
+ this.indent = indent;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- style = (String) valueBinding(context, "style", style);
- lowerCase = (Boolean) valueBinding(context, "lowerCase", lowerCase);
- indent = (Float) valueBinding(context, "indent", indent);
- listSymbol = (String) valueBinding(context, "listSymbol", listSymbol);
-
- if (style != null) {
- if (style.equalsIgnoreCase(STYLE_ROMAN)) {
- list = new RomanList((int) indent); // int? bug in text?
- if (lowerCase != null) {
- list.setLowercase(lowerCase);
- //((RomanList) list).setRomanLower(lowerCase);
- }
- } else if (style.equalsIgnoreCase(STYLE_GREEK)) {
- list = new GreekList((int)indent); // int? bug in itext?
+ public void setListSymbol(String listSymbol)
+ {
+ this.listSymbol = listSymbol;
+ }
- if (lowerCase != null) {
- list.setLowercase(lowerCase);
- //((GreekList) list).setGreekLower(lowerCase);
- }
- } else if (style.equalsIgnoreCase(STYLE_DINGBATS)) {
- charNumber = (Integer) valueBinding(context, "charNumber", charNumber);
- list = new ZapfDingbatsList(charNumber, (int) indent);
- } else if (style.equalsIgnoreCase(STYLE_DINGBATS_NUMBER)) {
- numberType = (Integer) valueBinding(context, "numberType", numberType);
- list = new ZapfDingbatsNumberList(numberType, (int) indent);
+ /* for dingbats symbol list */
+ public void setCharNumber(Integer charNumber)
+ {
+ this.charNumber = charNumber;
+ }
- } else if (style.equalsIgnoreCase(STYLE_NUMBERED)) {
- list = new List(true, indent);
- //setFirst(int)
- } else if (style.equalsIgnoreCase(STYLE_LETTERED)) {
- list = new List(false, true, indent);
- //setFirst(char)
+ /* for dingbats number list */
+ public void setNumberType(Integer numberType)
+ {
+ this.numberType = numberType;
+ }
+
+ /* for ROMAN,GREEK */
+ public void setLowerCase(Boolean lowerCase)
+ {
+ this.lowerCase = lowerCase;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return list;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ list = null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ style = (String) valueBinding(context, "style", style);
+ lowerCase = (Boolean) valueBinding(context, "lowerCase", lowerCase);
+ indent = (Float) valueBinding(context, "indent", indent);
+ listSymbol = (String) valueBinding(context, "listSymbol", listSymbol);
+
+ if (style != null)
+ {
+ if (style.equalsIgnoreCase(STYLE_ROMAN))
+ {
+ list = new RomanList((int) indent); // int? bug in text?
+ if (lowerCase != null)
+ {
+ list.setLowercase(lowerCase);
+ // ((RomanList) list).setRomanLower(lowerCase);
}
- }
-
- if (list == null) {
- list = new List(false, indent);
- if (listSymbol!=null) {
- list.setListSymbol(listSymbol);
+ }
+ else if (style.equalsIgnoreCase(STYLE_GREEK))
+ {
+ list = new GreekList((int) indent); // int? bug in itext?
+
+ if (lowerCase != null)
+ {
+ list.setLowercase(lowerCase);
+ // ((GreekList) list).setGreekLower(lowerCase);
}
- }
- }
+ }
+ else if (style.equalsIgnoreCase(STYLE_DINGBATS))
+ {
+ charNumber = (Integer) valueBinding(context, "charNumber", charNumber);
+ list = new ZapfDingbatsList(charNumber, (int) indent);
+ }
+ else if (style.equalsIgnoreCase(STYLE_DINGBATS_NUMBER))
+ {
+ numberType = (Integer) valueBinding(context, "numberType", numberType);
+ list = new ZapfDingbatsNumberList(numberType, (int) indent);
- @Override
- public void handleAdd(Object o) {
- list.add(o);
- }
+ }
+ else if (style.equalsIgnoreCase(STYLE_NUMBERED))
+ {
+ list = new List(true, indent);
+ // setFirst(int)
+ }
+ else if (style.equalsIgnoreCase(STYLE_LETTERED))
+ {
+ list = new List(false, true, indent);
+ // setFirst(char)
+ }
+ }
+
+ if (list == null)
+ {
+ list = new List(false, indent);
+ if (listSymbol != null)
+ {
+ list.setListSymbol(listSymbol);
+ }
+ }
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ list.add(o);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIListItem.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -6,77 +6,92 @@
import com.lowagie.text.*;
-public class UIListItem
- extends ITextComponent
+public class UIListItem extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIListItem";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIListItem";
- ListItem listItem;
+ ListItem listItem;
- String alignment;
- Float indentationLeft;
- Float indentationRight;
- Integer listSymbol;
-
- public void setListSymbol(Integer listSymbol) {
- this.listSymbol = listSymbol;
- }
-
- public void setAlignment(String alignment) {
- this.alignment = alignment;
- }
+ String alignment;
+ Float indentationLeft;
+ Float indentationRight;
+ Integer listSymbol;
- public void setIndentationLeft(Float indentationLeft) {
- this.indentationLeft = indentationLeft;
- }
+ public void setListSymbol(Integer listSymbol)
+ {
+ this.listSymbol = listSymbol;
+ }
- public void setIndentationRight(Float indentationRight) {
- this.indentationRight = indentationRight;
- }
+ public void setAlignment(String alignment)
+ {
+ this.alignment = alignment;
+ }
- @Override
- public Object getITextObject() {
- return listItem;
- }
+ public void setIndentationLeft(Float indentationLeft)
+ {
+ this.indentationLeft = indentationLeft;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- listItem = new ListItem();
-
- // should listSymbol be a facet?
- listSymbol = (Integer) valueBinding(context, "listSymbol", listSymbol);
- if (listSymbol != null) {
- int symbol = listSymbol;
- Font font = getFont();
- if (font == null) {
- listItem.setListSymbol(new Chunk((char)symbol));
- } else {
- listItem.setListSymbol(new Chunk((char)symbol, font));
- }
- }
-
- alignment = (String) valueBinding(context, "alignment", alignment);
- if (alignment != null) {
- listItem.setAlignment(ITextUtils.alignmentValue(alignment));
- }
-
- indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
- if (indentationLeft != null) {
- listItem.setIndentationLeft(indentationLeft);
- }
-
- indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
- if (indentationRight != null) {
- listItem.setIndentationRight(indentationRight);
- }
- }
+ public void setIndentationRight(Float indentationRight)
+ {
+ this.indentationRight = indentationRight;
+ }
- @Override
- public void removeITextObject() {
- listItem = null;
- }
- @Override
- public void handleAdd(Object o) {
- listItem.add(o);
- }
+ @Override
+ public Object getITextObject()
+ {
+ return listItem;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ listItem = new ListItem();
+
+ // should listSymbol be a facet?
+ listSymbol = (Integer) valueBinding(context, "listSymbol", listSymbol);
+ if (listSymbol != null)
+ {
+ int symbol = listSymbol;
+ Font font = getFont();
+ if (font == null)
+ {
+ listItem.setListSymbol(new Chunk((char) symbol));
+ }
+ else
+ {
+ listItem.setListSymbol(new Chunk((char) symbol, font));
+ }
+ }
+
+ alignment = (String) valueBinding(context, "alignment", alignment);
+ if (alignment != null)
+ {
+ listItem.setAlignment(ITextUtils.alignmentValue(alignment));
+ }
+
+ indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
+ if (indentationLeft != null)
+ {
+ listItem.setIndentationLeft(indentationLeft);
+ }
+
+ indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
+ if (indentationRight != null)
+ {
+ listItem.setIndentationRight(indentationRight);
+ }
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ listItem = null;
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ listItem.add(o);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIOutputText.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIOutputText.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIOutputText.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -9,101 +9,121 @@
import com.lowagie.text.Chunk;
-public class UIOutputText
- extends ITextComponent
- implements ValueHolder
+public class UIOutputText extends ITextComponent implements ValueHolder
{
- Chunk chunk;
+ Chunk chunk;
- Converter converter;
- Object value;
- Object localValue;
+ Converter converter;
+ Object value;
+ Object localValue;
-
- // -- ITextComponent methods
- @Override
- public void encodeEnd(FacesContext context)
- throws IOException
- {
- chunk.append(convert(context, getValue()));
-
- super.encodeEnd(context);
- }
-
- protected String convert(FacesContext context, Object value) {
- Converter myConverter = converterForValue(context, value);
- if (myConverter != null) {
- return myConverter.getAsString(context, this, value);
- } else if (value != null) {
- return value.toString();
- } else {
- return "";
- }
- }
-
- protected Converter converterForValue(FacesContext ctx, Object value) {
- if (converter != null) {
- return converter;
- }
-
- if (value != null) {
- try {
- return ctx.getApplication().createConverter(value.getClass());
- } catch (FacesException e) {
- // no converter defined - no problem
- }
- }
+ // -- ITextComponent methods
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ chunk.append(convert(context, getValue()));
- return null;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- com.lowagie.text.Font font = getFont();
-
- if (font == null) {
- chunk = new Chunk("");
- } else {
- chunk = new Chunk("", getFont());
- }
- }
+ super.encodeEnd(context);
+ }
- @Override
- public Object getITextObject() {
- return chunk;
- }
+ protected String convert(FacesContext context, Object value)
+ {
+ Converter myConverter = converterForValue(context, value);
+ if (myConverter != null)
+ {
+ return myConverter.getAsString(context, this, value);
+ }
+ else if (value != null)
+ {
+ return value.toString();
+ }
+ else
+ {
+ return "";
+ }
+ }
- @Override
- public void handleAdd(Object other) {
- throw new RuntimeException("illegal child element");
- }
+ protected Converter converterForValue(FacesContext ctx, Object value)
+ {
+ if (converter != null)
+ {
+ return converter;
+ }
- @Override
- public void removeITextObject() {
- chunk = null;
- }
+ if (value != null)
+ {
+ try
+ {
+ return ctx.getApplication().createConverter(value.getClass());
+ }
+ catch (FacesException e)
+ {
+ // no converter defined - no problem
+ }
+ }
- // -- ValueHolder methods
+ return null;
+ }
- public Converter getConverter() {
- return converter;
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ com.lowagie.text.Font font = getFont();
- public void setConverter(Converter converter) {
- this.converter = converter;
- }
+ if (font == null)
+ {
+ chunk = new Chunk("");
+ }
+ else
+ {
+ chunk = new Chunk("", getFont());
+ }
+ }
- public Object getValue() {
- return valueBinding(FacesContext.getCurrentInstance(), "value", localValue);
- }
+ @Override
+ public Object getITextObject()
+ {
+ return chunk;
+ }
- public void setValue(Object value) {
- this.localValue = value;
- }
+ @Override
+ public void handleAdd(Object other)
+ {
+ throw new RuntimeException("illegal child element");
+ }
- public Object getLocalValue() {
- return localValue;
- }
+ @Override
+ public void removeITextObject()
+ {
+ chunk = null;
+ }
+ // -- ValueHolder methods
+
+ public Converter getConverter()
+ {
+ return converter;
+ }
+
+ public void setConverter(Converter converter)
+ {
+ this.converter = converter;
+ }
+
+ public Object getValue()
+ {
+ return valueBinding(FacesContext.getCurrentInstance(), "value", localValue);
+ }
+
+ public void setValue(Object value)
+ {
+ this.localValue = value;
+ }
+
+ public Object getLocalValue()
+ {
+ return localValue;
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIPage.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIPage.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIPage.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -6,42 +6,47 @@
import com.lowagie.text.*;
-public class UIPage
- extends ITextComponent
+public class UIPage extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIPage";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIPage";
- @Override
- public Object getITextObject() {
- return null;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
- @Override
- public void removeITextObject() {
- // nothing to do
- }
+ @Override
+ public void removeITextObject()
+ {
+ // nothing to do
+ }
- @Override
- public void createITextObject(FacesContext context) {
- // nothing to do
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ // nothing to do
+ }
- @Override
- public void handleAdd(Object o) {
- addToITextParent(o);
- }
+ @Override
+ public void handleAdd(Object o)
+ {
+ addToITextParent(o);
+ }
- @Override
- public void encodeBegin(FacesContext context)
- throws IOException
- {
- super.encodeBegin(context);
- Document document = findDocument();
- if (document != null) {
- document.newPage();
- } else {
- throw new IllegalArgumentException("Cannot find parent document");
- }
- }
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+ Document document = findDocument();
+ if (document != null)
+ {
+ document.newPage();
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot find parent document");
+ }
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIPageNumber.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIPageNumber.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIPageNumber.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -1,37 +1,44 @@
package org.jboss.seam.pdf.ui;
+
import java.io.IOException;
import javax.faces.context.FacesContext;
-public class UIPageNumber extends ITextComponent {
+public class UIPageNumber extends ITextComponent
+{
- @Override
- public void createITextObject(FacesContext context) {
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ @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 handleAdd(Object other)
+ {
+ throw new RuntimeException("header page number cannot contain other elements");
+ }
- @Override
- public void removeITextObject() {
- }
+ @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();
- }
+ @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();
+ }
-
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIParagraph.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,129 +3,165 @@
import javax.faces.context.*;
import com.lowagie.text.*;
-public class UIParagraph
- extends ITextComponent
+public class UIParagraph extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIParagraph";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UIParagraph";
- Paragraph paragraph;
- String alignment;
-
- Float firstLineIndent;
- Float extraParagraphSpace;
- Float leading;
- Float multipliedLeading;
- Float spacingBefore;
- Float spacingAfter;
- Float indentationLeft;
- Float indentationRight;
+ Paragraph paragraph;
+ String alignment;
- Boolean keepTogether;
+ Float firstLineIndent;
+ Float extraParagraphSpace;
+ Float leading;
+ Float multipliedLeading;
+ Float spacingBefore;
+ Float spacingAfter;
+ Float indentationLeft;
+ Float indentationRight;
- public void setAlignment(String alignment) {
- this.alignment = alignment;
- }
- public void setFirstLineIndent(Float firstLineIndent) {
- this.firstLineIndent = firstLineIndent;
- }
- public void setExtraParagraphSpace(Float extraParagraphSpace) {
- this.extraParagraphSpace = extraParagraphSpace;
- }
- public void setLeading(Float leading) {
- this.leading = leading;
- }
- public void setMultipliedLeading(Float multipliedLeading) {
- this.multipliedLeading = multipliedLeading;
- }
- public void setSpacingBefore(Float spacingBefore) {
- this.spacingBefore = spacingBefore;
- }
- public void setSpacingAfter(Float spacingAfter) {
- this.spacingAfter = spacingAfter;
- }
- public void setIndentationLeft(Float indentationLeft) {
- this.indentationLeft = indentationLeft;
- }
- public void setIndentationRight(Float indentationRight) {
- this.indentationRight = indentationRight;
- }
- public void setKeepTogether(Boolean keepTogether) {
- this.keepTogether = keepTogether;
- }
+ Boolean keepTogether;
- @Override
- public Object getITextObject() {
- return paragraph;
- }
+ public void setAlignment(String alignment)
+ {
+ this.alignment = alignment;
+ }
- @Override
- public void removeITextObject() {
- paragraph = null;
- }
+ public void setFirstLineIndent(Float firstLineIndent)
+ {
+ this.firstLineIndent = firstLineIndent;
+ }
- @Override
- public void createITextObject(FacesContext context) {
- Font font = getFont();
- if (font == null) {
- paragraph = new Paragraph();
- } else {
- paragraph = new Paragraph("", font);
- }
+ public void setExtraParagraphSpace(Float extraParagraphSpace)
+ {
+ this.extraParagraphSpace = extraParagraphSpace;
+ }
- alignment = (String) valueBinding(context, "alignment", alignment);
- if (alignment != null) {
- paragraph.setAlignment(alignment);
- }
-
- firstLineIndent = (Float) valueBinding(context, "firstLineIndent", firstLineIndent);
- if (firstLineIndent != null) {
- paragraph.setFirstLineIndent(firstLineIndent);
- }
+ public void setLeading(Float leading)
+ {
+ this.leading = leading;
+ }
- extraParagraphSpace = (Float) valueBinding(context, "extraParagraphSpace", extraParagraphSpace);
- if (extraParagraphSpace != null) {
- paragraph.setExtraParagraphSpace(extraParagraphSpace);
- }
+ public void setMultipliedLeading(Float multipliedLeading)
+ {
+ this.multipliedLeading = multipliedLeading;
+ }
- leading = (Float) valueBinding(context, "leading", leading);
- multipliedLeading = (Float) valueBinding(context, "multipliedLeading", multipliedLeading);
- if (leading != null) {
- if (multipliedLeading != null) {
- paragraph.setLeading(leading, multipliedLeading);
- } else {
- paragraph.setLeading(leading);
- }
- }
+ public void setSpacingBefore(Float spacingBefore)
+ {
+ this.spacingBefore = spacingBefore;
+ }
+ public void setSpacingAfter(Float spacingAfter)
+ {
+ this.spacingAfter = spacingAfter;
+ }
- spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
- if (spacingBefore != null) {
- paragraph.setSpacingBefore(spacingBefore);
- }
-
- spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
- if (spacingAfter != null) {
- paragraph.setSpacingAfter(spacingAfter);
- }
-
- indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
- if (indentationLeft != null) {
- paragraph.setIndentationLeft(indentationLeft);
- }
-
- indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
- if (indentationRight != null) {
- paragraph.setIndentationRight(indentationRight);
- }
-
- keepTogether = (Boolean) valueBinding(context, "keepTogether", keepTogether);
- if (keepTogether != null) {
- paragraph.setKeepTogether(keepTogether);
- }
- }
+ public void setIndentationLeft(Float indentationLeft)
+ {
+ this.indentationLeft = indentationLeft;
+ }
- @Override
- public void handleAdd(Object o) {
- paragraph.add(o);
- }
+ public void setIndentationRight(Float indentationRight)
+ {
+ this.indentationRight = indentationRight;
+ }
+
+ public void setKeepTogether(Boolean keepTogether)
+ {
+ this.keepTogether = keepTogether;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return paragraph;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ paragraph = null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ Font font = getFont();
+ if (font == null)
+ {
+ paragraph = new Paragraph();
+ }
+ else
+ {
+ paragraph = new Paragraph("", font);
+ }
+
+ alignment = (String) valueBinding(context, "alignment", alignment);
+ if (alignment != null)
+ {
+ paragraph.setAlignment(alignment);
+ }
+
+ firstLineIndent = (Float) valueBinding(context, "firstLineIndent", firstLineIndent);
+ if (firstLineIndent != null)
+ {
+ paragraph.setFirstLineIndent(firstLineIndent);
+ }
+
+ extraParagraphSpace = (Float) valueBinding(context, "extraParagraphSpace", extraParagraphSpace);
+ if (extraParagraphSpace != null)
+ {
+ paragraph.setExtraParagraphSpace(extraParagraphSpace);
+ }
+
+ leading = (Float) valueBinding(context, "leading", leading);
+ multipliedLeading = (Float) valueBinding(context, "multipliedLeading", multipliedLeading);
+ if (leading != null)
+ {
+ if (multipliedLeading != null)
+ {
+ paragraph.setLeading(leading, multipliedLeading);
+ }
+ else
+ {
+ paragraph.setLeading(leading);
+ }
+ }
+
+ spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
+ if (spacingBefore != null)
+ {
+ paragraph.setSpacingBefore(spacingBefore);
+ }
+
+ spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
+ if (spacingAfter != null)
+ {
+ paragraph.setSpacingAfter(spacingAfter);
+ }
+
+ indentationLeft = (Float) valueBinding(context, "indentationLeft", indentationLeft);
+ if (indentationLeft != null)
+ {
+ paragraph.setIndentationLeft(indentationLeft);
+ }
+
+ indentationRight = (Float) valueBinding(context, "indentationRight", indentationRight);
+ if (indentationRight != null)
+ {
+ paragraph.setIndentationRight(indentationRight);
+ }
+
+ keepTogether = (Boolean) valueBinding(context, "keepTogether", keepTogether);
+ if (keepTogether != null)
+ {
+ paragraph.setKeepTogether(keepTogether);
+ }
+ }
+
+ @Override
+ public void handleAdd(Object o)
+ {
+ paragraph.add(o);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -11,391 +11,462 @@
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;
-public class UIPieChart
- extends UIChart
+public class UIPieChart extends UIChart
{
- private DefaultPieDataset data;
-
- private String title;
- private String label;
- private boolean legend = true;
- private boolean is3D = false;
-
- private Double labelLinkMargin;
- private String labelLinkPaint;
- private String labelLinkStroke;
- private Boolean labelLinksVisible;
- private String labelOutlinePaint;
- private String labelOutlineStroke;
- private String labelShadowPaint;
- private String labelPaint;
- private Double labelGap;
- private String labelBackgroundPaint;
- private Double startAngle;
- private Boolean circular;
- private String direction;
- private String sectionOutlinePaint;
- private String sectionOutlineStroke;
- private Boolean sectionOutlinesVisible;
- private String baseSectionOutlinePaint;
- private String baseSectionPaint;
- private String baseSectionOutlineStroke;
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getTitle() {
- return (String) valueBinding("title", title);
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return (String) valueBinding("label", label);
- }
-
- public void setLegend(boolean legend) {
- this.legend = legend;
- }
-
- public boolean getLegend(){
- return (Boolean) valueBinding("legend", legend);
- }
-
- public void setIs3D(boolean is3D) {
- this.is3D = true;
- }
-
- public boolean getIs3D() {
- return (Boolean) valueBinding("is3D", is3D);
- }
-
- public String getBaseSectionOutlinePaint() {
- return (String) valueBinding("baseSectionOutlinePaint", baseSectionOutlinePaint);
- }
+ private DefaultPieDataset data;
- public void setBaseSectionOutlinePaint(String baseSectionOutlinePaint) {
- this.baseSectionOutlinePaint = baseSectionOutlinePaint;
- }
+ private String title;
+ private String label;
+ private boolean legend = true;
+ private boolean is3D = false;
- public String getBaseSectionOutlineStroke() {
- return (String) valueBinding("baseSectionOutlineStroke", baseSectionOutlineStroke);
- }
+ private Double labelLinkMargin;
+ private String labelLinkPaint;
+ private String labelLinkStroke;
+ private Boolean labelLinksVisible;
+ private String labelOutlinePaint;
+ private String labelOutlineStroke;
+ private String labelShadowPaint;
+ private String labelPaint;
+ private Double labelGap;
+ private String labelBackgroundPaint;
+ private Double startAngle;
+ private Boolean circular;
+ private String direction;
+ private String sectionOutlinePaint;
+ private String sectionOutlineStroke;
+ private Boolean sectionOutlinesVisible;
+ private String baseSectionOutlinePaint;
+ private String baseSectionPaint;
+ private String baseSectionOutlineStroke;
- public void setBaseSectionOutlineStroke(String baseSectionOutlineStroke) {
- this.baseSectionOutlineStroke = baseSectionOutlineStroke;
- }
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
- public String getBaseSectionPaint() {
- return (String) valueBinding("baseSectionPaint", baseSectionPaint);
- }
+ public String getTitle()
+ {
+ return (String) valueBinding("title", title);
+ }
- public void setBaseSectionPaint(String baseSectionPaint) {
- this.baseSectionPaint = baseSectionPaint;
- }
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
- public Boolean getCircular() {
- return (Boolean) valueBinding("isCircular", circular);
- }
+ public String getLabel()
+ {
+ return (String) valueBinding("label", label);
+ }
- public void setCircular(Boolean circular) {
- this.circular = circular;
- }
+ public void setLegend(boolean legend)
+ {
+ this.legend = legend;
+ }
- public String getLabelBackgroundPaint() {
- return (String) valueBinding("labelBackgroundPaint", labelBackgroundPaint);
- }
+ public boolean getLegend()
+ {
+ return (Boolean) valueBinding("legend", legend);
+ }
- public void setLabelBackgroundPaint(String labelBackgroundPaint) {
- this.labelBackgroundPaint = labelBackgroundPaint;
- }
+ public void setIs3D(boolean is3D)
+ {
+ this.is3D = true;
+ }
- public Double getLabelGap() {
- return (Double) valueBinding("labelGap", labelGap);
- }
+ public boolean getIs3D()
+ {
+ return (Boolean) valueBinding("is3D", is3D);
+ }
- public void setLabelGap(Double labelGap) {
- this.labelGap = labelGap;
- }
+ public String getBaseSectionOutlinePaint()
+ {
+ return (String) valueBinding("baseSectionOutlinePaint", baseSectionOutlinePaint);
+ }
- public Double getLabelLinkMargin() {
- return (Double) valueBinding("labelLinkMargin", labelLinkMargin);
- }
+ public void setBaseSectionOutlinePaint(String baseSectionOutlinePaint)
+ {
+ this.baseSectionOutlinePaint = baseSectionOutlinePaint;
+ }
- public void setLabelLinkMargin(double labelLinkMargin) {
- this.labelLinkMargin = labelLinkMargin;
- }
+ public String getBaseSectionOutlineStroke()
+ {
+ return (String) valueBinding("baseSectionOutlineStroke", baseSectionOutlineStroke);
+ }
- public String getLabelLinkPaint() {
- return (String) valueBinding("labelLinkPaint", labelLinkPaint);
- }
+ public void setBaseSectionOutlineStroke(String baseSectionOutlineStroke)
+ {
+ this.baseSectionOutlineStroke = baseSectionOutlineStroke;
+ }
- public void setLabelLinkPaint(String labelLinkPaint) {
- this.labelLinkPaint = labelLinkPaint;
- }
+ public String getBaseSectionPaint()
+ {
+ return (String) valueBinding("baseSectionPaint", baseSectionPaint);
+ }
- public String getLabelLinkStroke() {
- return (String) valueBinding("labelLinkStroke", labelLinkStroke);
- }
+ public void setBaseSectionPaint(String baseSectionPaint)
+ {
+ this.baseSectionPaint = baseSectionPaint;
+ }
- public void setLabelLinkStroke(String labelLinkStroke) {
- this.labelLinkStroke = labelLinkStroke;
- }
+ public Boolean getCircular()
+ {
+ return (Boolean) valueBinding("isCircular", circular);
+ }
- public Boolean isLabelLinksVisible() {
- return (Boolean) valueBinding("labelLinksVisible", labelLinksVisible);
- }
+ public void setCircular(Boolean circular)
+ {
+ this.circular = circular;
+ }
- public void setLabelLinksVisible(Boolean labelLinksVisible) {
- this.labelLinksVisible = labelLinksVisible;
- }
+ public String getLabelBackgroundPaint()
+ {
+ return (String) valueBinding("labelBackgroundPaint", labelBackgroundPaint);
+ }
- public String getLabelOutlinePaint() {
- return (String) valueBinding("labelOutlinePaint", labelOutlinePaint);
- }
+ public void setLabelBackgroundPaint(String labelBackgroundPaint)
+ {
+ this.labelBackgroundPaint = labelBackgroundPaint;
+ }
- public void setLabelOutlinePaint(String labelOutlinePaint) {
- this.labelOutlinePaint = labelOutlinePaint;
- }
+ public Double getLabelGap()
+ {
+ return (Double) valueBinding("labelGap", labelGap);
+ }
- public String getLabelOutlineStroke() {
- return (String) valueBinding("labelOutlineStroke", labelOutlineStroke);
- }
+ public void setLabelGap(Double labelGap)
+ {
+ this.labelGap = labelGap;
+ }
- public void setLabelOutlineStroke(String labelOutlineStroke) {
- this.labelOutlineStroke = labelOutlineStroke;
- }
+ public Double getLabelLinkMargin()
+ {
+ return (Double) valueBinding("labelLinkMargin", labelLinkMargin);
+ }
- public String getLabelPaint() {
- return (String) valueBinding("labelPaint", labelPaint);
- }
+ public void setLabelLinkMargin(double labelLinkMargin)
+ {
+ this.labelLinkMargin = labelLinkMargin;
+ }
- public void setLabelPaint(String labelPaint) {
- this.labelPaint = labelPaint;
- }
+ public String getLabelLinkPaint()
+ {
+ return (String) valueBinding("labelLinkPaint", labelLinkPaint);
+ }
- public String getLabelShadowPaint() {
- return (String) valueBinding("labelShadowPaint", labelShadowPaint);
- }
+ public void setLabelLinkPaint(String labelLinkPaint)
+ {
+ this.labelLinkPaint = labelLinkPaint;
+ }
- public void setLabelShadowPaint(String labelShadowPaint) {
- this.labelShadowPaint = labelShadowPaint;
- }
+ public String getLabelLinkStroke()
+ {
+ return (String) valueBinding("labelLinkStroke", labelLinkStroke);
+ }
- public String getDirection() {
- return (String) valueBinding("rotation", direction);
- }
+ public void setLabelLinkStroke(String labelLinkStroke)
+ {
+ this.labelLinkStroke = labelLinkStroke;
+ }
- public void setDirection(String rotation) {
- this.direction = rotation;
- }
+ public Boolean isLabelLinksVisible()
+ {
+ return (Boolean) valueBinding("labelLinksVisible", labelLinksVisible);
+ }
- public String getSectionOutlinePaint() {
- return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
- }
+ public void setLabelLinksVisible(Boolean labelLinksVisible)
+ {
+ this.labelLinksVisible = labelLinksVisible;
+ }
- public void setSectionOutlinePaint(String sectionOutlinePaint) {
- this.sectionOutlinePaint = sectionOutlinePaint;
- }
+ public String getLabelOutlinePaint()
+ {
+ return (String) valueBinding("labelOutlinePaint", labelOutlinePaint);
+ }
- public String getSectionOutlineStroke() {
- return (String) valueBinding("sectionOutlineStroke", sectionOutlineStroke);
- }
+ public void setLabelOutlinePaint(String labelOutlinePaint)
+ {
+ this.labelOutlinePaint = labelOutlinePaint;
+ }
- public void setSectionOutlineStroke(String sectionOutlineStroke) {
- this.sectionOutlineStroke = sectionOutlineStroke;
- }
+ public String getLabelOutlineStroke()
+ {
+ return (String) valueBinding("labelOutlineStroke", labelOutlineStroke);
+ }
- public Boolean isSectionOutlinesVisible() {
- return (Boolean) valueBinding("sectionOutlineVisible", sectionOutlinesVisible);
- }
+ public void setLabelOutlineStroke(String labelOutlineStroke)
+ {
+ this.labelOutlineStroke = labelOutlineStroke;
+ }
- public void setSectionOutlinesVisible(Boolean sectionOutlinesVisible) {
- this.sectionOutlinesVisible = sectionOutlinesVisible;
- }
+ public String getLabelPaint()
+ {
+ return (String) valueBinding("labelPaint", labelPaint);
+ }
- public Double getStartAngle() {
- return (Double) valueBinding("startAngle", startAngle);
- }
+ public void setLabelPaint(String labelPaint)
+ {
+ this.labelPaint = labelPaint;
+ }
- public void setStartAngle(Double startAngle) {
- this.startAngle = startAngle;
- }
+ public String getLabelShadowPaint()
+ {
+ return (String) valueBinding("labelShadowPaint", labelShadowPaint);
+ }
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
-
- title = (String) values[1];
- label = (String) values[2];
- legend = (Boolean) values[3];
- is3D = (Boolean) values[4];
- labelLinkMargin = (Double) values[5];
- labelLinkPaint = (String) values[6];
- labelLinkStroke = (String) values[7];
- labelLinksVisible = (Boolean) values[8];
- labelOutlinePaint = (String) values[9];
- labelOutlineStroke = (String) values[10];
- labelShadowPaint = (String) values[11];
- labelPaint = (String) values[12];
- labelGap = (Double) values[13];
- labelBackgroundPaint = (String) values[14];
- startAngle = (Double) values[15];
- circular = (Boolean) values[16];
- direction = (String) values[17];
- sectionOutlinePaint = (String) values[18];
- sectionOutlineStroke = (String) values[19];
- sectionOutlinesVisible = (Boolean) values[20];
- baseSectionOutlinePaint = (String) values[21];
- baseSectionPaint = (String) values[22];
- baseSectionOutlineStroke = (String) values[23];
- }
+ public void setLabelShadowPaint(String labelShadowPaint)
+ {
+ this.labelShadowPaint = labelShadowPaint;
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[24];
+ public String getDirection()
+ {
+ return (String) valueBinding("rotation", direction);
+ }
- values[0] = super.saveState(context);
- values[1] = title;
- values[2] = label;
- values[3] = legend;
- values[4] = is3D;
- values[5] = labelLinkMargin;
- values[6] = labelLinkPaint;
- values[7] = labelLinkStroke;
- values[8] = labelLinksVisible;
- values[9] = labelOutlinePaint;
- values[10] = labelOutlineStroke;
- values[11] = labelShadowPaint;
- values[12] = labelPaint;
- values[13] = labelGap;
- values[14] = labelBackgroundPaint;
- values[15] = startAngle;
- values[16] = circular;
- values[17] = direction;
- values[18] = sectionOutlinePaint;
- values[19] = sectionOutlineStroke;
- values[20] = sectionOutlinesVisible;
- values[21] = baseSectionOutlinePaint;
- values[22] = baseSectionPaint;
- values[23] = baseSectionOutlineStroke;
-
- return values;
- }
-
-
-
- @Override
- public void createDataset() {
- data = new DefaultPieDataset();
- }
-
- @Override
- public Dataset getDataset() {
- return data;
- }
-
- public Rotation rotationValue(String value) {
- if (value == null || value.equalsIgnoreCase("anticlockwise")) {
- return Rotation.ANTICLOCKWISE;
- } else {
- return Rotation.CLOCKWISE;
- }
- }
-
- @Override
- public void configurePlot(Plot plot) {
- super.configurePlot(plot);
+ public void setDirection(String rotation)
+ {
+ this.direction = rotation;
+ }
- if (plot instanceof PiePlot) {
- PiePlot pieplot = (PiePlot) plot;
- if (label != null) {
- pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator(label));
- }
-
- if (baseSectionOutlinePaint != null) {
- pieplot.setBaseSectionOutlinePaint(findColor(baseSectionOutlinePaint));
- }
- if (baseSectionOutlineStroke != null) {
- pieplot.setBaseSectionOutlineStroke(findStroke(baseSectionOutlineStroke));
- }
- if (baseSectionPaint != null) {
- pieplot.setBaseSectionPaint(findColor(baseSectionPaint));
- }
-
- if (circular != null) {
- pieplot.setCircular(circular);
- }
- if (startAngle!=null) {
- pieplot.setStartAngle(startAngle);
- }
- if (direction != null) {
- pieplot.setDirection(rotationValue(direction));
- }
-
- if (sectionOutlinePaint != null) {
- pieplot.setSectionOutlinePaint(findColor(sectionOutlinePaint));
- }
- if (sectionOutlineStroke != null) {
- pieplot.setSectionOutlineStroke(findStroke(sectionOutlineStroke));
- }
- if (sectionOutlinesVisible != null) {
- pieplot.setSectionOutlinesVisible(sectionOutlinesVisible);
- }
+ public String getSectionOutlinePaint()
+ {
+ return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
+ }
-
-
-
- //pieplot.setLabelFont(arg0);
- if (labelBackgroundPaint!=null) {
- pieplot.setLabelBackgroundPaint(findColor(labelBackgroundPaint));
- }
- if (labelGap != null) {
- pieplot.setLabelGap(labelGap);
- }
- if (labelLinkMargin != null) {
- pieplot.setLabelLinkMargin(labelLinkMargin);
- }
- if (labelLinkPaint != null) {
- pieplot.setLabelLinkPaint(findColor(labelLinkPaint));
- }
- if (labelLinkStroke != null) {
- pieplot.setLabelLinkStroke(findStroke(labelLinkStroke));
- }
- if (labelLinksVisible != null) {
- pieplot.setLabelLinksVisible(labelLinksVisible);
- }
- if (labelOutlinePaint != null) {
- pieplot.setLabelOutlinePaint(findColor(labelOutlinePaint));
- }
- if (labelOutlineStroke != null) {
- pieplot.setLabelOutlineStroke(findStroke(labelOutlineStroke));
- }
- if (labelPaint != null) {
- pieplot.setLabelPaint(findColor(labelPaint));
- }
- if (labelShadowPaint != null) {
- pieplot.setLabelShadowPaint(findColor(labelShadowPaint));
- }
-
-
- }
- }
-
- @Override
- public JFreeChart createChart(FacesContext context) {
- legend = (Boolean) valueBinding(context, "legend", getLegend());
-
- if (!is3D) {
- return ChartFactory.createPieChart(getTitle(), data, legend, false, false);
- } else {
- return ChartFactory.createPieChart3D(getTitle(), data, legend, false, false);
- }
- }
+ public void setSectionOutlinePaint(String sectionOutlinePaint)
+ {
+ this.sectionOutlinePaint = sectionOutlinePaint;
+ }
+
+ public String getSectionOutlineStroke()
+ {
+ return (String) valueBinding("sectionOutlineStroke", sectionOutlineStroke);
+ }
+
+ public void setSectionOutlineStroke(String sectionOutlineStroke)
+ {
+ this.sectionOutlineStroke = sectionOutlineStroke;
+ }
+
+ public Boolean isSectionOutlinesVisible()
+ {
+ return (Boolean) valueBinding("sectionOutlineVisible", sectionOutlinesVisible);
+ }
+
+ public void setSectionOutlinesVisible(Boolean sectionOutlinesVisible)
+ {
+ this.sectionOutlinesVisible = sectionOutlinesVisible;
+ }
+
+ public Double getStartAngle()
+ {
+ return (Double) valueBinding("startAngle", startAngle);
+ }
+
+ public void setStartAngle(Double startAngle)
+ {
+ this.startAngle = startAngle;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+
+ title = (String) values[1];
+ label = (String) values[2];
+ legend = (Boolean) values[3];
+ is3D = (Boolean) values[4];
+ labelLinkMargin = (Double) values[5];
+ labelLinkPaint = (String) values[6];
+ labelLinkStroke = (String) values[7];
+ labelLinksVisible = (Boolean) values[8];
+ labelOutlinePaint = (String) values[9];
+ labelOutlineStroke = (String) values[10];
+ labelShadowPaint = (String) values[11];
+ labelPaint = (String) values[12];
+ labelGap = (Double) values[13];
+ labelBackgroundPaint = (String) values[14];
+ startAngle = (Double) values[15];
+ circular = (Boolean) values[16];
+ direction = (String) values[17];
+ sectionOutlinePaint = (String) values[18];
+ sectionOutlineStroke = (String) values[19];
+ sectionOutlinesVisible = (Boolean) values[20];
+ baseSectionOutlinePaint = (String) values[21];
+ baseSectionPaint = (String) values[22];
+ baseSectionOutlineStroke = (String) values[23];
+ }
+
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[24];
+
+ values[0] = super.saveState(context);
+ values[1] = title;
+ values[2] = label;
+ values[3] = legend;
+ values[4] = is3D;
+ values[5] = labelLinkMargin;
+ values[6] = labelLinkPaint;
+ values[7] = labelLinkStroke;
+ values[8] = labelLinksVisible;
+ values[9] = labelOutlinePaint;
+ values[10] = labelOutlineStroke;
+ values[11] = labelShadowPaint;
+ values[12] = labelPaint;
+ values[13] = labelGap;
+ values[14] = labelBackgroundPaint;
+ values[15] = startAngle;
+ values[16] = circular;
+ values[17] = direction;
+ values[18] = sectionOutlinePaint;
+ values[19] = sectionOutlineStroke;
+ values[20] = sectionOutlinesVisible;
+ values[21] = baseSectionOutlinePaint;
+ values[22] = baseSectionPaint;
+ values[23] = baseSectionOutlineStroke;
+
+ return values;
+ }
+
+ @Override
+ public void createDataset()
+ {
+ data = new DefaultPieDataset();
+ }
+
+ @Override
+ public Dataset getDataset()
+ {
+ return data;
+ }
+
+ public Rotation rotationValue(String value)
+ {
+ if (value == null || value.equalsIgnoreCase("anticlockwise"))
+ {
+ return Rotation.ANTICLOCKWISE;
+ }
+ else
+ {
+ return Rotation.CLOCKWISE;
+ }
+ }
+
+ @Override
+ public void configurePlot(Plot plot)
+ {
+ super.configurePlot(plot);
+
+ if (plot instanceof PiePlot)
+ {
+ PiePlot pieplot = (PiePlot) plot;
+ if (label != null)
+ {
+ pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator(label));
+ }
+
+ if (baseSectionOutlinePaint != null)
+ {
+ pieplot.setBaseSectionOutlinePaint(findColor(baseSectionOutlinePaint));
+ }
+ if (baseSectionOutlineStroke != null)
+ {
+ pieplot.setBaseSectionOutlineStroke(findStroke(baseSectionOutlineStroke));
+ }
+ if (baseSectionPaint != null)
+ {
+ pieplot.setBaseSectionPaint(findColor(baseSectionPaint));
+ }
+
+ if (circular != null)
+ {
+ pieplot.setCircular(circular);
+ }
+ if (startAngle != null)
+ {
+ pieplot.setStartAngle(startAngle);
+ }
+ if (direction != null)
+ {
+ pieplot.setDirection(rotationValue(direction));
+ }
+
+ if (sectionOutlinePaint != null)
+ {
+ pieplot.setSectionOutlinePaint(findColor(sectionOutlinePaint));
+ }
+ if (sectionOutlineStroke != null)
+ {
+ pieplot.setSectionOutlineStroke(findStroke(sectionOutlineStroke));
+ }
+ if (sectionOutlinesVisible != null)
+ {
+ pieplot.setSectionOutlinesVisible(sectionOutlinesVisible);
+ }
+
+ // pieplot.setLabelFont(arg0);
+ if (labelBackgroundPaint != null)
+ {
+ pieplot.setLabelBackgroundPaint(findColor(labelBackgroundPaint));
+ }
+ if (labelGap != null)
+ {
+ pieplot.setLabelGap(labelGap);
+ }
+ if (labelLinkMargin != null)
+ {
+ pieplot.setLabelLinkMargin(labelLinkMargin);
+ }
+ if (labelLinkPaint != null)
+ {
+ pieplot.setLabelLinkPaint(findColor(labelLinkPaint));
+ }
+ if (labelLinkStroke != null)
+ {
+ pieplot.setLabelLinkStroke(findStroke(labelLinkStroke));
+ }
+ if (labelLinksVisible != null)
+ {
+ pieplot.setLabelLinksVisible(labelLinksVisible);
+ }
+ if (labelOutlinePaint != null)
+ {
+ pieplot.setLabelOutlinePaint(findColor(labelOutlinePaint));
+ }
+ if (labelOutlineStroke != null)
+ {
+ pieplot.setLabelOutlineStroke(findStroke(labelOutlineStroke));
+ }
+ if (labelPaint != null)
+ {
+ pieplot.setLabelPaint(findColor(labelPaint));
+ }
+ if (labelShadowPaint != null)
+ {
+ pieplot.setLabelShadowPaint(findColor(labelShadowPaint));
+ }
+
+ }
+ }
+
+ @Override
+ public JFreeChart createChart(FacesContext context)
+ {
+ legend = (Boolean) valueBinding(context, "legend", getLegend());
+
+ if (!is3D)
+ {
+ return ChartFactory.createPieChart(getTitle(), data, legend, false, false);
+ }
+ else
+ {
+ return ChartFactory.createPieChart3D(getTitle(), data, legend, false, false);
+ }
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIRectangle.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIRectangle.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIRectangle.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -6,138 +6,162 @@
import com.lowagie.text.Rectangle;
-public abstract class UIRectangle
-extends ITextComponent
+public abstract class UIRectangle extends ITextComponent
{
- protected Integer border;
- protected String borderColor;
- protected String borderColorLeft;
- protected String borderColorRight;
- protected String borderColorTop;
- protected String borderColorBottom;
- protected String backgroundColor;
- protected Float borderWidth;
- protected Float borderWidthLeft;
- protected Float borderWidthRight;
- protected Float borderWidthTop;
- protected Float borderWidthBottom;
+ protected Integer border;
+ protected String borderColor;
+ protected String borderColorLeft;
+ protected String borderColorRight;
+ protected String borderColorTop;
+ protected String borderColorBottom;
+ protected String backgroundColor;
+ protected Float borderWidth;
+ protected Float borderWidthLeft;
+ protected Float borderWidthRight;
+ protected Float borderWidthTop;
+ protected Float borderWidthBottom;
- public UIRectangle() {
- super();
- }
+ public UIRectangle()
+ {
+ super();
+ }
- // xxx - use string
- public void setBorder(Integer border) {
- this.border = border;
- }
-
- public void setBorderWidth(Float borderWidth) {
- this.borderWidth = borderWidth;
- }
+ // xxx - use string
+ public void setBorder(Integer border)
+ {
+ this.border = border;
+ }
- public void setBorderWidthBottom(Float borderWidthBottom) {
- this.borderWidthBottom = borderWidthBottom;
- }
+ public void setBorderWidth(Float borderWidth)
+ {
+ this.borderWidth = borderWidth;
+ }
- public void setBorderWidthLeft(Float borderWidthLeft) {
- this.borderWidthLeft = borderWidthLeft;
- }
+ public void setBorderWidthBottom(Float borderWidthBottom)
+ {
+ this.borderWidthBottom = borderWidthBottom;
+ }
- public void setBorderWidthRight(Float borderWidthRight) {
- this.borderWidthRight = borderWidthRight;
- }
+ public void setBorderWidthLeft(Float borderWidthLeft)
+ {
+ this.borderWidthLeft = borderWidthLeft;
+ }
- public void setBorderWidthTop(Float borderWidthTop) {
- this.borderWidthTop = borderWidthTop;
- }
+ public void setBorderWidthRight(Float borderWidthRight)
+ {
+ this.borderWidthRight = borderWidthRight;
+ }
- public void setBackgroundColor(String backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
+ public void setBorderWidthTop(Float borderWidthTop)
+ {
+ this.borderWidthTop = borderWidthTop;
+ }
- public void setBorderColor(String borderColor) {
- this.borderColor = borderColor;
- }
+ public void setBackgroundColor(String backgroundColor)
+ {
+ this.backgroundColor = backgroundColor;
+ }
- public void setBorderColorBottom(String borderColorBottom) {
- this.borderColorBottom = borderColorBottom;
- }
+ public void setBorderColor(String borderColor)
+ {
+ this.borderColor = borderColor;
+ }
- public void setBorderColorLeft(String borderColorLeft) {
- this.borderColorLeft = borderColorLeft;
- }
+ public void setBorderColorBottom(String borderColorBottom)
+ {
+ this.borderColorBottom = borderColorBottom;
+ }
- public void setBorderColorRight(String borderColorRight) {
- this.borderColorRight = borderColorRight;
- }
+ public void setBorderColorLeft(String borderColorLeft)
+ {
+ this.borderColorLeft = borderColorLeft;
+ }
- public void setBorderColorTop(String borderColorTop) {
- this.borderColorTop = borderColorTop;
- }
+ public void setBorderColorRight(String borderColorRight)
+ {
+ this.borderColorRight = borderColorRight;
+ }
+ public void setBorderColorTop(String borderColorTop)
+ {
+ this.borderColorTop = borderColorTop;
+ }
- public void applyRectangleProperties(FacesContext context, Rectangle rectangle) {
-
- border = (Integer) valueBinding(context, "border", border);
- if (border != null) {
- rectangle.setBorder(border);
- }
-
- backgroundColor = (String) valueBinding(context, "backgroundColor", backgroundColor);
- if (backgroundColor != null) {
- rectangle.setBackgroundColor(ITextUtils.colorValue(backgroundColor));
- }
+ public void applyRectangleProperties(FacesContext context, Rectangle rectangle)
+ {
- borderColor = (String) valueBinding(context, "borderColor", borderColor);
- if (borderColor != null) {
- rectangle.setBorderColor(ITextUtils.colorValue(borderColor));
- }
+ border = (Integer) valueBinding(context, "border", border);
+ if (border != null)
+ {
+ rectangle.setBorder(border);
+ }
- borderColorLeft = (String) valueBinding(context, "borderColorLeft", borderColorLeft);
- if (borderColorLeft != null) {
- rectangle.setBorderColorLeft(ITextUtils.colorValue(borderColorLeft));
- }
+ backgroundColor = (String) valueBinding(context, "backgroundColor", backgroundColor);
+ if (backgroundColor != null)
+ {
+ rectangle.setBackgroundColor(ITextUtils.colorValue(backgroundColor));
+ }
- borderColorRight = (String) valueBinding(context, "borderColorRight", borderColorRight);
- if (borderColorRight != null) {
- rectangle.setBorderColorRight(ITextUtils.colorValue(borderColorRight));
- }
+ borderColor = (String) valueBinding(context, "borderColor", borderColor);
+ if (borderColor != null)
+ {
+ rectangle.setBorderColor(ITextUtils.colorValue(borderColor));
+ }
- borderColorTop = (String) valueBinding(context, "borderColorTop", borderColorTop);
- if (borderColorTop != null) {
- rectangle.setBorderColorTop(ITextUtils.colorValue(borderColorTop));
- }
+ borderColorLeft = (String) valueBinding(context, "borderColorLeft", borderColorLeft);
+ if (borderColorLeft != null)
+ {
+ rectangle.setBorderColorLeft(ITextUtils.colorValue(borderColorLeft));
+ }
- borderColorBottom = (String) valueBinding(context, "borderColorBottom", borderColorBottom);
- if (borderColorBottom != null) {
- rectangle.setBorderColorBottom(ITextUtils.colorValue(borderColorBottom));
- }
+ borderColorRight = (String) valueBinding(context, "borderColorRight", borderColorRight);
+ if (borderColorRight != null)
+ {
+ rectangle.setBorderColorRight(ITextUtils.colorValue(borderColorRight));
+ }
- borderWidth = (Float) valueBinding(context, "borderWidth", borderWidth);
- if (borderWidth != null) {
- rectangle.setBorderWidth(borderWidth);
- }
+ borderColorTop = (String) valueBinding(context, "borderColorTop", borderColorTop);
+ if (borderColorTop != null)
+ {
+ rectangle.setBorderColorTop(ITextUtils.colorValue(borderColorTop));
+ }
- borderWidthLeft = (Float) valueBinding(context, "borderWidthLeft", borderWidthLeft);
- if (borderWidthLeft != null) {
- rectangle.setBorderWidthLeft(borderWidthLeft);
- }
+ borderColorBottom = (String) valueBinding(context, "borderColorBottom", borderColorBottom);
+ if (borderColorBottom != null)
+ {
+ rectangle.setBorderColorBottom(ITextUtils.colorValue(borderColorBottom));
+ }
- borderWidthRight = (Float) valueBinding(context, "borderWidthRight", borderWidthRight);
- if (borderWidthRight != null) {
- rectangle.setBorderWidthRight(borderWidthRight);
- }
+ borderWidth = (Float) valueBinding(context, "borderWidth", borderWidth);
+ if (borderWidth != null)
+ {
+ rectangle.setBorderWidth(borderWidth);
+ }
- borderWidthTop = (Float) valueBinding(context, "borderWidthTop", borderWidthTop);
- if (borderWidthTop != null) {
- rectangle.setBorderWidthTop(borderWidthTop);
- }
+ borderWidthLeft = (Float) valueBinding(context, "borderWidthLeft", borderWidthLeft);
+ if (borderWidthLeft != null)
+ {
+ rectangle.setBorderWidthLeft(borderWidthLeft);
+ }
- borderWidthBottom = (Float) valueBinding(context, "borderWidthBottom", borderWidthBottom);
- if (borderWidthBottom != null) {
- rectangle.setBorderWidthBottom(borderWidthBottom);
- }
+ 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);
+ }
+
+ }
+
}
\ No newline at end of file
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UISection.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UISection.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UISection.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,63 +3,72 @@
import javax.faces.context.*;
import com.lowagie.text.*;
-public class UISection
- extends ITextComponent
+public class UISection extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UISection";
+ public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UISection";
- Section section;
- Integer numberDepth;
-
- public void setNumberDepth(Integer numberDepth) {
- this.numberDepth = numberDepth;
- }
-
- public Section getSection() {
- return section;
- }
-
- @Override
- public Object getITextObject() {
- return null; // don't add to parent - already added.
- }
+ Section section;
+ Integer numberDepth;
- @Override
- public void removeITextObject() {
- section = null;
- }
+ public void setNumberDepth(Integer numberDepth)
+ {
+ this.numberDepth = numberDepth;
+ }
- @Override
- public void handleAdd(Object o) {
- section.add(o);
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- UISection uiParent = (UISection)findITextParent(getParent(), UISection.class);
-
- Section sectionParent = uiParent.getSection();
- if (sectionParent == null) {
- throw new RuntimeException("section must have a parent chapter/section");
- }
-
- numberDepth = (Integer) valueBinding(context, "numberDepth", numberDepth);
- if (numberDepth == null) {
- numberDepth = countSectionParents(this, 0);
- }
+ public Section getSection()
+ {
+ return section;
+ }
- section = sectionParent.addSection(new Paragraph(""), numberDepth);
- }
+ @Override
+ public Object getITextObject()
+ {
+ return null; // don't add to parent - already added.
+ }
- private int countSectionParents(UISection component, int level) {
- if (component == null) {
- return level;
- }
- return countSectionParents((UISection)findITextParent(component.getParent(), UISection.class),
- level+1);
- }
+ @Override
+ public void removeITextObject()
+ {
+ section = null;
+ }
- public void setTitle(Paragraph title) {
- section.setTitle(title);
- }
+ @Override
+ public void handleAdd(Object o)
+ {
+ section.add(o);
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ UISection uiParent = (UISection) findITextParent(getParent(), UISection.class);
+
+ Section sectionParent = uiParent.getSection();
+ if (sectionParent == null)
+ {
+ throw new RuntimeException("section must have a parent chapter/section");
+ }
+
+ numberDepth = (Integer) valueBinding(context, "numberDepth", numberDepth);
+ if (numberDepth == null)
+ {
+ numberDepth = countSectionParents(this, 0);
+ }
+
+ section = sectionParent.addSection(new Paragraph(""), numberDepth);
+ }
+
+ private int countSectionParents(UISection component, int level)
+ {
+ if (component == null)
+ {
+ return level;
+ }
+ return countSectionParents((UISection) findITextParent(component.getParent(), UISection.class), level + 1);
+ }
+
+ public void setTitle(Paragraph title)
+ {
+ section.setTitle(title);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UISignature.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -20,123 +20,140 @@
import com.lowagie.text.pdf.PdfStamper;
import com.lowagie.text.pdf.PdfWriter;
-public class UISignature
- extends ITextComponent
+public class UISignature extends ITextComponent
{
- // signature box
- String field;
- String size;
- String reason;
- String location;
-
- public void setField(String field) {
- this.field = field;
- }
-
- public void setSize(String size) {
- this.size = size;
- }
- public void setReason(String reason) {
- this.reason = reason;
- }
- public void setLocation(String location) {
- this.location = location;
- }
-
-
-
- @Override
- public void createITextObject(FacesContext context) {}
+ // signature box
+ String field;
+ String size;
+ String reason;
+ String location;
- @Override
- public void removeITextObject() {}
-
- @Override
- public Object getITextObject() {
- return null;
- }
+ public void setField(String field)
+ {
+ this.field = field;
+ }
- @Override
- public void handleAdd(Object other) {
- throw new RuntimeException("PDF signature does not accept children");
- }
+ public void setSize(String size)
+ {
+ this.size = size;
+ }
- @Override
- public void encodeEnd(FacesContext context) throws IOException {
- PdfWriter writer = findWriter();
- if (writer == null) {
- throw new RuntimeException("Cannot find PdfWriter - the document may not exist or may not be a pdf type");
- }
-
- PdfAcroForm form = writer.getAcroForm();
+ public void setReason(String reason)
+ {
+ this.reason = reason;
+ }
- field = (String) valueBinding(context, "field", field);
- if (field == null) {
- throw new RuntimeException("signature field named is required");
- }
-
- size = (String) valueBinding(context, "size", size);
- if (size == null) {
- throw new RuntimeException("signature size is required");
- }
- float[] rect = ITextUtils.stringToFloatArray(size);
- if (rect.length != 4) {
- throw new RuntimeException("size must contain four numbers");
- }
- form.addSignature(field, rect[0], rect[1], rect[2], rect[3]);
-
- UIDocument doc = (UIDocument) findITextParent(this, UIDocument.class);
- doc.addSignature(this);
-
- super.encodeEnd(context);
- }
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
- private PdfWriter findWriter() {
- UIDocument doc = (UIDocument) findITextParent(this, UIDocument.class);
- if (doc != null) {
- DocWriter writer = doc.getWriter();
-
- if (writer instanceof PdfWriter) {
- return (PdfWriter) writer;
- }
- }
- return null;
- }
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ }
- public byte[] sign(byte[] originalBytes) {
- KeyStoreConfig store = KeyStoreConfig.instance();
-
- try {
- InputStream is = FacesResources.getResourceAsStream( store.getKeyStore(), getFacesContext().getExternalContext() );
-
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(is, store.getKeyStorePassword().toCharArray());
+ @Override
+ public void removeITextObject()
+ {
+ }
- PrivateKey key = (PrivateKey) ks.getKey(store.getKeyAlias(),
- store.getKeyPassword().toCharArray());
- Certificate[] chain = ks.getCertificateChain(store.getKeyAlias());
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
- PdfReader reader = new PdfReader(originalBytes);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
+ @Override
+ public void handleAdd(Object other)
+ {
+ throw new RuntimeException("PDF signature does not accept children");
+ }
- PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
- PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
- appearance.setCrypto(key, chain, null,
- PdfSignatureAppearance.SELF_SIGNED);
-
- appearance.setReason(reason);
- appearance.setLocation(location);
-
- appearance.setVisibleSignature(field);
- stamper.close();
-
- return os.toByteArray();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException
+ {
+ PdfWriter writer = findWriter();
+ if (writer == null)
+ {
+ throw new RuntimeException("Cannot find PdfWriter - the document may not exist or may not be a pdf type");
+ }
- }
+ PdfAcroForm form = writer.getAcroForm();
+ field = (String) valueBinding(context, "field", field);
+ if (field == null)
+ {
+ throw new RuntimeException("signature field named is required");
+ }
-
+ size = (String) valueBinding(context, "size", size);
+ if (size == null)
+ {
+ throw new RuntimeException("signature size is required");
+ }
+ float[] rect = ITextUtils.stringToFloatArray(size);
+ if (rect.length != 4)
+ {
+ throw new RuntimeException("size must contain four numbers");
+ }
+ form.addSignature(field, rect[0], rect[1], rect[2], rect[3]);
+
+ UIDocument doc = (UIDocument) findITextParent(this, UIDocument.class);
+ doc.addSignature(this);
+
+ super.encodeEnd(context);
+ }
+
+ private PdfWriter findWriter()
+ {
+ UIDocument doc = (UIDocument) findITextParent(this, UIDocument.class);
+ if (doc != null)
+ {
+ DocWriter writer = doc.getWriter();
+
+ if (writer instanceof PdfWriter)
+ {
+ return (PdfWriter) writer;
+ }
+ }
+ return null;
+ }
+
+ public byte[] sign(byte[] originalBytes)
+ {
+ KeyStoreConfig store = KeyStoreConfig.instance();
+
+ try
+ {
+ InputStream is = FacesResources.getResourceAsStream(store.getKeyStore(), getFacesContext().getExternalContext());
+
+ KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+ ks.load(is, store.getKeyStorePassword().toCharArray());
+
+ PrivateKey key = (PrivateKey) ks.getKey(store.getKeyAlias(), store.getKeyPassword().toCharArray());
+ Certificate[] chain = ks.getCertificateChain(store.getKeyAlias());
+
+ PdfReader reader = new PdfReader(originalBytes);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0');
+ PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
+ appearance.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED);
+
+ appearance.setReason(reason);
+ appearance.setLocation(location);
+
+ appearance.setVisibleSignature(field);
+ stamper.close();
+
+ return os.toByteArray();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIStroke.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIStroke.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIStroke.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -8,142 +8,170 @@
import org.jboss.seam.pdf.ITextUtils;
-public class UIStroke
- extends UIComponentBase
+public class UIStroke extends UIComponentBase
{
- Float width;
- String cap; // CAP_BUTT, CAP_ROUND, CAP_SQUARE
- String join; // JOIN_MITER, JOIN_ROUND, JOIN_BEVEL
- Float miterLimit =1f;
- String dashString;
- Float dashPhase = 0f;
-
- public String getCap() {
- return cap;
- }
+ Float width;
+ String cap; // CAP_BUTT, CAP_ROUND, CAP_SQUARE
+ String join; // JOIN_MITER, JOIN_ROUND, JOIN_BEVEL
+ Float miterLimit = 1f;
+ String dashString;
+ Float dashPhase = 0f;
- public void setCap(String cap) {
- this.cap = cap;
- }
+ public String getCap()
+ {
+ return cap;
+ }
- public String getDash() {
- return dashString;
- }
+ public void setCap(String cap)
+ {
+ this.cap = cap;
+ }
- public void setDash(String dash) {
- this.dashString = dash;
- }
+ public String getDash()
+ {
+ return dashString;
+ }
- public float getDashPhase() {
- return dashPhase;
- }
+ public void setDash(String dash)
+ {
+ this.dashString = dash;
+ }
- public void setDashPhase(float dashPhase) {
- this.dashPhase = dashPhase;
- }
+ public float getDashPhase()
+ {
+ return dashPhase;
+ }
- public String getJoin() {
- return join;
- }
+ public void setDashPhase(float dashPhase)
+ {
+ this.dashPhase = dashPhase;
+ }
- public void setJoin(String join) {
- this.join = join;
- }
+ public String getJoin()
+ {
+ return join;
+ }
- public float getMiterlimit() {
- return miterLimit;
- }
+ public void setJoin(String join)
+ {
+ this.join = join;
+ }
- public void setMiterLimit(float miterLimit) {
- this.miterLimit = miterLimit;
- }
+ public float getMiterlimit()
+ {
+ return miterLimit;
+ }
- public float getWidth() {
- return width;
- }
+ public void setMiterLimit(float miterLimit)
+ {
+ this.miterLimit = miterLimit;
+ }
- public void setWidth(float width) {
- this.width = width;
- }
-
- public int capValue(String cap) {
- if (cap == null || cap.equalsIgnoreCase("butt")) {
- return BasicStroke.CAP_BUTT;
- } else if (cap.equalsIgnoreCase("round")) {
- return BasicStroke.CAP_ROUND;
- } else if (cap.equalsIgnoreCase("square")) {
- return BasicStroke.CAP_SQUARE;
- }
- throw new RuntimeException("invalid cap value: " + cap);
- }
-
- public int joinValue(String join) {
- if (join == null || join.equalsIgnoreCase("miter")) {
- return BasicStroke.JOIN_MITER;
- } else if (join.equalsIgnoreCase("round")) {
- return BasicStroke.JOIN_ROUND;
- } else if (join.equalsIgnoreCase("bevel")) {
- return BasicStroke.JOIN_BEVEL;
- }
- throw new RuntimeException("invalid join value: " + join);
- }
-
+ public float getWidth()
+ {
+ return width;
+ }
- @Override
- public String getFamily() {
- return ITextComponent.COMPONENT_FAMILY;
- }
-
-
- @Override
- public void restoreState(FacesContext context, Object state)
- {
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
+ public void setWidth(float width)
+ {
+ this.width = width;
+ }
- width = (Float) values[1];
- cap = (String) values[2];
- join = (String) values[3];
- miterLimit = (Float) values[4];
- dashString = (String) values[5];
- dashPhase = (Float) values[6];
- }
+ public int capValue(String cap)
+ {
+ if (cap == null || cap.equalsIgnoreCase("butt"))
+ {
+ return BasicStroke.CAP_BUTT;
+ }
+ else if (cap.equalsIgnoreCase("round"))
+ {
+ return BasicStroke.CAP_ROUND;
+ }
+ else if (cap.equalsIgnoreCase("square"))
+ {
+ return BasicStroke.CAP_SQUARE;
+ }
+ throw new RuntimeException("invalid cap value: " + cap);
+ }
- @Override
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[7];
-
- values[0] = super.saveState(context);
- values[1] = width;
- values[2] = cap;
- values[3] = join;
- values[4] = miterLimit;
- values[5] = dashString;
- values[6] = dashPhase;
-
- return values;
- }
-
- public Stroke getStroke() {
- if (width == null) {
- return new BasicStroke();
- } else if (cap == null) {
- return new BasicStroke(getWidth());
- } else if (dashString == null) {
- if (miterLimit == null) {
- return new BasicStroke(getWidth(), capValue(getCap()), joinValue(getJoin()));
- } else {
- return new BasicStroke(getWidth(), capValue(getCap()), joinValue(getJoin()), miterLimit);
- }
- } else {
- return new BasicStroke(getWidth(),
- capValue(getCap()),
- joinValue(getJoin()),
- getMiterlimit(),
- ITextUtils.stringToFloatArray(getDash()),
- getDashPhase());
- }
- }
+ public int joinValue(String join)
+ {
+ if (join == null || join.equalsIgnoreCase("miter"))
+ {
+ return BasicStroke.JOIN_MITER;
+ }
+ else if (join.equalsIgnoreCase("round"))
+ {
+ return BasicStroke.JOIN_ROUND;
+ }
+ else if (join.equalsIgnoreCase("bevel"))
+ {
+ return BasicStroke.JOIN_BEVEL;
+ }
+ throw new RuntimeException("invalid join value: " + join);
+ }
+ @Override
+ public String getFamily()
+ {
+ return ITextComponent.COMPONENT_FAMILY;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+
+ width = (Float) values[1];
+ cap = (String) values[2];
+ join = (String) values[3];
+ miterLimit = (Float) values[4];
+ dashString = (String) values[5];
+ dashPhase = (Float) values[6];
+ }
+
+ @Override
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[7];
+
+ values[0] = super.saveState(context);
+ values[1] = width;
+ values[2] = cap;
+ values[3] = join;
+ values[4] = miterLimit;
+ values[5] = dashString;
+ values[6] = dashPhase;
+
+ return values;
+ }
+
+ public Stroke getStroke()
+ {
+ if (width == null)
+ {
+ return new BasicStroke();
+ }
+ else if (cap == null)
+ {
+ return new BasicStroke(getWidth());
+ }
+ else if (dashString == null)
+ {
+ if (miterLimit == null)
+ {
+ return new BasicStroke(getWidth(), capValue(getCap()), joinValue(getJoin()));
+ }
+ else
+ {
+ return new BasicStroke(getWidth(), capValue(getCap()), joinValue(getJoin()), miterLimit);
+ }
+ }
+ else
+ {
+ return new BasicStroke(getWidth(), capValue(getCap()), joinValue(getJoin()), getMiterlimit(), ITextUtils.stringToFloatArray(getDash()), getDashPhase());
+ }
+ }
+
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UISwingComponent.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UISwingComponent.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UISwingComponent.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -3,38 +3,40 @@
import java.awt.Component;
import java.awt.Graphics2D;
-public class UISwingComponent extends UIGraphics2D {
- private Component component;
+public class UISwingComponent extends UIGraphics2D
+{
+ private Component component;
- public void setComponent(Component component) {
- this.component = component;
- }
+ public void setComponent(Component component)
+ {
+ this.component = component;
+ }
- public Component getComponent() {
- return (Component) valueBinding("component", component);
- }
-
-
- @Override
- public void render(Graphics2D g2) {
- // don't use the component variable directly!
- // we need to check for the valueBinding
- Component component = getComponent();
+ public Component getComponent()
+ {
+ return (Component) valueBinding("component", component);
+ }
- if (component == null) {
- throw new RuntimeException("Component was null");
- }
+ @Override
+ public void render(Graphics2D g2)
+ {
+ // don't use the component variable directly!
+ // we need to check for the valueBinding
+ Component component = getComponent();
- System.out.println("component is " + component + " " +
- component.getWidth() + "x" + component.getHeight());
- // setSize() is very important. The default size
- // for this component is zero, which means it will not display
- // unless the size is set
- component.setSize(getWidth(), getHeight());
+ if (component == null)
+ {
+ throw new RuntimeException("Component was null");
+ }
- System.out.println("component is " + component + " " +
- component.getWidth() + "x" + component.getHeight());
- component.paint(g2);
- System.out.println("g2=" + g2);
- }
+ System.out.println("component is " + component + " " + component.getWidth() + "x" + component.getHeight());
+ // setSize() is very important. The default size
+ // for this component is zero, which means it will not display
+ // unless the size is set
+ component.setSize(getWidth(), getHeight());
+
+ System.out.println("component is " + component + " " + component.getWidth() + "x" + component.getHeight());
+ component.paint(g2);
+ System.out.println("g2=" + g2);
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UITable.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UITable.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UITable.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -7,215 +7,260 @@
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
-public class UITable
- extends ITextComponent
+public class UITable extends ITextComponent
{
- public static final String COMPONENT_TYPE = "org.jboss.seam.pdf.ui.UITable";
+ 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;
+ 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 setWidths(String widths) {
- this.widths = widths;
- }
-
- public void setColumns(int columns) {
- this.columns = columns;
- }
+ public void setColumns(int columns)
+ {
+ this.columns = columns;
+ }
- public void setHeaderRows(Integer headerRows) {
- this.headerRows = headerRows;
- }
+ public void setHeaderRows(Integer headerRows)
+ {
+ this.headerRows = headerRows;
+ }
- public void setFooterRows(Integer footerRows) {
- this.footerRows = footerRows;
- }
+ public void setFooterRows(Integer footerRows)
+ {
+ this.footerRows = footerRows;
+ }
- public void setExtendLastRow(Boolean extendLastRow) {
- this.extendLastRow = extendLastRow;
- }
-
- public void setHeadersInEvent(Boolean headersInEvent) {
- this.headersInEvent = headersInEvent;
- }
-
- public void setHorizontalAlignment(String horizontalAlignment) {
- this.horizontalAlignment = ITextUtils.alignmentValue(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;
- }
-
-
-
- @Override
- public Object getITextObject() {
- return table;
- }
-
- @Override
- public void removeITextObject() {
- table = null;
- }
-
- @Override
- public void createITextObject(FacesContext context) {
- columns = (Integer) valueBinding(context, "columns", columns);
- table = new PdfPTable(columns);
-
- widths = (String) valueBinding(context, "widths", widths);
- if (widths != null) {
- try {
- table.setWidths(ITextUtils.stringToFloatArray(widths));
- } catch (DocumentException e) {
- throw new RuntimeException(e);
- }
- }
-
- headerRows = (Integer) valueBinding(context, "headerRows", headerRows);
- if (headerRows != null) {
- table.setHeaderRows(headerRows);
- }
-
- footerRows = (Integer) valueBinding(context, "footerRows", footerRows);
- if (footerRows != null) {
- table.setFooterRows(footerRows);
- }
-
- widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage);
- if (widthPercentage!=null) {
- table.setWidthPercentage(widthPercentage);
- }
-
- horizontalAlignment = (Integer) valueBinding(context, "horizontalAlignment", horizontalAlignment);
- if (horizontalAlignment!=null) {
- table.setHorizontalAlignment(horizontalAlignment);
- }
-
- runDirection = (Integer) valueBinding(context, "runDirection", runDirection);
- if (runDirection!=null) {
- table.setRunDirection(runDirection);
- }
-
- lockedWidth = (Boolean) valueBinding(context, "lockedWidth", lockedWidth);
- if (lockedWidth!=null) {
- table.setLockedWidth(lockedWidth);
- }
-
- splitRows = (Boolean) valueBinding(context, "splitRows", splitRows);
- if (splitRows!=null) {
- table.setSplitRows(splitRows);
- }
-
- spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
- if (spacingBefore!=null) {
- table.setSpacingBefore(spacingBefore);
- }
-
- spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
- if (spacingAfter!=null) {
- table.setSpacingAfter(spacingAfter);
- }
-
- extendLastRow = (Boolean) valueBinding(context, "extendLastRow", extendLastRow);
- if (extendLastRow!=null) {
- table.setExtendLastRow(extendLastRow);
- }
-
- headersInEvent = (Boolean) valueBinding(context, "headersInEvent", headersInEvent);
- if (headersInEvent!=null) {
- table.setHeadersInEvent(headersInEvent);
- }
-
- splitLate = (Boolean) valueBinding(context, "splitLate", splitLate);
- if (splitLate!=null) {
- table.setSplitLate(splitLate);
- }
-
- keepTogether = (Boolean) valueBinding(context, "keepTogether", keepTogether);
- if (keepTogether!=null) {
- table.setKeepTogether(keepTogether);
- }
- }
-
- @Override
- public void handleAdd(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");
- }
- }
+ public void setExtendLastRow(Boolean extendLastRow)
+ {
+ this.extendLastRow = extendLastRow;
+ }
- public PdfPCell getDefaultCellFacet() {
- Object facet = processFacet("defaultCell");
-
- if (facet != null) {
- if (!(facet instanceof PdfPCell)) {
- throw new RuntimeException("UITable defaultCell facet must be a PdfPCell - found " + facet.getClass());
- }
- return (PdfPCell) facet;
- }
- return null;
- }
+ public void setHeadersInEvent(Boolean headersInEvent)
+ {
+ this.headersInEvent = headersInEvent;
+ }
+
+ public void setHorizontalAlignment(String horizontalAlignment)
+ {
+ this.horizontalAlignment = ITextUtils.alignmentValue(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;
+ }
+
+ @Override
+ public Object getITextObject()
+ {
+ return table;
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ table = null;
+ }
+
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ columns = (Integer) valueBinding(context, "columns", columns);
+ table = new PdfPTable(columns);
+
+ widths = (String) valueBinding(context, "widths", widths);
+ if (widths != null)
+ {
+ try
+ {
+ table.setWidths(ITextUtils.stringToFloatArray(widths));
+ }
+ catch (DocumentException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ headerRows = (Integer) valueBinding(context, "headerRows", headerRows);
+ if (headerRows != null)
+ {
+ table.setHeaderRows(headerRows);
+ }
+
+ footerRows = (Integer) valueBinding(context, "footerRows", footerRows);
+ if (footerRows != null)
+ {
+ table.setFooterRows(footerRows);
+ }
+
+ widthPercentage = (Float) valueBinding(context, "widthPercentage", widthPercentage);
+ if (widthPercentage != null)
+ {
+ table.setWidthPercentage(widthPercentage);
+ }
+
+ horizontalAlignment = (Integer) valueBinding(context, "horizontalAlignment", horizontalAlignment);
+ if (horizontalAlignment != null)
+ {
+ table.setHorizontalAlignment(horizontalAlignment);
+ }
+
+ runDirection = (Integer) valueBinding(context, "runDirection", runDirection);
+ if (runDirection != null)
+ {
+ table.setRunDirection(runDirection);
+ }
+
+ lockedWidth = (Boolean) valueBinding(context, "lockedWidth", lockedWidth);
+ if (lockedWidth != null)
+ {
+ table.setLockedWidth(lockedWidth);
+ }
+
+ splitRows = (Boolean) valueBinding(context, "splitRows", splitRows);
+ if (splitRows != null)
+ {
+ table.setSplitRows(splitRows);
+ }
+
+ spacingBefore = (Float) valueBinding(context, "spacingBefore", spacingBefore);
+ if (spacingBefore != null)
+ {
+ table.setSpacingBefore(spacingBefore);
+ }
+
+ spacingAfter = (Float) valueBinding(context, "spacingAfter", spacingAfter);
+ if (spacingAfter != null)
+ {
+ table.setSpacingAfter(spacingAfter);
+ }
+
+ extendLastRow = (Boolean) valueBinding(context, "extendLastRow", extendLastRow);
+ if (extendLastRow != null)
+ {
+ table.setExtendLastRow(extendLastRow);
+ }
+
+ headersInEvent = (Boolean) valueBinding(context, "headersInEvent", headersInEvent);
+ if (headersInEvent != null)
+ {
+ table.setHeadersInEvent(headersInEvent);
+ }
+
+ splitLate = (Boolean) valueBinding(context, "splitLate", splitLate);
+ if (splitLate != null)
+ {
+ table.setSplitLate(splitLate);
+ }
+
+ keepTogether = (Boolean) valueBinding(context, "keepTogether", keepTogether);
+ if (keepTogether != null)
+ {
+ table.setKeepTogether(keepTogether);
+ }
+ }
+
+ @Override
+ public void handleAdd(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");
+ }
+ }
+
+ public PdfPCell getDefaultCellFacet()
+ {
+ Object facet = processFacet("defaultCell");
+
+ if (facet != null)
+ {
+ if (!(facet instanceof PdfPCell))
+ {
+ throw new RuntimeException("UITable defaultCell facet must be a PdfPCell - found " + facet.getClass());
+ }
+ return (PdfPCell) facet;
+ }
+ return null;
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UITitle.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UITitle.java 2008-08-30 11:55:40 UTC (rev 8855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UITitle.java 2008-08-30 12:01:23 UTC (rev 8856)
@@ -4,40 +4,48 @@
import com.lowagie.text.Paragraph;
-public class UITitle extends ITextComponent {
- @Override
- public void createITextObject(FacesContext context) {
- //
- }
+public class UITitle extends ITextComponent
+{
+ @Override
+ public void createITextObject(FacesContext context)
+ {
+ //
+ }
- @Override
- public Object getITextObject() {
- return null;
- }
+ @Override
+ public Object getITextObject()
+ {
+ return null;
+ }
- @Override
- public void handleAdd(Object other) {
- Paragraph paragraph = null;
-
- if (other instanceof Paragraph) {
- paragraph = (Paragraph) other;
- }
-
- if (paragraph == null) {
- throw new RuntimeException("title must be a paragraph");
- }
-
- UISection section = (UISection) findITextParent(this,UISection.class);
- if (section == null) {
- throw new RuntimeException("cannot find parent chapter/section for title");
- }
-
- section.getSection().setTitle(paragraph);
- }
+ @Override
+ public void handleAdd(Object other)
+ {
+ Paragraph paragraph = null;
- @Override
- public void removeITextObject() {
- //
- }
+ if (other instanceof Paragraph)
+ {
+ paragraph = (Paragraph) other;
+ }
+ if (paragraph == null)
+ {
+ throw new RuntimeException("title must be a paragraph");
+ }
+
+ UISection section = (UISection) findITextParent(this, UISection.class);
+ if (section == null)
+ {
+ throw new RuntimeException("cannot find parent chapter/section for title");
+ }
+
+ section.getSection().setTitle(paragraph);
+ }
+
+ @Override
+ public void removeITextObject()
+ {
+ //
+ }
+
}
More information about the seam-commits
mailing list