WiCoCoを弄ってみた

http://www.wicoco.org/cgi-bin/wiki/wiki.cgi
Javaで非矩形ウィンドウを表示するライブラリです。ブツはここからダウンロードできます。
現実逃避的に遊んでみました。
とりあえず、Transparentableのテスト。コードは次のような感じ。

import java.awt.*;
import javax.swing.*;
import org.wicoco.feature.*;

public class TransparentableTest {
	public static void main( String[] args ) throws Exception {
		
		JFrame frame = new JFrame( "TransparentableTest" );
		frame.getContentPane().add( new JLabel("Hello World"), BorderLayout.CENTER );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setSize( 240, 160 );
		frame.setVisible( true );
		
		Transparentable feature = new Transparentable();
		feature.setAlpha( 0.7f );
		feature.setWindow( frame );
		feature.enable();
		
	}
}

ときどき、描画に失敗するのか、ウィンドウ内が真っ暗になることがある。画面を一度切り替えれば、きちんと描画されるっぽい。
お次は、Transparentableでのpiccoloフレームワークのテスト。

import org.wicoco.feature.*;
import edu.umd.cs.piccolo.nodes.*;
import edu.umd.cs.piccolox.*;

public class PFrameTest extends PFrame {
	public void initialize(){
		getCanvas().getLayer().addChild( new PText("Hello World") );
	}
	public static void main( String[] args ){
		PFrame frame = new PFrameTest();
		
		Transparentable feature = new Transparentable();
		feature.setAlpha( 0.7f );
		feature.setWindow( frame );
		feature.enable();
	}
}

とりあえず、動いた。だけど、動作が遅すぎる。体感的には一桁ほど遅くなっている。
さて、次は非矩形ウィンドウ。

import java.awt.*;
import javax.swing.*;
import org.wicoco.feature.*;

public class ShapeableTest {
	public static void main( String[] args ) {
		JFrame frame = new JFrame(){
			public void paint( Graphics g ){
				Rectangle r = getRootPane().getBounds();
				g.fillOval( r.x, r.y, r.width, r.height );
			}
		};
		frame.setSize( 160, 160 );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setVisible( true );
		
		Shapeable feature = new Shapeable();
		feature.setWindow( frame );
		feature.enable();
	}
}

ウィンドウリサイズを試して、強制的に描画内容を変更させたけど、それなりに頑張れるみたいです。てか、ドキュメントにはガラス板のようにするとしか書いてなくて、これの機能が何なのか分かるまで、結構時間を食った。
あと、どうも、コンポーネントを塗った塗らないで非矩形を作ってるっぽい。だから、piccoloを非矩形にすることはできなかった。残念。とりあえず、この二つを繋ぐには、PCanvasあたりを作り直せばよいのかな?
あと、ポップアップメニュー(普通のメニューは試してない)の挙動が怪しかったり。