Saturday, December 27, 2008

Free JFreeCharts Info.

I had to use JFreeCharts all of a sudden, kind of in a rush. I had no previous information about it until I could get hold of a free JFreeCharts Developer Guide, I am lucky that I could use it since my company paid for it.

After accomplishing a few tasks using JFreeCharts, I wanted to summarize what I discovered about JFreeCharts. Well, without any further due I am going to get right into it:
To start with, it is an API to give a "face" to your data, so in simpler terms JFreeCharts helps you turn numbers into diagrams and the output diagrams can be be piped into as a PDF(using iText) or SVG(using batik) file. It fits well in a situation when you as a developer have to convey the meaning of the data in the database to a separate team like business or maybe the architecture team.

We have a tool that we developed in-hosue, the tool basically saves time since it makes querying the database a lot easier. There are tables in the database that tell how many times queries were fired and how many people were accessing the database and doing the four holy things that we always do with the database(add, edit, get, delete). Now, using the JFreeCharts methods I could give a meaningful representation to the logs in these tables, in terms of Pie Charts, Bar Charts, Line Charts, Scatter Plots, Time Series Charts etc.

I will get into details of my accomplishments with JFreeCharts but before thast just for a simple overview, the following is a list of packages into which all of the class libraries are bundled, for a resonoably advanced reader, the hierarchial names should give an initial insight into what can be accomplished with the classes and inturn the methods inside them.

