Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2011 Michael Bedward
  * 
  * This file is part of jai-tools.
  *
  * jai-tools is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation, either version 3 of the 
  * License, or (at your option) any later version.
 *
 * jai-tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with jai-tools.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package jaitools.demo.jiffle;
import  javax.media.jai.TiledImage;
Demonstrates how to retrieve and use a runtime object from a compiled Jiffle script.

Author(s):
Michael Bedward
Version:
$Id: DirectRuntimeDemo.java 1592 2011-03-29 11:01:25Z michael.bedward $
Since:
1.1
public class DirectRuntimeDemo extends JiffleDemoBase {

    
Run the demonstration. The optional arg can be either the path to a user-supplied script file or one of "chessboard", "interference", "ripple" or "squircle".

Parameters:
args (optional) the script to run
Throws:
Exception on an error in the Jiffle compiler
    public static void main(String[] argsthrows Exception {
        DirectRuntimeDemo demo = new DirectRuntimeDemo();
        File f = JiffleDemoHelper.getScriptFile(args.);
        demo.compileAndRun(f);
    }

    
Compiles a script read from a file and submits it for execution.

Parameters:
scriptFile file containing the Jiffle script
Throws:
Exception on an error in the Jiffle compiler
    public void compileAndRun(File scriptFilethrows Exception {
        Map<StringJiffle.ImageRoleimageParams = CollectionFactory.map();
        imageParams.put("result"..);
        Jiffle jiffle = new Jiffle(scriptFileimageParams);
        Map<StringRenderedImageimages = CollectionFactory.map();
        images.put("result",
                ImageUtils.createConstantImage(, Double.valueOf(0d)));
        if (jiffle.isCompiled()) {
            JiffleDirectRuntime runtime = jiffle.getRuntimeInstance();
            final TiledImage destImg = ImageUtils.createConstantImage(, 0d);
            runtime.setDestinationImage("result"destImg);
            
            runtime.evaluateAll(null);
            
            ImageFrame frame = new ImageFrame(destImg"Jiffle image demo");
            frame.setVisible(true);
        }
    }
New to GrepCode? Check out our FAQ X