[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...
Norman Richards
norman.richards at jboss.com
Wed May 2 22:33:12 EDT 2007
User: nrichards
Date: 07/05/02 22:33:12
Modified: src/pdf/org/jboss/seam/pdf/ui ITextComponent.java
UIBarChart.java UIChart.java UIChartData.java
UILineChart.java UIPieChart.java
Log:
better styling options
Revision Changes Path
1.14 +4 -0 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ITextComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- ITextComponent.java 2 May 2007 01:09:04 -0000 1.13
+++ ITextComponent.java 3 May 2007 02:33:12 -0000 1.14
@@ -148,6 +148,10 @@
return value;
}
+ public Object valueBinding(String property, Object defaultValue) {
+ return valueBinding(FacesContext.getCurrentInstance(), property, defaultValue);
+ }
+
// ------------------------------------------------------
@Override
1.4 +2 -6 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIBarChart.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIBarChart.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UIBarChart.java 2 May 2007 01:09:04 -0000 1.3
+++ UIBarChart.java 3 May 2007 02:33:12 -0000 1.4
@@ -2,8 +2,6 @@
import java.awt.BasicStroke;
import java.awt.Color;
-import java.awt.Stroke;
-
import javax.faces.context.FacesContext;
import org.jfree.chart.ChartFactory;
@@ -12,7 +10,6 @@
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
-import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.Dataset;
@@ -83,14 +80,13 @@
public void configureRenderer(BarRenderer renderer) {
renderer.setItemMargin(0.0);
-
renderer.setBaseOutlineStroke(new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10f,
new float[] {10,3}, 0));
}
@Override
- public JFreeChart getChart(FacesContext context) {
+ public JFreeChart createChart(FacesContext context) {
if (!is3D) {
return ChartFactory.createBarChart(title,
categoryAxisLabel,
1.5 +17 -12 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIChart.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChart.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- UIChart.java 2 May 2007 01:09:04 -0000 1.4
+++ UIChart.java 3 May 2007 02:33:12 -0000 1.5
@@ -1,7 +1,5 @@
package org.jboss.seam.pdf.ui;
-import java.awt.BasicStroke;
-import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Stroke;
@@ -25,7 +23,9 @@
public abstract class UIChart
extends ITextComponent
{
- Image image = null;
+ private Image image = null;
+ private JFreeChart chart = null;
+
float height = 300;
float width = 400;
@@ -40,6 +40,7 @@
String plotOutlineStroke;
String plotOutlinePaint;
+
public void setHeight(float height) {
this.height = height;
}
@@ -120,7 +121,7 @@
return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlineStroke", plotOutlineStroke);
}
- public Paint findColor(String name) {
+ public static Paint findColor(String name) {
UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(name);
if (component != null) {
@@ -134,7 +135,7 @@
return ITextUtils.colorValue(name);
}
- private Stroke findStroke(String id) {
+ public static Stroke findStroke(String id) {
UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(id);
if (component instanceof UIStroke) {
@@ -146,12 +147,13 @@
}
}
- public abstract JFreeChart getChart(FacesContext context);
+ public abstract JFreeChart createChart(FacesContext context);
+ public JFreeChart getChart() {
+ return chart;
+ }
@Override
public void createITextObject(FacesContext context) {
- JFreeChart chart = getChart(context);
-
if (borderBackgroundPaint != null) {
chart.setBackgroundPaint(findColor(getBorderBackgroundPaint()));
}
@@ -218,6 +220,8 @@
{
// bypass super to avoid createITextObject() before the chart is ready
createDataset();
+ chart = createChart(context);
+
}
@@ -243,6 +247,7 @@
@Override
public void removeITextObject() {
image = null;
+ chart = null;
}
1.3 +68 -11 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIChartData.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIChartData.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIChartData.java 28 Apr 2007 23:47:56 -0000 1.2
+++ UIChartData.java 3 May 2007 02:33:12 -0000 1.3
@@ -4,6 +4,7 @@
import javax.faces.context.FacesContext;
+import org.jfree.chart.plot.PiePlot;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DefaultPieDataset;
@@ -11,10 +12,15 @@
public class UIChartData
extends ITextComponent
{
- String key;
- String columnKey;
- String rowKey;
- Number value;
+ private String key;
+ private String columnKey;
+ private String rowKey;
+ private Number value;
+ private Float explodedPercent;
+
+ private String sectionPaint;
+ private String sectionOutlinePaint;
+ private String sectionOutlineStroke;
public void setKey(String key) {
this.key = key;
@@ -32,16 +38,49 @@
this.value = value;
}
+ public Float getExplodedPercent() {
+ return (Float) valueBinding("explodedPercent", explodedPercent);
+ }
+
+ public void setExplodedPercent(Float explodedPercent) {
+ this.explodedPercent = explodedPercent;
+ }
+
+
+ public String getSectionOutlinePaint() {
+ return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
+ }
+
+ 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 String getSectionPaint() {
+ return (String) valueBinding("sectionPaint", sectionPaint);
+ }
+
+ public void setSectionPaint(String sectionPaint) {
+ this.sectionPaint = sectionPaint;
+ }
+
@Override
public void encodeEnd(FacesContext context)
throws IOException
{
super.encodeEnd(context);
- key = (String) valueBinding(context, "key", key);
- rowKey = (String) valueBinding(context, "rowkey", rowKey);
- columnKey = (String) valueBinding(context, "columnKey", columnKey);
- value = (Number) valueBinding(context, "value", value);
+ key = (String) valueBinding("key", key);
+ rowKey = (String) valueBinding("rowkey", rowKey);
+ columnKey = (String) valueBinding("columnKey", columnKey);
+ value = (Number) valueBinding("value", value);
UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
if (chart != null) {
@@ -50,6 +89,26 @@
if (dataset instanceof DefaultPieDataset) {
DefaultPieDataset piedata = (DefaultPieDataset) dataset;
piedata.setValue(key, value);
+
+ PiePlot plot = (PiePlot) chart.getChart().getPlot();
+
+ if (explodedPercent != null) {
+ plot.setExplodePercent(key, getExplodedPercent());
+ }
+
+ if (sectionPaint != null) {
+ plot.setSectionPaint(key, UIChart.findColor(getSectionPaint()));
+ }
+
+ if (sectionOutlinePaint != null) {
+ plot.setSectionOutlinePaint(key, UIChart.findColor(getSectionOutlinePaint()));
+ }
+
+ if (sectionOutlineStroke != null) {
+ plot.setSectionOutlineStroke(key, UIChart.findStroke(getSectionOutlineStroke()));
+ }
+
+
} else if (dataset instanceof DefaultCategoryDataset) {
DefaultCategoryDataset data = (DefaultCategoryDataset) dataset;
data.addValue(value, rowKey, columnKey);
@@ -60,7 +119,6 @@
}
}
-
@Override
public void createITextObject(FacesContext context) {
@@ -80,5 +138,4 @@
public void removeITextObject() {
}
-
}
1.3 +1 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UILineChart.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UILineChart.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UILineChart.java 2 May 2007 01:09:04 -0000 1.2
+++ UILineChart.java 3 May 2007 02:33:12 -0000 1.3
@@ -62,7 +62,7 @@
}
@Override
- public JFreeChart getChart(FacesContext context) {
+ public JFreeChart createChart(FacesContext context) {
if (!is3D) {
return ChartFactory.createLineChart(title,
domainAxisLabel,
1.3 +287 -22 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIPieChart.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIPieChart.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UIPieChart.java 2 May 2007 01:09:04 -0000 1.2
+++ UIPieChart.java 3 May 2007 02:33:12 -0000 1.3
@@ -1,45 +1,232 @@
package org.jboss.seam.pdf.ui;
+import java.awt.Color;
+
import javax.faces.context.FacesContext;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
+import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
+import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.Plot;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.DefaultPieDataset;
+import org.jfree.util.Rotation;
public class UIPieChart
extends UIChart
{
- DefaultPieDataset data;
-
- String title;
+ private DefaultPieDataset data;
- boolean legend;
- boolean tooltips;
- boolean urls;
- boolean is3D = false;
+ 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 void setLegend(boolean legend) {
- this.legend = legend;
+ 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 setTooltips(boolean tooltips) {
- this.tooltips = tooltips;
+ public void setLegend(boolean legend) {
+ this.legend = legend;
}
- public void setUrls(boolean urls) {
- this.urls = urls;
+ 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);
+ }
+
+ public void setBaseSectionOutlinePaint(String baseSectionOutlinePaint) {
+ this.baseSectionOutlinePaint = baseSectionOutlinePaint;
+ }
+
+ public String getBaseSectionOutlineStroke() {
+ return (String) valueBinding("baseSectionOutlineStroke", baseSectionOutlineStroke);
+ }
+
+ public void setBaseSectionOutlineStroke(String baseSectionOutlineStroke) {
+ this.baseSectionOutlineStroke = baseSectionOutlineStroke;
+ }
+
+ public String getBaseSectionPaint() {
+ return (String) valueBinding("baseSectionPaint", baseSectionPaint);
+ }
+
+ public void setBaseSectionPaint(String baseSectionPaint) {
+ this.baseSectionPaint = baseSectionPaint;
+ }
+
+ public Boolean getCircular() {
+ return (Boolean) valueBinding("isCircular", circular);
+ }
+
+ public void setCircular(Boolean circular) {
+ this.circular = circular;
+ }
+
+ public String getLabelBackgroundPaint() {
+ return (String) valueBinding("labelBackgroundPaint", labelBackgroundPaint);
+ }
+
+ public void setLabelBackgroundPaint(String labelBackgroundPaint) {
+ this.labelBackgroundPaint = labelBackgroundPaint;
+ }
+
+ public Double getLabelGap() {
+ return (Double) valueBinding("labelGap", labelGap);
+ }
+
+ public void setLabelGap(Double labelGap) {
+ this.labelGap = labelGap;
+ }
+
+ public Double getLabelLinkMargin() {
+ return (Double) valueBinding("labelLinkMargin", labelLinkMargin);
+ }
+
+ public void setLabelLinkMargin(double labelLinkMargin) {
+ this.labelLinkMargin = labelLinkMargin;
+ }
+
+ public String getLabelLinkPaint() {
+ return (String) valueBinding("labelLinkPaint", labelLinkPaint);
+ }
+
+ public void setLabelLinkPaint(String labelLinkPaint) {
+ this.labelLinkPaint = labelLinkPaint;
+ }
+
+ public String getLabelLinkStroke() {
+ return (String) valueBinding("labelLinkStroke", labelLinkStroke);
+ }
+
+ public void setLabelLinkStroke(String labelLinkStroke) {
+ this.labelLinkStroke = labelLinkStroke;
+ }
+
+ public Boolean isLabelLinksVisible() {
+ return (Boolean) valueBinding("labelLinksVisible", labelLinksVisible);
+ }
+
+ public void setLabelLinksVisible(Boolean labelLinksVisible) {
+ this.labelLinksVisible = labelLinksVisible;
+ }
+
+ public String getLabelOutlinePaint() {
+ return (String) valueBinding("labelOutlinePaint", labelOutlinePaint);
+ }
+
+ public void setLabelOutlinePaint(String labelOutlinePaint) {
+ this.labelOutlinePaint = labelOutlinePaint;
+ }
+
+ public String getLabelOutlineStroke() {
+ return (String) valueBinding("labelOutlineStroke", labelOutlineStroke);
+ }
+
+ public void setLabelOutlineStroke(String labelOutlineStroke) {
+ this.labelOutlineStroke = labelOutlineStroke;
+ }
+
+ public String getLabelPaint() {
+ return (String) valueBinding("labelPaint", labelPaint);
+ }
+
+ public void setLabelPaint(String labelPaint) {
+ this.labelPaint = labelPaint;
+ }
+
+ public String getLabelShadowPaint() {
+ return (String) valueBinding("labelShadowPaint", labelShadowPaint);
+ }
+
+ public void setLabelShadowPaint(String labelShadowPaint) {
+ this.labelShadowPaint = labelShadowPaint;
+ }
+
+ public String getDirection() {
+ return (String) valueBinding("rotation", direction);
+ }
+
+ public void setDirection(String rotation) {
+ this.direction = rotation;
+ }
+
+ public String getSectionOutlinePaint() {
+ return (String) valueBinding("sectionOutlinePaint", sectionOutlinePaint);
+ }
+
+ 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 createDataset() {
data = new DefaultPieDataset();
@@ -50,23 +237,101 @@
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 getChart(FacesContext context) {
- legend = (Boolean) valueBinding(context, "legend", legend);
- tooltips = (Boolean) valueBinding(context, "tooltips", tooltips);
- urls = (Boolean) valueBinding(context, "urls", urls);
+ public JFreeChart createChart(FacesContext context) {
+ legend = (Boolean) valueBinding(context, "legend", getLegend());
if (!is3D) {
- return ChartFactory.createPieChart(title, data, legend, tooltips, urls);
+ return ChartFactory.createPieChart(getTitle(), data, legend, false, false);
} else {
- return ChartFactory.createPieChart3D(title, data, legend, tooltips, urls);
+ return ChartFactory.createPieChart3D(getTitle(), data, legend, false, false);
}
}
More information about the jboss-cvs-commits
mailing list