Window Decoration - Non-Rectangluar Window Shapes(17:54, 17. Mar. 2010)

The last article explained some basics about Synthetica's window decoration. As you maybe know since Java 6u10 it's possible to use non-rectangular windows for your apps. Synthetica supports this feature in two different ways.

  • Per Pixel Transparency
  • Per Pixel Translucency

The advantage of pixel translucency is soft clipping - see zoomed screenshots below. However because of better paint performance, pixel transparency has been chosen for the Synthetica Black Eye theme/skin.

" "" "

 In case that you prefer soft-clipping you can enable per pixel translucency by setting the window opacity to false and by removing the predefined window shape.

UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaBlackEyeLookAndFeel");
UIManager.put("Synthetica.window.opaque", false);
UIManager.put("Synthetica.window.shape", "");

" "

Note: In Java6u18 the paint performance for translucent windows has been improved by fixing bug 6794764. However it's not recommended to activate translucency by default for each window. We recommend to let the user decide if the used machine has enough graphic power to enable translucency without affecting overall application performance.

Currently Synthetica BlackEye is the only theme/skin which implements a real non-rectangular window shape. Window decorations of older themes are also non-rectangular but not transparent. This means that some pixels in the window corners stay opaque by default. On bright backgrounds this is hard to recognize but on dark backgrounds the unwanted pixels appear. To activate transparency you can add the lines below to your app.

UIManager.setLookAndFeel(...);
UIManager.put("Synthetica.window.shape", "ROUND_RECT");
UIManager.put("Synthetica.window.arcW", 6);
UIManager.put("Synthetica.window.arcH", 6);

" "" "

Of course you can also customize a theme and add the shape value declaration to the related synth.xml file of the theme instead of passing to the UI-Manager - just like below.

<synth>
<!--
*******************************************************************************
Defaults
*******************************************************************************
-->
  <style id="default">
    <string id="winShape">ROUND_RECT</string>
    <defaultsProperty key="Synthetica.window.shape" type="idref" value="winShape"/>
    <defaultsProperty key="Synthetica.window.arcW" type="integer" value="6"/>
    <defaultsProperty key="Synthetica.window.arcH" type="integer" value="6"/>
...

What about MAC and Linux?

Currently per pixel transparency is not supported on MAC - luckily translucency is supported since Java 1.5. In case that per pixel transparency is enabled, Synthetica falls back to translucency. Compared to Windows (OS), translucency on MAC is more performant and affects overall paint performance for around 10%-15%.

On Linux per pixel translucency requires that a proper window manager is installed and because of Bug 6762511 Java 6u14 or above is required.

The upcoming article explains how to create a translucent dialog instance...CU JY