Friday, November 20, 2009

GUI development and Java FX

I hate GUI development. I'm sure lots of developers feel exactly the same way. Even if you are gifted with a sense of aesthetics that allows you to appreciate how Finder or Windows Explorer are superior to a command-line, you might still hate GUI development.

One of the reasons for this could be the difficulty of getting from a paper UI mockup to something that actually works. I've often found programs with UI design that I appreciate, but the work required to duplicate the approach is often insurmountable.

Consider the tools developers generally have at their disposal. Most, if not all of them, are very good at building applications that conform to an aesthetic that (as far as I can remember) comes from Windows 95. I'm talking about the single, resizeable window, menus, dialog boxes maybe a tool bar or 2 or 3 and a big blank space in the middle where your work goes. The best tool I've used for this kind of UI design is Qt Designer. But this doesn't help you if you want animation, or zooming or free-form layout. As soon as you go out of the standard UI box you need to build almost everything yourself. And that sucks.

Java FX seems to be one of a few tools gaining popularity these days that help us break out of the old paradigm. Consider the following code snippet. It defines an object that can be used as an arbitrarily large surface and defines a viewport onto it so that the user can drag their view around instead of dragging the objects on the view around.
public class Viewport extends CustomNode {
    public var viewWidth :Float;
    public var viewHeight :Float;
    public var content :Node[];

    var currentX :Float = 0;
    var currentY :Float = 0;
    var dragStartX :Float = 0;
    var dragStartY :Float = 0;

    def viewport = Rectangle {
        x: bind -currentX
        y: bind -currentY
        width: bind viewWidth;
        height: bind viewHeight;
        fill: Color.TRANSPARENT;
    };

    override function create() :Node {
        insert viewport before content[0];

        return Group {
            content: bind content;
            translateX: bind currentX;
            translateY: bind currentY;
        }
    }

    override var onMousePressed =
        function(event :MouseEvent) :Void {

            dragStartX = event.sceneX + currentX;
            dragStartY = event.sceneY + currentY;
        };

    override var onMouseDragged =
        function(event :MouseEvent) :Void {

            currentX = dragStartX - event.sceneX;
            currentY = dragStartY - event.sceneY;
        };
}

I doubt that can be done as easily, quickly and readably in Qt or Apple's Interface Builder. That viewport class took about 1 hour to code. Now lets say you want to drag the widgets around on the viewport, no problem, just put them in a DraggableGroup like this one.
public class DraggableGroup extends CustomNode {
    public var content :Node[];

    override def blocksMouse = true;
    var currentX :Float = 0;
    var currentY :Float = 0;
    var dragStartX :Float = 0;
    var dragStartY :Float = 0;

    override function create() :Node {
        return Group {
            content: bind content;
            translateX: bind currentX;
            translateY: bind currentY;
        }
    }

    override var onMousePressed =
        function(event :MouseEvent) :Void {

            dragStartX = event.sceneX - currentX;
            dragStartY = event.sceneY - currentY;
    };

    override var onMouseDragged =
        function(event :MouseEvent) :Void {

            currentX = event.sceneX - dragStartX;
            currentY = event.sceneY - dragStartY;
    };
}

Although this isn't particularly exciting, it does show that with some basic built-ins you can create a GUI that would be quite hard to put together in one of the stalwart toolkits developers normally use, although you're in trouble if you want multi-line text editing!

Sunday, November 15, 2009

Java FX and the Yield Slope

Recently I've been looking at Java FX, a promising new technology from Sun that is supposed to help developers create rich web applications, desktop applications and mobile applications.

While Java FX 1.2 can't live up to that promise just yet, it is nonetheless fun to use. The biggest missing component is a design tool. The FX community is abuzz with the possibility of this gap being bridged in the next version, hopefully to be released sometime soon. Some early screen-shots can be seen here.

On the plus side, Java FX (on the desktop) has access to the full class library of Java SE. Unfortunately, this isn't true for the browser or mobile versions (for obvious reasons.) For those configurations, we have to wait for the default Java FX class library to grow.

