Demos for Chapter 3 Available

I just uploaded the source code for the demos of the third chapter of our book. The demos are currently available only on the CVS repository. We’ll try to offer zip archives by the time the book is published. In the meantime, you’ll have to deal with CVS, which will help you get new demos as we publish them.

4 Responses to “Demos for Chapter 3 Available”

  1. pollux says:

    With smartcvs I can’t access to it

  2. pollux says:

    It’s ok… I just forget to request the root before.. Sorry

  3. Brad says:

    Not that it takes away from the what the demo was trying to show but …

    In the CopyAreaPerformance demo if you resize the window with useCopyArea set to true it fails to draw the happy faces.

    On a resize the viewX and y are the same as prevVX and y so the clip gets called with what works out to be this …
    g.copyArea(0, 0, getWidth(), getHeight(), 0, 0);
    g.setClip(0, 0, getWidth(),0 );

    The two quick ways I fixed it was set f.resizeable(false); or by changing the if at the start of the paint to …

    if (useCopyArea && prevVX > -9999 && (prevVX != viewX || prevVY != prevVY))

    Like I said, it’s a demo so who cares but I just thought someone might want to know.
    Next time I’ll keep it to myself :)

  4. Chet Haase says:

    Thanks for the bug report. This demo, like many demos in the book, was intended to show a specific technique or piece of data. In this case, the intent was to show, in code, why both honoring the clip and using copyArea are useful for performance reasons. So I’m not shocked that it doesn’t handle random application occurrences because, well, I thought the app was sufficient dull and single-purposed enough that nobody would be looking for that extra app functionality.

    Having said that, it seems reasonable to add in the extra capabilities when I get around to it (lots of other things are higher on the queue, like finishing the book and posting the rest of the demos and book info on the various sites…)