|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SOA World Conference
Virtualization Conference $200 Savings Expire May 16, 2008... – Register Today!
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Advanced Java
Using Color Technology in Java
Heighten the visual impact of your application
By: John Chamberlain
Digg This!
Brighten up your dreary application by learning how to use Java to create and manage color. Using a color picker makes it easy to define exact colors with alpha transparency. For a developer there are two situations in which color comes up: when you are creating the colors for your interface and when a user can define colors or manipulate images as part of your application's functionality. To work with color effectively, you should know the basics of color management and color definition. Color Management You can do this translation using the Java 2D API's ColorSpace and ICC_Profile classes. First load the profiles for the two different environments. For the display you can use the built-in RGB profile that is the default. For a device like a scanner or printer, you'll usually need to load a color profile from a file from the manufacturer. For each of the profiles generate a ColorSpace object. ColorSpace has two methods: toCIEXYZ and fromCIEXYZ. The CIEXYZ color space is sort of a master color model that serves as the medium for translation. You can translate any color or image from one color space to another by translating it first to CIEXYZ, then to the target color space. If you are programming for display only, that's about all you need to know about color management, but if you have color input/output in your application, you may want to learn more (see the resources section at the end of the article). Picking Color
![]() An important consideration for color picking is that you should stick to the HSB (Hue, Saturation, Brightness) system rather than the monitor-oriented RGB encoding. It's much easier to define colors by starting with a hue and then modifying its brightness (shading) and saturation (tinting) than by trying to do an RGB mix. Table 1 shows the basic HSB combinations.
![]() GUI Color Schemes Even without using a swatch book there are some basic rules you can apply when creating a scheme. In general, it's best to use a two- or three-color scheme plus highlights. In a two-color scheme, it's a good idea to pick two complementary colors. In a three-color scheme start off with a triad (three hues spaced equally). To create highlights decrease the saturation of your base colors. Other things to be aware of are the distance effect and contrast. When you look from afar, darker colors such as blue fade to black faster; red and blue are inherently darker than yellow and green. Maximizing contrast is a good policy but having black on white can be harsh. Using a pale yellow background may provide better readability. If you need large text to be read from a distance, for example, in a kiosk display, add a red one-pixel outline to the letters to increase contrast. Resources
LATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING JAVA NEWS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||