private JiffleRuntime createRuntimeInstance(RuntimeModel model, Class<? extends JiffleRuntime> runtimeClass, boolean scriptInDocs) throws if (!isCompiled()) { throw new it.geosolutions.jaiext.jiffle.JiffleException("The script has not been compiled");
private JiffleRuntime createRuntimeInstance(RuntimeModel model, Class<? extends JiffleRuntime> runtimeClass, boolean scriptInDocs) throws if (!isCompiled()) { throw new it.geosolutions.jaiext.jiffle.JiffleException("The script has not been compiled");
@Test public void fileWithParamsConstructor() throws Exception { System.out.println(" Jiffle(scriptFile, imageParams)"); URL url = JiffleBasicTest.class.getResource("constant.jfl"); File file = new File(url.toURI()); imageParams.put("dest", Jiffle.ImageRole.DEST); jiffle = new Jiffle(file, imageParams); assertTrue(jiffle.isCompiled()); }
/** * Compiles a script read from a file and submits it for execution. * * @param scriptFile file containing the Jiffle script * @throws Exception on an error in the Jiffle compiler */ public void compileAndRun(File scriptFile) throws Exception { Map<String, Jiffle.ImageRole> imageParams = new HashMap<>(); imageParams.put("result", Jiffle.ImageRole.DEST); Jiffle jiffle = new Jiffle(scriptFile, imageParams); Map<String, RenderedImage> images = new HashMap<>(); images.put("result", ImageUtilities.createConstantImage(WIDTH, HEIGHT, Double.valueOf(0d))); if (jiffle.isCompiled()) { JiffleDirectRuntime runtime = jiffle.getRuntimeInstance(); final TiledImage destImg = ImageUtilities.createConstantImage(WIDTH, HEIGHT, 0d); runtime.setDestinationImage("result", destImg); runtime.evaluateAll(null); ImageFrame frame = new ImageFrame(destImg, "Jiffle image demo"); frame.setVisible(true); } }
@Test public void scriptWithParamsConstructor() throws Exception { System.out.println(" Jiffle(script, imageParams)"); String script = "dest = 42;"; imageParams.put("dest", Jiffle.ImageRole.DEST); jiffle = new Jiffle(script, imageParams); assertTrue(jiffle.isCompiled()); }
@Test public void compileValidScript() throws Exception { System.out.println(" compile valid script"); String script = "dest = 42;"; imageParams.put("dest", Jiffle.ImageRole.DEST); jiffle.setScript(script); jiffle.setImageParams(imageParams); jiffle.compile(); assertTrue(jiffle.isCompiled()); }
@Test public void compileInvalidScriptAndCheckStatus() throws Exception { System.out.println(" compile invalid script and check status"); // script with an uninitialized variable String script = "dest = x;"; imageParams.put("dest", Jiffle.ImageRole.DEST); jiffle.setScript(script); jiffle.setImageParams(imageParams); try { jiffle.compile(); } catch (JiffleParserException ignored) {} assertFalse(jiffle.isCompiled()); }
@Test public void blankInstance() { System.out.println(" creating an empty Jiffle object"); assertEquals("", jiffle.getScript()); assertTrue(jiffle.getImageParams().isEmpty()); assertFalse(jiffle.isCompiled()); }