The following is a simple (and ugly - GUI design isn't my forte) Java FX application that graphs the yield slope over the last 30 years.


 Click the image to run the program

Saturday, October 31, 2009

Meaning of the yield curve

A lot of discussion about economics today mentions the importance of the steep yield curve. Some even make predictions about what will happen next, giving the yield curve as evidence. But what is the meaning of a steep yield curve?

The Yield Curve Today

First, a refresher, what is the yield curve? As with most things, Wikipedia has a great article on the topic, so I'll just borrow from them:
The yield curve is the relation between the interest rate and the time to maturity of the debt. The yield of a debt instrument is the overall rate of return available on the investment. For instance, a bank account that pays an interest rate of 4% per year has a 4% yield. Investing for a period of time t gives a yield Y(t). This function Y is called the yield curve, and it is often, but not always, an increasing function of t.
The slope of the yield curve tells us how quickly the yield increases as the term increases. A quick way of checking this slope is to compare the yield of the 10 year treasury note to that of the 2 year note. The following graph shows how this value has changed over the last 20 years.



The current value, 2.49%, is much higher than the average, 1%. In fact it is about as high as it has ever been over the last 20 years. This qualifies as a steep yield curve.

What does it mean?

Negative sloping yield curves are reasonably accurate predictors of recession and steep yield curves are predictors of strong economic growth. As you can see in the graph above, the yield curve was almost flat throughout the mid-90s indicating a risk of economic weakness. Arguably this risk manifested itself as the tech sector crash in early 2000. During parts of 2005-2006, preceding the current recession, the yield curve was negative.

A steep yield curve is generally considered to be a predictor of strong economic growth. The yield curve was steep coming out of the recessions in the early '90s and 2000s. Since the yield curve is just as steep now as it was then, does this mean we are out of the woods and can look forward to strong growth?

As the economy heats up, inflation will generally increase. Most central banks will try to keep inflation within a (low) controlled range. They will adjust monetary policy to this effect. The most commonly employed method of keeping high inflation in check is increasing the lending rate. A steep yield curve represents and adjustment for the risk of higher interest rates in the future, which implies economic growth.

But there are other potential causes for inflation. Some argue that the steep curve is adjusting for the risk of inflation due to the massive stimulus the government has injected into the economy through the policy of quantitative easing the US Federal Reserve applied in 2008-2009. If this turns out to be correct, we could have inflation without recovery.

References

http://en.wikipedia.org/wiki/Yield_curve
http://beginnersinvest.about.com/lw/Business-Finance/Personal-finance/The-Yield-Curve.htm
http://gregmankiw.blogspot.com/2009/05/yield-curve-is-steep.html
http://www.ustreas.gov/offices/domestic-finance/debt-management/interest-rate/yield.shtml

Tuesday, October 27, 2009

Analysis of Callaway Golf Company (NYSE:ELY)

Callaway Golf Company (ELY)

Callaway Golf Company sells all things golf related. This includes, golf balls, golf clubs, golf gizmos and golf attire. They have products targetting all price points but with a general emphasis on technologically superior products.

The current economic downturn has hurt Callaway's profits badly; both Q1 and Q2 2009 profits fell ~82% YOY. Sales were down 17% over the same period. Despite being hit pretty hard, they did manage to turn a profit.

Callaway has no short or long-term debt and $50 million cash on hand. They recently sold $140 million worth of preferred shares which they used to pay off $90 million of debt on a line of credit. I think this shows that management values a strong balance sheet and that they are financing the company conservatively during this downturn.

Historically, Callaway tends to lose money during Q3 and Q4 and I'm sure this year will be worse than usual. However, this is not unexpected and as mentioned above, Callaway have taken precautions to work through the hard times. Given that a weak recovery is projected for 2010, Callaway have already weathered the worst of the storm.

Bullish Argument

The bullish argument is based on fundamentals. Callaway currently has a market cap of $499.05 million but a book value of $632.46 million, making a price/book of 0.71. The company is priced less than the value of its assets; this is a value play.

That book value will probably decrease through Q3 and Q4, but historically it tends to fall by about $100M, meaning the company will still be undervalued. Callaway have been taking measures to reduces costs and expenses like most other companies, so I believe 2010 could see better profits than 2009 even if we see only a weak recovery.

Finally, I don't watch, play or follow golf, but I know the name Callaway. I like companies with a strong recognizable brand name, it is the sort of thing that is hard to acquire, and amazingly hard to loose (see Palm for example.) Callaway also own another brand I recognize, Top-Flite.

Bearish Argument

Callaway have already issued guidance that Q3 will not be stellar. Mr. Market has already reacted to this news, but bad earnings could drag the stock down through Q3 and Q4. If Callaway cannot claw back some of its pre-2009 sales, it is likely this stock will remain under $10 for a long time.

Summing up, I think Callaway is a somewhat risky value play. Either way you hack it, Callaway is currently undervalued, but that could change over the coming year if this economy continues to go badly. But, given the bonuses Wall St. is paying itself, the golfing class could be back in force for 2010.