Print

Print


It's theoretically possible but would require some hacking.

I'd start by running headless.
	http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/

... then you'd need a way of updating the Display2D.  The easiest way  
to do it is to fire up the Console, probably by just calling  
pressStart().

	SwingUtilities.invokeLater(new Runnable() { public void run() {
		console.pressStart();
		} });

... last you'll need a way to take a picture at some point.  What I  
would do is steal some code from Display2D.takeSnapshot().  Let's say  
you want to generate a PNG.  I'd do something like this:

	SwingUtilities.invokeAndWait(new Runnable() { public void run() {
		try {
			Graphics g = display.insideDisplay.getGraphics();
			BufferedImage img = display.insideDisplay.paint(g, true, false);
			g.dispose();
			OutputStream stream = new BufferedOutputStream(
				new FileOutputStream(new File("/tmp/output.png")));
			PngEncoder encode = new PngEncoder(img, false,  
PngEncoder.FILTER.NONE, 9);
			stream.write(encode.pngEncode());
			stream.close();
		    } catch (Exception e) { /* oh well */ }
		} });

This is just off the top of my head.  No doubt there are other issues  
still.

Sean

On May 3, 2010, at 12:33 PM, Mark Coletti wrote:

> It is possible to save a snapshot of a simulation from the GUI.   
> However, I would like to do the same from a _headless_ MASON  
> configuration.  That is, I want to run MASON from the command line  
> and have it emit PNG snapshots of the simulation; this will _not_ be  
> from within a GUI.  Is there a convenient way of doing this?
>
> Cheers,
>
> Mark Coletti
> [log in to unmask]
>