(for brevity I have put everything that can be dotted in the parenthesis)
org.jfree.chart (annotations, axis, block, entity, event, imagemap, labels, needle, plot, renderer, renderer.category, renderer.xy, servlet, title, ui, urls,

(for brevity I have put everything that can be dotted after "data" in parenthesis)
org.jfree.chart.data (category, contour, function, gantt, general, jdbc, statistics, time, xml, xy)

Pie Chart can be generated using data which can be cast to the PieDataset interface and the same chart can be displayed with a 3D effect.

Data which confirms to the CategoryDatset interface can be displayed as Bar Chart and/or Line Chart

Similarly, data that confirms to the XYDataset interface can be used to generate a range of chart types. By default lines are drawn between datasets. So one can give just the X, Y data points and the interface will draw the line to connect them by default. Extentions of XYDataset such as HighLowDataset and IntervalXYDataset can be used to high-low-open-close data and histograms respectively.

Area Charts and Stacked Area Charts can be generated using data of CategoryDataset and XYDataset interface types. The list of kids of Charts that can be generated using JFreeCharts goes on and on, you name it.

There are three clear-cut steps that goes into getting data, presenting data and displaying the data into diagrams, the steps are as follows:

The steps:

1. Create the appropriate dataset using the data in hand(technically in the tables of your database system)

2. "Presenting the Data" created(or cast) in step 1. Involves creating a JFreeChart object which will draw the chart, eg. ChartFactory can draw the data in step 1.

3. The final step is "Displaying Chart" for eg. displaying the chart in a frame on the screen.


// Step 1 (creating the dataset, in other terms casting your data into a JFreeChart Dataset type)
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Amar" , 30.4);
dataset.setValue("Akbar" , 19.6);
dataset.setValue("Anthony" , 85.5);

//Step 2 (creating the chart)
JFreeChart chart = ChartFactory.createPieChart("The Chart", dataset, true, true, false);//starting from the frist boolean: legend, tooltips, urls

//Step 3 (creating and displaying a frame)
ChartFrame frame = new ChartFrame("Example", chart);
frame.pack();
frame.setVisible(true);



Once a chart object is created in step 2, a plethora of further customization eg. setting background color, getting the plot object fromt he chart object for further customization and in-turn a "renderer" object can be obtained from the the plot object to customize colors and other like attributes.

Please copy and paste the following for a google search box and click "Google Search" button, to move onto the second of my article on TimeSeriesCharts and how I used it. The text to search for in google is:

Free JFreeCharts Guide, JFreeCharts developer guide, TimeSeries, XYDataSet, Pie Chart, Bar Chart, JFreeCharts API, Premium JFreeCharts

Free Premium JFreeCharts Info.

I had to use JFreeCharts all of a sudden, kind of in a rush. I had no previous information about it until I could get hold of a free JFreeCharts Developer Guide, I am lucky that I could use it since my company paid for it.

After accomplishing a few tasks using JFreeCharts, I wanted to summarize what I discovered about JFreeCharts. Well, without any further due I am going to get right into it:
To start with, it is an API to give a "face" to your data, so in simpler terms JFreeCharts helps you turn numbers into diagrams and the output diagrams can be be piped into as a PDF(using iText) or SVG(using batik) file. It fits well in a situation when you as a developer have to convey the meaning of the data in the database to a separate team like business or maybe the architecture team.

We have a tool that we developed in-hosue, the tool basically saves time since it makes querying the database a lot easier. There are tables in the database that tell how many times queries were fired and how many people were accessing the database and doing the four holy things that we always do with the database(add, edit, get, delete). Now, using the JFreeCharts methods I could give a meaningful representation to the logs in these tables, in terms of Pie Charts, Bar Charts, Line Charts, Scatter Plots, Time Series Charts etc.

I will get into details of my accomplishments with JFreeCharts but before thast just for a simple overview, the following is a list of packages into which all of the class libraries are bundled, for a resonoably advanced reader, the hierarchial names should give an initial insight into what can be accomplished with the classes and inturn the methods inside them.

(for brevity I have put everything that can be dotted in the parenthesis)
org.jfree.chart (annotations, axis, block, entity, event, imagemap, labels, needle, plot, renderer, renderer.category, renderer.xy, servlet, title, ui, urls,

(for brevity I have put everything that can be dotted after "data" in parenthesis)
org.jfree.chart.data (category, contour, function, gantt, general, jdbc, statistics, time, xml, xy)

Pie Chart can be generated using data which can be cast to the PieDataset interface and the same chart can be displayed with a 3D effect.

Data which confirms to the CategoryDatset interface can be displayed as Bar Chart and/or Line Chart

Similarly, data that confirms to the XYDataset interface can be used to generate a range of chart types. By default lines are drawn between datasets. So one can give just the X, Y data points and the interface will draw the line to connect them by default. Extentions of XYDataset such as HighLowDataset and IntervalXYDataset can be used to high-low-open-close data and histograms respectively.

Area Charts and Stacked Area Charts can be generated using data of CategoryDataset and XYDataset interface types. The list of kids of Charts that can be generated using JFreeCharts goes on and on, you name it.

There are three clear-cut steps that goes into getting data, presenting data and displaying the data into diagrams, the steps are as follows:

The steps:

1. Create the appropriate dataset using the data in hand(technically in the tables of your database system)

2. "Presenting the Data" created(or cast) in step 1. Involves creating a JFreeChart object which will draw the chart, eg. ChartFactory can draw the data in step 1.

3. The final step is "Displaying Chart" for eg. displaying the chart in a frame on the screen.


// Step 1 (creating the dataset, in other terms casting your data into a JFreeChart Dataset type)
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Amar" , 30.4);
dataset.setValue("Akbar" , 19.6);
dataset.setValue("Anthony" , 85.5);

//Step 2 (creating the chart)
JFreeChart chart = ChartFactory.createPieChart("The Chart", dataset, true, true, false);//starting from the frist boolean: legend, tooltips, urls

//Step 3 (creating and displaying a frame)
ChartFrame frame = new ChartFrame("Example", chart);
frame.pack();
frame.setVisible(true);




Once a chart object is created in step 2, a plethora of further customization eg. setting background color, getting the plot object fromt he chart object for further customization and in-turn a "renderer" object can be obtained from the the plot object to customize colors and other like attributes.

Thanks for reading and Thanks for stopping by!!

~Nirmal

Keep your friends close and your enemies closer.
Sun-Tzu

Wednesday, December 17, 2008

Most Used Eclipse Shortcuts

This list is I believe (becoz i use : ) ), the most used eclipse shortcuts, be it myEclipse, IRAD's eclipse, CFEclipse or any other flavor of eclipse.

These are mostly the ones you use to edit text in the editor and also has the most important ones for searching.

I am sure at least 3 to 4 shortcuts here will be new for every avid shortcut users.

ctrl + shift + t
search for (java) types
you can enter only the uppercase letters of your wanted class or interface. eclipse will bring only such types to the top which contains these uppercase letters inside their names.
i.e. entering BAD finds BaseAccountData or BindAccountDAO etc

ctrl + shift + r
searches for any resources .
the same is true for search with uppercase letters as mentioned above. beside types, eclipse will list any other resources, i.e. jsp, xml, properties, ...

ctrl + o
searches for a method inside a type. let you jump quickly to the beginning of a method.

F3
opens the declaration of a type. let you jump quickly from a type to another type. just place the cursor to the declared type you want to jump to and hit F3. you can alternatively push ctrl and click onto the type you want to open.

alt + arrow left / rigth
lets you jump right back (and forth) to the location (i.e. type declaration) you came from.

ctrl + t
shows the type hierarchy of a type. just place the cursor to the declared type with the wanted hierarchy and hit ctrl + t. now you can scroll through the hierarchy (arrow up / down) and open the desired supertype or subtype (by hitting enter).

ctrl + shift + g
searches for all references of a type or method. just place the cursor the the declaration of the type or method and hit ctrl + shift + g. now you have an overview of all types in workspace which references your class / method.


Ctrl+(shift+)k
-> Searching forward (backward) for the last highlighted text

Ctrl+. -> Go to the next warning / error
Ctrl+, -> Go to the previous warning / error
* works in Javaperspective, not e.g. in phpeclipse

Ctrl+shift+l -> List of many available Shortcuts


Alt + Shift + J, release then press X
runs the program

Ctrl + NumPad - or +
to collapse/uncollapse

Ctrl + NumPad * (multiply key)
To expand all

Ctrl + NumPad / (divide key)
to collapse all

Alt+Shift+Q, B
Show all breakpoints

Alt+Shift+Q, H
Cheat sheets

Alt+Shift+Q, C
Show console

Ctrl+Shift+X
To upper case

Ctrl+Shift+Y
To lower case

Ctrl+Shift+Up
Go to previous member

Ctrl+Shift+Down
Go to next member

Ctrl+Shift+P
Go to matching bracket

Ctrl+Alt+H
Open call hierarchy

Alt + Shift + S
source quick menu

Ctrl + Shift + \ or / or C
comment uncomment block

Ctrl + /
toggle selection comment


Ctrl + L
Shift left

Ctrl + 3
Pretty much lets you search anything and everything

Ctrl + E
Same as ctrl + F6