« August 2007 | Main | October 2007 »

September 27, 2007

Memory leak update

The memory leak seems to affect Windows XP as well, so I can only assume that this is a problem on all platforms. You are only affected if you run under -Dteppefall.chrome=false and you can probably stop the problem by setting -Dteppefall.cursor-monitor=false.

Example:

java
-Dteppefall.cursor-monitor=false
-Dteppefall.chrome=false
-Dteppefall.override=true
-Dswing.defaultlaf=com.teppefall.ds.look.TitaniumLAF
-jar darkstarlayout.jar

September 26, 2007

Memory leak on Vista

There seems to be a Windows Vista specific memory leak in the latest build. Applications will stop working correctly after 24 hours or so. I am working on it.

On a side note.. My Apple Powerbook is spewing out thousands of error messages. “bootp_session_transmit: bpf_write(en2) failed: No buffer space available (55)” plus errors from launchd, Mail and various processes. Who knows what is wrong. Maybe swap is screwed up.. if I have swap that is :) Rebooting the machine every day now (how unnatural). Waiting for Leopard.

The latest ATI graphics driver hangs Windows XP and Linux KDE now complains that it can't talk to klauncher. And to top all this off. Firefox uses 95% CPU when idling in multiple Web 2.0 websites.

I might have found the cause of global warming. Software bugs.

September 20, 2007

Using Quicktime to display CMYK images

Darkstar 2D's CompositeQuickTime.createImageFromQT should work on OS X and you end up with a apple.awt.OSXImage. Fun fact: searching for apple.awt.OSXImage on Google gives me 10 hits.
CMYK test image - 592 kb (in RGB below)

cmyk_test.jpg


importPackage(Packages.java.io)
importPackage(Packages.java.awt)
importPackage(Packages.java.awt.image)
importPackage(Packages.java.awt.geom)
importPackage(Packages.javax.imageio)
importPackage(Packages.com.teppefall.ds.render2d.compositing)
importPackage(Packages.quicktime)
importPackage(Packages.quicktime.io)

function loadImage(ref, cmyk) {
	var bimg;
	try {
		var file = new File(System.getProperty("user.home") +File.separator+"Desktop"+File.separator+ ref)
		if(!cmyk)
		bimg = ImageIO.read(file);
		else
		bimg = CompositeQuickTime.createImageFromQT(new QTFile(file))
		context.info(bimg)
	}
	catch(e) {
		e.printStackTrace();
	}
	return bimg;
}

var sprite
var r = {
	destroy: function() {
		try {
			QTSession.close()
		}
		catch(e) {}
	},
	initialize: function(ds, fg, bg) {
		try {
			QTSession.open()
		}
		catch(e) {}
		sprite = loadImage("cmyk_test2.jpg", true)
	},
	render : function(g, size) {
		g.drawImage(
			sprite,
			0,
			0,
			sprite.getWidth(null),
			sprite.getHeight(null),
			null
		)
	}
}

context.getDarkstar().setRenderer(new D2DAdapter(r))

September 17, 2007

Color masking and sprite tiles

Wow.. written by a high school senior. The mask and sprite code is really cool. So I made a Javascript “mashup” in Darkstar FX.

One thing that is strange. My color picker (Colorspace) reports that the green in the Mario tile is #008500 in Firefox but #007300 when I paint the same image in Java 2D or open the file in Photoshop.

mario2.png

mario_fx.png

mask.js
importPackage(Packages.java.io)
importPackage(Packages.java.awt)
importPackage(Packages.java.awt.image)
importPackage(Packages.java.awt.geom)
importPackage(Packages.javax.imageio)

function loadImage(ref) {
    var bimg;
    try {
        // read images from desktop folder
        bimg = ImageIO.read(new File(System.getProperty("user.home") +File.separator+"Desktop"+File.separator+ ref));
        //context.info(bimg)
    }
    catch(e) {
        e.printStackTrace();
    }
    return bimg;
   }
function makeColorTransparent(ref, color) { 
    image = loadImage(ref); 
    dimg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB); 
    g = dimg.createGraphics(); 
    g.setComposite(AlphaComposite.Src); 
    g.drawImage(image, null, 0, 0); 
    g.dispose(); 
    for(i = 0; i < dimg.getHeight(); i++) { 
        for(j = 0; j < dimg.getWidth(); j++) { 
            if(dimg.getRGB(j, i) == color.getRGB()) { 
                dimg.setRGB(j, i, 0x8F1C1C); 
            }
        }
    }
    return dimg;
}

