Sunday, August 23, 2009

Aqua-like Controls - The Continious Capacity Indicator

Probably everyone that's used a Mac before has seen those things; the green/yellow/red bars with tick marks. They are described in the Apple Human Interface Guidelines under the section "Level Controls" as they are described by Apple as Following:
A capacity indicator, as its name suggests, provides graphical information about the current state of something
that has a finite capacity, such as storage space or battery charge. There are two styles of capacity indicator,
continuous and discrete. A continuous capacity indicator is a translucent track that is filled with a colored
bar that indicates the current value. For example, Figure 15-61 shows a continuous capacity indicator that
represents how much space has been used (and how much space is left) in the user’s mail account.
The Capacity Indicator was implemented as a BasicProgressBarUI with the paint() method overridden. The Paint method figures out the Percentage of the bar and determines the needed color, which will then be painted using 3 different ImageIcons. Before that, the whole length of the bar is filled with a gradient background. The 3 bounds of the colors can also be specified by setting Client Properties on the JProgressBar. As Usual, the Source is included with the JAR.

All four Images can be found here with the source file. The UI includes a main() method for preview or test purposes so you can see the UI. There are no tick marks yet; but sometime I'll revisit this topic and add the tick marks maybe into this UI or as a seperate JComponent.

Saturday, August 22, 2009

Aqua-like Controls for Java

This article features some JComponents that I've been working on recently.

[As of this writing(Aug. 22), it's safe to say that this is not the final draft; there will be tweaks in coming weeks -- maybe even entirely new Components will be added.]

Since I love Apple, Macs, iPods and more, I wanted to implement Aqua and Cocoa Components first that are sure nice and quite useful, but not avalaible through Client Properties in Java 6.0 for Mac. (Note: I do not have a Mac, just a tiny NetBook running Ubuntu 9.10 and Windoze XP, all of the Mac-related stuff was found out over the web, so no guarantees here...) First time I saw a Mac, I just fell in love with it and the Aqua UI. Since then, I've been working to make my Ubuntu look like a Mac and was quite successful. Also all of my Java apps use the QuAqua L&F, and some UI's are missing there, I write them for myself and share them here.


Some of my UI's are:
  1. The "Continious Capacity Meter"
More on the UI's can be found on the Blog Entries about the specific control. Feel free to eMail me with more control suggestions or some code, I appreciate it!