|
|
||
Chet Haase's BlogJanuary 2007 ArchivesSunday MathPosted by chet on January 28, 2007 at 03:13 PM | Permalink | Comments (8)I just want to point out that these equations: f(x) = x >> 1, for all x f(y) = !(y >> 1), for all yare just another example of the halves and halve-nots. But I should add that I'm divided; this seems rather shifty and I don't want to subtract from the end product. Filthy Rich Clients: A Subtle TeaserPosted by chet on January 24, 2007 at 09:21 PM | Permalink | Comments (24)Romain Guy and I are nearing the end of a book on Swing, Java 2D, animation, and how to write better, and cooler, Swing applications. It's called Filthy Rich Clients. I know we haven't mentioned it before, except for here, and here, and here, and here, and then here. And there's always here, and here, and then here. We've obviously been pretty quiet about it. Now the book is actually nearing completion; we have just a tad more writing to go (right, Romain?), some more editing, then some more editing, and reviews, and then editing, and some more reviews, and then we'll probably want to edit it some more. And theoretically, all of this gets done in time to publish for JavaOne 2007 (second week of May). So I thought I'd take a quick break from editing Chapter 12 (a fun chapter about a really cool utility ... which I have to completely rewrite in the next 2 days) and post the outline, now that we're fairly sure what it'll be: Part I: Graphics and GUI Fundametals
Part II: Animation
Part III: Effects
At least, that's our take on it before the reviewers rip it apart. It should be a fun, and hopefully quite useful, book. The first section, Part I, is fairly huge and is intended to be educational to a broad audience about how Swing and Java 2D do what they do and how you can take advantage of various features for richer applications. So while the whole book is oriented toward making-Swing-apps-cooler, there is a lot of material in there that is also intended to simply help Swing programmers understand Swing better. Lots of code. Lots of screenshots. Occasional math equations just to act a little crazy. Now, back to my dark little editing corner.... Font Hints for Custom ComponentsPosted by chet on January 10, 2007 at 02:40 PM | Permalink | Comments (12)I just got finished writing a small section on text-anti-aliasing for Romain's and my Filthy Rich Clients book (did you notice how smoothly I slid that teaser into the discussion?). It seemed like such a bite-sized and useful bit of info that I thought it would go well here, so here it is: Setting text anti-aliasing hints can be confusing, especially with new RenderingHints added in Java SE 6 for LCD text. What text quality do you want? What is appropriate for the application? What is appropriate for the platform? What does your user prefer? A better solution than setting hints directly in most situations is for your application to figure out what the user’s native desktop settings are for fonts and to do something similar for their Java application. This, in fact, is what Swing does in some of its look and feels (Metal, Windows, and GTK in particular); it queries desktop properties for how text is rendered by native applications and sets RenderingHints appropriately. Custom components which perform their own text operations do not get this Swing
behavior; the Graphics object you get in I wrote a simple app that shows how to do this, by rendering one string with the
default Graphics object in
First, note that the image may look a lot better on my display than it does here for you; LCD text rendering is optimized to look good on the runtime display, not whatever display you may be using to view this screenshot. But the important thing to note here is not how good it looks here, but that the two strings are different because the second string was drawn after setting the appropriate desktop property hints on the Graphics object. Here is the simple code that produced this output:
g2d.drawString("Unhinted string", 10, 20);
if (desktopHints == null) {
Toolkit tk = Toolkit.getDefaultToolkit();
desktopHints = (Map) (tk.getDesktopProperty("awt.font.desktophints"));
}
if (desktopHints != null) {
g2d.addRenderingHints(desktopHints);
}
g2d.drawString("Desktop-hinted string", 10, 40);
Here, we first check to see whether desktopHints is null; this keeps us from
re-creating it every time through For more information on desktop properties, check out the article “AWT Desktop Properties” in the JavaDocs (the document name is DesktopProperties.html, but it might be easier to find it by clicking on the link in the JavaDoc for Toolkit.getDesktopProperty). Thanks to Phil Race for helpful pointers on this one TaggedPosted by chet on January 08, 2007 at 03:40 PM | Permalink | Comments (5)I got tagged - does that mean I'm IT? I've been waiting my whole life for this... I only found out what blog tagging was last Friday, so imagine my surprise when I realized that Romain tagged me a week ago. Now that I know what tagging is, I'm not sure I'm happy about it. I agree with Chris that it's like a blog version of chain mail, which I've made a point of not propagating my whole life (which, come to think of it, could explain my luck). But, like Chris, I also cave to pressure. And when the pressure is getting me to talk more about Chet, well, I don't have to be pushed off that cliff. And heck, maybe tagging is a good thing. The web is far too useful with so little junk content out there, right? First, some clarification. It's a bit tough to come up with five things that people don't generally know about me already. It's not like I'm shy. So I'll reinterpret this goal and aim my blog at this subject instead: Five things about me that aren't patently obvious to people meeting me for the first time
Well, I caved completely and came up with my five things. I feel so soiled. But the chain mail stops here; no more derefs to others. Maybe I have no friends. Maybe I have friends, but can't afford to lose any. Maybe I'm hypocritically sticking to my principles after completely giving in and writing this posting. But for whatever reason, you'll have to search elsewhere to find more victims. | ||
|
|