October 2006 - Posts

It was quite a busy month before, I rarely even had time to post an entry. Luckily I am here now to tell about this exciting tool from the java community. It's called JFreeChart. Our team decided to use it(ehem, thanks to my research) and it seems to do a very good job. Although, the online documentation isn't complete... You have to buy it which doesn't make JFreeChart a free software after all. But with or without the docs they sell you can still use it effectively.


Here's a snipper of code that loads a data from a database, puts them in a List and sets the value for a PieChart. This is by no means a complete code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    public JFreeChart createChart()
{
     DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
    
GeographicDAO geographicdao = dao.getGeographicDAO();
  
     ArrayList<CountryBean> countryList = geographicdao.selectCountryList(magazine, timeStamp);

     geographicdao.freeConnection();
    
     DefaultPieDataset dataSet = new DefaultPieDataset();
    
     Country country = null;
    
     for (int i = 0; i < countryList.size(); i++)
     {
       country= countryList.get(i);
      
       dataSet.setValue( country.getCountryName() + " = " + country.getPercentage() + "%", Float.parseFloat( country.getPercentage() ) );
      
       country = null;
     }

     chart = ChartFactory.createPieChart3D("Country graph", dataSet, true, true, false);
    
   return chart;
}

public void writeChart(OutputStream ostream, int width, int height) throws IOException
{
  ChartUtilities.writeChartAsJPEG( ostream, chart, width, height);
}


And here's how it might look



Posted by lamia | with no comments
Filed under:
I'm really feeling so tired as I'm writing this post. But that's not to stop me as I am very happy to have learned something new. While I was studying client's code, Converting from PHP to Java. I didn't quicly realize the how script.aculo.us and Prototype.js makes your javascripting life so much faster. HTML elements can be referred to by typing $("element") inside the <script></script> tags. And also form values using the $F("formelement").

Now the thing that made me jump with joy is how the Observer pattern is implemented in this framework. Take a look at the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
                        <select name="intervalType" style='width: 100%'>
<c:forEach var="interval" items="${intervalList}" varStatus="status">
<option value="${interval.intervalType}">${interval.intervalName}</option>
</c:forEach>
</select>

<script language="JavaScript" type="text/javascript">
Event.observe('intervalType', 'change', checkIntervalChange, false);

function checkIntervalChange()
{
if ( $("intervalType").value == "${intervalList[3].intervalType}" )
{
$("intervalStartDate").disabled = false;
$("intervalEndDate").disabled = false;
}
else
{
$("intervalStartDate").disabled = true;
$("intervalEndDate").disabled = true;
}
}
</script>


Isn't that very interesting? I hope you don't confuse JSP's Expression Language${} with Javascript's $(). :)
Posted by lamia | 1 comment(s)
A friend sent me an e-mail attachment with this news from javalobby dated Tuesday, October 03, 2006. I don't have the exact URL but could at least post the news here on my blog. I wonder what Microsoft has been up to. I don't know if this is a problem with their system or a conspiracy lying there but I'm not scared since I could just switch between operating systems(windows, linux/solaris, macintosh). I don't give a damn about vista's new look and feel. It doesn't make the user any more intelligent anyway. But I am a little worried about about job security though, since most people are using windows then something has to be done to fix this! Darn it!




Java and Vista not playing well together

Two items at dzone.com caught my eye this week and seemed worth mentioning to you. First, barring the occurrence of some major unforeseen problem, Microsoft is just one final test version away from releasing the �golden master� of its new Vista operating system. This is really big news for both Microsoft and the industry as a whole, even if Vista has lost several of its more intriguing features during the years of its development. Vista is the next wave of big business for Microsoft and for legions of ISVs, system integrators, OEMs and resel lers whose economic prospects are tied in with those of the industry leader. (Note: I have to tell you I made a Freudian slip when first typing the previous sentence, typing �bug business� rather than �big business.� Of course, �u� and �i� are very close to one another on the keyboard) Many billions of dollars are at stake with Vista, numbers so huge most of us probably cannot even begin to comprehend their scale. For Microsoft to be just one final �test version� away from finalizing its next big thing is major news for our whole industry, if not for the global economy.

The second item was a disconcerting one, at least one the surface of things. It appears that Vista and certain desktop Java applications do not play well together. One of the most promin ent features of Vista is the �Aero� graphics effects that give the Vista UI its distinctive, high-gloss appearance. In testing at eWEEK Labs it was discovered that running Swing or Eclipse SWT applications can cause this slick-looking Vista eye candy to be completely disabled, at least on the recent pre-release build 5728 of Vista. If you�re interested in more details, then a nice discussion of this problem and its possible causes and solutions is available in the forums at Javalobby.

So, let�s put two and two together. Vista is just one final test version away from being released to production, and Java desktop applications are somehow disabling the slickest and most visible part of the new Vista interface. I don�t know how you feel about it, but I think this is potentially a very sticky situation. I have not heard any indication that this problem is the result of some new conspiracy involving either of the former archrivals, Sun a nd Microsoft. On the contrary, it seems to be a genuine case of a regrettable technical problem that is getting noticed very late in the game, perhaps too late for it to be fixed before Vista is finalized. Another interesting dzone.com link last month, �Microsoft's Process: What it takes to get a bug fixed before Vista ships� made clear how impressively difficult it is to get changes made to Vista. Judging from that description, it will be a minor miracle if this Java/Vista problem is successfully resolved. Ooops!



After a bit of research on google about this issue, I found this blog and everything seems ok... If there's a bit of a problem I guess it won't make much difference...




Posted by lamia | 3 comment(s)
Filed under: ,