Saturday, March 31, 2007

Display Busy Cursor in Java

Most guides and books will tell you that it is very easy to change the cursor in a Java application. For example, the following fragment of code sets the cursor to a busy cursor while it performs some processing, and then returns the cursor to the default cursor again afterwards.


import java.awt.Cursor;

// Setting cursor for any Component:
component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
doProcessing();
component.setCursor(Cursor.getDefaultCursor());

This is a good start but, somewhat surprisingly, this short code fragment contains a bug. The problem is that the main processing method might throw an exception. If the exception is not caught within the processing method, then the Java Virtual Machine unwinds the call stack repeatedly until it finds a try context that will catch the given exception. In other words, the flow of control may jump out of this (apparently) linear flow of control and we therefore cannot guarantee that the default cursor is restored. In short, if an exception is thrown, the busy cursor will remain there indefinitely!

Wednesday, March 21, 2007

Warcraft/ Frozen Throne - Dota Item Effect Calculation

Inside Dota, We know that most item effect is not direct stack, example with 1 basher hero will gain 15% of stun chance, but with 2 basher is not equal to 2 X 15% = 30% of stun chances.

The actual formula of multiple item should calculate based on :
Total % = Current % / 100 + (100 - Current %)/100 * Additional %/100

Tuesday, March 6, 2007

乱世心情

最近,马股下跌的速度超出我的想象,
终于体验到人家所说的惊慌抛售,
除此之外,读过的什么逆势操做,什么人卖你买的一大堆理论,
仿佛在这个环境都变得不重要,就算清楚的知道但却很难克服心理上的障碍去执行。
毕竟看着身价一天一天的狂跌,要不为所动是很难的,
也明白到为什么很多人都不敢踏足股市,
至于一些人满口理论,只要是过来人就明白他们从没买卖任何股票,全都是纸上谈兵,
因为真正买卖过的人就知道有些东西真的是说是容易做时难。