Thursday, November 06, 2008

Shaped Windows in Java 1.6.0u10

Most of the demo I've found on this topics seems to show windows with simple geometries, thought I would show a cooler window shape.


And here is the code


import com.sun.awt.AWTUtilities;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
import java.util.Scanner;

public class Test extends JFrame {
public Test() {
setUndecorated(true);
ClassLoader loader = getClass().getClassLoader();
if ( loader == null )
System.out.printf("loader == null%n");
JLabel imagel = new JLabel(new ImageIcon(loader.getResource("tux.png")));
setLocation(200,200);
setSize(220,260);
add(imagel);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

public static void main(String[] args) {
Test window = new Test();
GeneralPath path = createTuxPath();
AffineTransform at = AffineTransform.getScaleInstance(220.0/334, 260.0/393);
AWTUtilities.setWindowShape(window, path.createTransformedShape(at));
}
private static GeneralPath createTuxPath() {
final String tuxpath="M 177,0 C 168,0 158,2 148,7 C 120,21 124,53 128,115 C 129,132 113,143 99,165 C 85,187 84,204 73,223 C 63,240 65,239 68,254 C 68,254 67,255 67,255 C 63,259 58,268 52,273 C 46,278 29,277 25,283 C 21,288 25,296 25,311 C 25,317 24,322 23,326 C 22,331 22,334 24,337 C 27,344 33,345 67,352 C 85,356 102,366 113,367 C 125,367 127,364 134,357 C 135,357 136,356 137,355 C 138,355 138,355 139,355 C 154,348 149,350 173,349 C 197,347 204,346 226,352 C 227,357 229,360 231,361 C 234,364 239,366 250,367 C 260,367 267,364 274,357 C 279,353 283,348 297,339 C 309,331 325,323 329,320 C 330,318 333,316 333,310 C 334,305 329,303 326,302 C 322,299 312,291 306,282 C 303,277 308,269 303,262 C 302,261 301,260 300,260 C 302,255 303,250 304,246 C 310,224 293,186 276,162 C 260,139 246,125 240,95 C 233,66 241,74 235,49 C 233,36 227,26 222,19 C 216,12 208,8 205,6 C 199,3 190,-0 177,0 z";
GeneralPath gp = new GeneralPath();
Scanner s = new Scanner(tuxpath);
s.useDelimiter("[ ,]");
String op = "A";
do {
switch (op.charAt(0)) {
case 'M':
gp.moveTo(s.nextFloat(),s.nextFloat());
break;
case 'C':
gp.curveTo(s.nextFloat(),s.nextFloat(),s.nextFloat(),s.nextFloat(),s.nextFloat(),s.nextFloat());
break;
case 'L':
gp.lineTo(s.nextFloat(),s.nextFloat());
break;
case 'Q': // && other operation??
System.out.printf("I don't know what to do with '%s'. Need to read SVG spec. first. Bye.%n", op);
System.exit(0);
}
op = s.next();
} while ( op.charAt(0) != 'z' );
s.close();

return gp;
}
}


Here is the image I used.

Monday, October 20, 2008

Makehuman Installation commands for Hardy (Ubuntu 8.04)

sudo apt-get install freeglut3-dev xorg-dev libpng12-dev
tar xzf animorph-0.3.tar.gz
cd animorph-0.3/
./configure
make
sudo make install
cd ..
tar xzf mhgui-0.2.tar.gz
cd mhgui-0.2/
./configure
make
sudo make install
cd ..
tar xzf makehuman-0.9.1-rc1a.tar.gz
cd makehuman-0.9.1-rc1a/
./configure
make
sudo make install
sudo ldconfig

### aqsis
sudo apt-get install libopenexr2ldbl libfltk1.1
wget http://zerstorer.free.fr/makehuman/aqsis-libsc2a_1.2.0-2_i386.deb
sudo dpkg -i aqsis-libsc2a_1.2.0-2_i386.deb
sudo apt-get install aqsis

Sunday, October 19, 2008

Most annoying Java bug in Linux is gone in jdk1.7.0-ea :) .
Download: http://download.java.net/jdk7/binaries/
NOTE: the bug lives in jdk1.6.0_10-rc2.
Bug Symptom:
1) launching a Java windows application,e.g. netbeans6.1, from terminal, the following message display:
(:13266): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)

(:13266): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

2) unable to type /edit (there is a work around.. but ahhhh...)

Bug Track: http://bugs.sun.com/view_bug.do?bug_id=6624717