Monday, May 18, 2009

Two nice JAVA library that i tried

It has been a tough 2 weeks from May. I had to rush for ELISSA project (Early Intervention Support System for Special Children). It is a Java + MySQL based app. Intergration of it with RFID and Serial really headache.

Two nice JAVA library that i had tried it on.

1. JFreeChart, it indeed a nice libraty for chart plotting and displaying. We can easily manipulate the input, axis label and which type of chart display. I used BarChart3DDemo4.java that provided in the demo set,since the threshold need to be set and diplay it above the result.

Example for the axis label manipulation that i changed :

ModuleBarChart graph1 = new ModuleBarChart("Result 1");
graph1.charttitle = "Fine motor";
graph1.xaxistitle = "Subgroup";
graph1.xlabel1 = "Swimming";
graph1.ylabel1 = 5;
graph1.chartDisplay();


2. iTEX PdfWriter, easy-to-use library to make the app output to PDF format. Their website provided some dummy sample and i manage to get it on after a few trys. The output pdf file will created the your current working directory.

public static void main(String[] args) {

String text = " ELISSA Assessment result test";
String imgpath = "resources/images/dataguiback.jpg" ;

System.out.println("ELISSA report");

// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to System.out (and a txt file)
PdfWriter w = PdfWriter.getInstance(document, System.out);
w.setCloseStream(false); // System.out should not be closed
PdfWriter.getInstance(document,
new FileOutputStream("output.pdf"));

// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph(text));

document.add(new Paragraph("Assessment Result"));
Image jpg = Image.getInstance(imgpath);
document.add(jpg);

} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}

// step 5: we close the document
document.close();
}
}

No comments:

Post a Comment