function splitImage(img, cols, rows) {
   var w = img.getWidth()/cols;
   var h = img.getHeight()/rows;
   var num = 0;
   imgs = new Array();
   for(y = 0; y < rows; y++) {
       for(x = 0; x < cols; x++) {
           imgs[num] = new BufferedImage(w, h, img.getType());
           g = imgs[num].createGraphics();
           g.drawImage(img, 0, 0, w, h, w*x, h*y, w*x+w, h*y+h, null);
           g.dispose();
           num++;
       }
   }
   return imgs;
}
var tiles
var r = {
    initialize: function(ds, fg, bg) {
        var sprite = makeColorTransparent("mario2.png", new Color(0x007300)) // firefox and java2d have different color values?
        tiles = splitImage(sprite, 6, 4)
    },
   render : function(g, size) {
       var xoffset = 0, yoffset = 0
       for(i in tiles) {
           if(i % 8 == 0) {
           if(i != 0)
           yoffset += 1
           xoffset = 0
           //context.info(i + ", "+yoffset)
        }
        g.drawImage(
            tiles[i],
            tiles[i].getWidth()*xoffset,
            tiles[i].getHeight()*yoffset,
            tiles[i].getWidth(),
            tiles[i].getHeight(),
            null
        )
        xoffset++
        //g.drawString("test", 10*i, 20)
        }
    }
}
context.getDarkstar().setRenderer(new D2DAdapter(r))

September 11, 2007

Colorspace 1.5, Layout 3.2, FX 3.2 and Darkstar 20070905

New features:

Colorspace supports the scroll wheel. One NPE fixed. Both fixes by Luan. Decimal values are written to standard output when the decimal check box is selected. 200-500ms shaved off About dialog launch. Colorspace no longer runs under a security policy since it causes to many problems on OS X.

Darkstar applications now have focus aware menus under Titanium LAF. A feature from the stone age. Just use com.teppefall.ds.Application in the same way as before. This means that the foreground color of your menu goes dark (under Titanium) when the JFrame loses focus.

The DSR executable supports the -Xchrome parameter. This turns on the native chrome and is the same as -Dteppefall.chrome=true.

DSR can launch multiple applications at the same time. Just add a comma separator between class names. A word of warning though. Running threads might block the shutdown process, so closing down resources on application exit is paramount. Note that DSR today has a very high probability of not closing down properly.

Other issues:

If Darkstar FX is unable to create HTML and thumbnails you should try the -Xinsecure parameter. FX and Layout run under security managers and can fail if the policy file is not perfect. Strange problems when running under DSR might also be a result of the security policy.

Website
http://www.teppefall.com
Download
http://us.teppefall.com/download.jsp
Alternative download
http://static.teppefall.com/data/list
Miglayout form example
http://labs.teppefall.com/2007/09/miglayout_forms.html
Screenshots
http://labs.teppefall.com/2007/08/titanium_on_vista.html

September 08, 2007

MiGLayout forms

miglayout.jfc
<layout class="net.miginfocom.swing.MigLayout">
	<component class="javax.swing.JLabel" text="First Name"/>
	<component class="javax.swing.JTextField" id="firstname">
		<property name="columns" value="15" type="int"/>
	</component>
	<component class="javax.swing.JLabel" text="Surname" constraint="gap unrelated"/>
	<component class="javax.swing.JTextField" id="surname" constraint="wrap">
		<property name="columns" value="15" type="int"/>
	</component>
	<component class="javax.swing.JLabel" text="Address"/>
	<component class="javax.swing.JTextField" id="address" constraint="span, growx"/>
	<component class="javax.swing.JButton" id="submit" text="Submit"/>
</layout>

miglayout_advanced.jfc
<layout class="net.miginfocom.swing.MigLayout">
	<component class="javax.swing.JLabel" text="General" constraint="split, span, gaptop 10"/>
	<component class="javax.swing.JSeparator" constraint="growx, wrap, gaptop 10"/>
	<component class="javax.swing.JLabel" text="Company" constraint="gap 10"/>
	<component class="javax.swing.JTextField" constraint="span, growx"/>
	<component class="javax.swing.JLabel" text="Contact" constraint="gap 10"/>
	<component class="javax.swing.JTextField" constraint="span, growx, wrap"/>
	<component class="javax.swing.JLabel" text="Propeller" constraint="split, span, gaptop 10"/>
	<component class="javax.swing.JSeparator" constraint="growx, wrap, gaptop 10"/>
	<component class="javax.swing.JLabel" text="PTI/kW" constraint="gap 10"/>
	<component class="javax.swing.JTextField">
		<property name="columns" value="10" type="int"/>
	</component>
	<component class="javax.swing.JLabel" text="Power/kW" constraint="gap 10"/>
	<component class="javax.swing.JTextField" constraint="wrap">
		<property name="columns" value="10" type="int"/>
	</component>
	<component class="javax.swing.JLabel" text="R/mm" constraint="gap 10"/>
	<component class="javax.swing.JTextField">
		<property name="columns" value="10" type="int"/>
	</component>
	<component class="javax.swing.JLabel" text="D/mm" constraint="gap 10"/>
	<component class="javax.swing.JTextField">
		<property name="columns" value="10" type="int"/>
	</component>
</layout>

MiG Layout

September 02, 2007

Who invented Facebook

who-invented-facebook.jpg
Original - De Berejstes Klub
http://www.nytimes.com/2007/09/01/technology/01facebook.html?_r=1&oref=slogin
http://www.techcrunch.com/2007/08/31/like-sands-through-the-hour-glass-another-person-is-claiming-to-have-founded-facebook/
http://mashable.com/2007/09/01/i-invented-facebook/
http://news.com.com/Who+founded+Facebook+A+new+claim+emerges/2100-1038_3-6205758.html

Next generation Teppefall software

Coming soon to Teppefall Link.