#Open Source INFO
The present project try to make the Chart generation easy through a Fluent Api [1]. The core of the Api is based on JFreechart.
The engine of the DSL for create Charts use the @Chart
annotation for create the whole Chart. Basically, you have to decorate the class on your class with the Annotation and add properties that will map on graph properties.
Let's to build a graph of "amount vs age " with the next information:
Player | Mount | Age | Date |
---|---|---|---|
Cristiano Ronaldo | 1344.567 | 29 | 27/09/2014 |
Messi | 2344.567 | 27 | 27/09/2014 |
Bale | 544.567 | 25 | 27/09/2014 |
The steps for create a graph are shown next:
Steps:
- Create a JavaBean Class. and add an
@Graph
Annotation on top Of the class.- Configure the The DSL for create the Graph
###Create a JavaBean Class###
The Pojo created is shown next:
@Chart(chartType = ChartType.PIE_CHART, xProperty = "edad", yProperty = "cantidad")
public class Persona {
private String persona;
private double cantidad;
private int edad;
private Date fecha;
//Getters and Setters methods
.
.
###Configure the The DSL for create the Graph.###
Here I show a snipped of code for create a graph Based on the DSL and @Graph
annotation:
import static com.danimaniarqsoft.report.poi.dsl.WorkbookBuilder.createWorkbook;
private List<Persona> personasDataset;
//Fill personasDataset from some datasource
JFreeChart chart = createChart().ofTypeXYPlotChart()
.withXAxisLabel("X-edad").
withYAxisLabel("Y-cantidad")
.withChartTitle("Reflection")
.addDataSet(personasDataset, Persona.class).
createChart();
ChartUtilities.saveChartAsJPEG(new File("ReflectionChart.jpg"),
The @Graph
annotation has a lot of properties for control the way how the DSL have to build the graph. The next table describe each property:
Aligments
Property | Description | Default |
---|---|---|
name | The name of the column | nothing, it is mandatory |
chartType | This property is used for choose the kind of Graph we would like to build. The value is defined in the Enum com.danimaniarqsoft.report.chart.dsl.ChartType | nothing, it is mandatory |
xProperty | In this property we have to provide the correct name of the instance class that we want to use for print a point into the graph, This property represent the x coordinate of the point that will be printed in the graph | nothing, it is mandatory |
© danimaniArqsoft
Fluent Interface, Martin Fowler on December twenty of 2005 write about a certain style of interface which he decided to name fluent interface. We write DSL's based on the concept of Fluent Interface ↩
The present project try to make the Excel development easy through Fluent Api for create Excel documents. The core Api for the DSL [1] is based on Apache POI.
The engine of the DSL for create Excel documents use the @ExcelColumn
annotation to create the whole Document. Basically, you have to decorate the attributes on your class with the Annotation and add properties that will map on the cell.
Let's to build a excel document like it show next:
Persona | Cantidad | Edad | Fecha |
---|---|---|---|
Cristiano Ronaldo | 1344.567 | 29 | 27/09/2014 |
Messi | 2344.567 | 27 | 27/09/2014 |
Bale | 544.567 | 25 | 27/09/2014 |
The steps for create a document are shown next:
Steps:
- Create a JavaBean Class. and add an
@ExcelAnnotation
on each property of the class property where we want to map in the excel document.- Configure the The DSL for create the Document.
###Create a JavaBean Class###
The Pojo created is shown next:
public class Persona {
@ExcelColumn(name = "Persona")
private String persona;
@ExcelColumn(name = "Cantidad")
private double cantidad;
@ExcelColumn(name = "Edad")
private int edad;
@ExcelColumn(name = "Fecha")
private Date fecha;
//Getters and Setters methods
.
.
###Configure the The DSL for create the Document.###
Here I show a snipped of code for create a document Based on the DSL and @ExcelColumn
annotation:
import static com.danimaniarqsoft.report.poi.dsl.WorkbookBuilder.createWorkbook;
Workbook wb = createWorkbook(WorkbookEnum.XLSX)
.createSheet("hoja1")
.createHeader(Persona.class)
.createRows(personas, Persona.class)
.buildWorkbook();
The @ExcelAnnotation
has a lot of properties for control the way that the DSL have to build the Excel Document. The next table describe each property:
Aligments
Property | Description | Default |
---|---|---|
name | The name of the column | nothing, it is mandatory |
dateFormat | This property is used for java.util.Date type. The value is a String with the date format defined on Java Date Format | "dd/MM/YYYY" |
textPosition | this property is used for align vertical text both Horizontally and vertically on a Cell | TextPosition.ALIGN_CENTER |
fontFormat | this property is used for font format | FontFormat.NORMAL |
© danimaniArqsoft
Fluent Interface, Martin Fowler on December twenty of 2005 write about a certain style of interface which he decided to name fluent interface. We write DSL's based on the concept of Fluent Interface ↩