Tabnine Logo
Jiffle.compile
Code IndexAdd Tabnine to your IDE (free)

How to use
compile
method
in
it.geosolutions.jaiext.jiffle.Jiffle

Best Java code snippets using it.geosolutions.jaiext.jiffle.Jiffle.compile (Showing top 20 results out of 315)

origin: geosolutions-it/jai-ext

public void getSourceFromJiffleObject(String script) throws JiffleException {
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  
  // You have to compile the script before getting the runtime
  // source otherwise an Exception will be thrown
  jiffle.compile();
  
  // Get the Java source. The boolean argument specifies that we
  // want the input script copied into the class javadocs
  String runtimeSource = jiffle.getRuntimeSource(true);
}
// docs end getSourceFromJiffleObject
origin: geosolutions-it/jai-ext

@Test(expected=JiffleException.class)
public void compileWithNoScript() throws Exception {
  System.out.println("   compile with no script set");
  
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  jiffle.setImageParams(imageParams);
  jiffle.compile();
}
origin: geosolutions-it/jai-ext

/**
 * Creates a new instance by compiling the script read from {@code scriptFile}. 
 * Using this constructor is equivalent to:
 * <pre><code>
 * Jiffle jiffle = new Jiffle();
 * jiffle.setScript(scriptFile);
 * jiffle.setImageParams(params);
 * jiffle.compile();
 * </code></pre>
 * 
 * @param scriptFile file containing the Jiffle script
 * 
 * @param params defines the names and roles of image variables
 *        referred to in the script.
 * 
 * @throws JiffleException on compilation errors
 */
public Jiffle(File scriptFile, Map<String, Jiffle.ImageRole> params)
    throws it.geosolutions.jaiext.jiffle.JiffleException {
  init();
  setScript(scriptFile);
  setImageParams(params);
  compile();
}

origin: it.geosolutions.jaiext.jiffle/jt-jiffle-language

/**
 * Creates a new instance by compiling the provided script. Using this
 * constructor is equivalent to:
 * <pre><code>
 * Jiffle jiffle = new Jiffle();
 * jiffle.setScript(script);
 * jiffle.setImageParams(params);
 * jiffle.compile();
 * </code></pre>
 * 
 * @param script Jiffle source code to compile
 * 
 * @param params defines the names and roles of image variables
 *        referred to in the script.
 * @throws JiffleException on compilation errors
 * 
 */
public Jiffle(String script, Map<String, Jiffle.ImageRole> params)
    throws it.geosolutions.jaiext.jiffle.JiffleException {
  init();
  setScript(script);
  setImageParams(params);
  compile();
}
origin: it.geosolutions.jaiext.jiffle/jt-jiffle-language

/**
 * Creates a new instance by compiling the script read from {@code scriptFile}. 
 * Using this constructor is equivalent to:
 * <pre><code>
 * Jiffle jiffle = new Jiffle();
 * jiffle.setScript(scriptFile);
 * jiffle.setImageParams(params);
 * jiffle.compile();
 * </code></pre>
 * 
 * @param scriptFile file containing the Jiffle script
 * 
 * @param params defines the names and roles of image variables
 *        referred to in the script.
 * 
 * @throws JiffleException on compilation errors
 */
public Jiffle(File scriptFile, Map<String, Jiffle.ImageRole> params)
    throws it.geosolutions.jaiext.jiffle.JiffleException {
  init();
  setScript(scriptFile);
  setImageParams(params);
  compile();
}

origin: geosolutions-it/jai-ext

private void setupSingleDestScript() throws JiffleException {
  String script = "dest = 42;";
  jiffle.setScript(script);
  
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  jiffle.setImageParams(imageParams);
  jiffle.compile();
}

origin: geosolutions-it/jai-ext

@Test(expected=JiffleException.class)
public void compileScriptWithoutImageParams() throws Exception {
  System.out.println("   compile script with missing image params");
  
  String script = "dest = 42;";
  
  jiffle.setScript(script);
  jiffle.compile();
}

origin: geosolutions-it/jai-ext

  protected void compileScript(String script) throws JiffleException {
    Jiffle jiffle = new Jiffle();
    jiffle.setScript(script);
    jiffle.compile();
  }
}
origin: geosolutions-it/jai-ext

@Test(expected=JiffleParserException.class)
public void compileInvalidScriptThrowsException() throws Exception {
  System.out.println("   compile invalid script and get exception");
  
  // script with an uninitialized variable
  String script = "dest = x;";
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  
  jiffle.setScript(script);
  jiffle.setImageParams(imageParams);
  jiffle.compile();
}
origin: geosolutions-it/jai-ext

private Jiffle getCompiledJiffle(String script) throws JiffleException {
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
  
  return jiffle;
}

origin: geosolutions-it/jai-ext

@Test(expected=JiffleException.class)
public void emptyImagesBlock() throws Exception {
  System.out.println("   empty images block and no parameters causes exception");
  
  String script = "images { } dest = 42;" ;
  
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
}

origin: geosolutions-it/jai-ext

private JiffleDirectRuntime getRuntime(String script) throws Exception {
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  
  Map<String, Jiffle.ImageRole> params = new HashMap<>();
  params.put("dest", Jiffle.ImageRole.DEST);
  jiffle.setImageParams(params);
  jiffle.compile();
  
  return jiffle.getRuntimeInstance();
}

origin: geosolutions-it/jai-ext

@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());
}
origin: geosolutions-it/jai-ext

private JiffleDirectRuntime getRuntimeWithImagesBlock() throws Exception {
  String script = 
       "images {"
      + "  src1=read; src2=read; src3=read;"
      + "  dest1=write; dest2=write; dest3=write;"
      + "}"
      + "dest1 = src1; dest2 = src2; dest3 = src3;" ;
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
  return jiffle.getRuntimeInstance();
}

origin: geosolutions-it/jai-ext

@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());
}

origin: geosolutions-it/jai-ext

  private JiffleDirectRuntime getRuntime(String script) throws Exception {
    Jiffle jiffle = new Jiffle();
    jiffle.setScript(script);
    jiffle.compile();
    return jiffle.getRuntimeInstance();
  }
}
origin: geosolutions-it/jai-ext

@Test
public void getImageScopeVarNames() throws Exception {
  String script = 
       "images { dest=write; } "
      + "init { foo = 1; bar = 2; foz = 3; baz = 4; } "
      + "dest = 42;" ;
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
  JiffleDirectRuntime runtime = jiffle.getRuntimeInstance();
  
  String[] names = runtime.getVarNames();
  
  List<String> expected = new ArrayList<>();
  expected.add("foo");
  expected.add("bar");
  expected.add("foz");
  expected.add("baz");
  
  assertEquals(expected.size(), names.length);
  for (int i = 0; i < names.length; i++) {
    assertTrue(expected.contains(names[i]));
    expected.remove(names[i]);
  }
}

origin: geosolutions-it/jai-ext

private JiffleDirectRuntime getRuntime(String script) throws Exception {
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  
  Map<String, Jiffle.ImageRole> imageParams = new HashMap<>();
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  
  jiffle.setImageParams(imageParams);
  jiffle.compile();
  JiffleDirectRuntime runtime = jiffle.getRuntimeInstance();
  
  WritableRenderedImage destImg = ImageUtilities.createConstantImage(WIDTH, WIDTH, 0d);
  runtime.setDestinationImage("dest", destImg);
  
  return runtime;
}

origin: geosolutions-it/jai-ext

@Test
public void noDestImage() throws Exception {
  System.out.println("   destination-less script with images block");
  String script = String.format(
       "images { inimage = read; } \n"
      + "init { n = 0; } \n"
      + "n += inimage >= %d;",
      NUM_PIXELS - 5);
  
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
  
  directRuntimeInstance = jiffle.getRuntimeInstance();
  directRuntimeInstance.setSourceImage("inimage", createSequenceImage());
  directRuntimeInstance.evaluateAll(null);
  
  Double var = directRuntimeInstance.getVar("n");
  assertNotNull(var);
  assertEquals(5, var.intValue());
}

origin: geosolutions-it/jai-ext

private void assertScriptResult(String script, 
    Evaluator e, String srcVarName, String destVarName) throws Exception {
  
  RenderedImage srcImg = null;
  WritableRenderedImage destImg = null;
  
  Jiffle jiffle = new Jiffle();
  jiffle.setScript(script);
  jiffle.compile();
  
  directRuntimeInstance = (JiffleDirectRuntime) jiffle.getRuntimeInstance();
  
  if (srcVarName != null && srcVarName.length() > 0) {
    srcImg = createSequenceImage();
    directRuntimeInstance.setSourceImage(srcVarName, srcImg);
  }
  
  if (destVarName != null && destVarName.length() > 0) {
    destImg = ImageUtilities.createConstantImage(IMG_WIDTH, IMG_WIDTH, 0d);
    directRuntimeInstance.setDestinationImage(destVarName, destImg);
  }
  
  directRuntimeInstance.evaluateAll(null);
  assertImage(srcImg, destImg, e);
}
it.geosolutions.jaiext.jiffleJifflecompile

Javadoc

Compiles the script into Java source for the runtime class.

Popular methods of Jiffle

  • <init>
    Creates a new instance by compiling the provided script. Using this constructor is equivalent to: J
  • getRuntimeInstance
    Gets the runtime object for this script. The runtime object is an instance of JiffleRuntime. By defa
  • setImageParams
    Sets the image parameters. These define which variables in the script refer to images and their type
  • setScript
    Sets the script. Calling this method will clear any previous script and runtime objects.
  • isCompiled
    Tests whether the script has been compiled successfully.
  • getReadPositions
    A utility method returning the source positions used in a given script
  • getRuntimeSource
    Gets a copy of the Java source for the runtime class. The script must have been compiled before call
  • clearCompiledObjects
    Clears all compiler and runtime objects.
  • createRuntimeInstance
  • createRuntimeSource
  • getImageParams
    Gets the current image parameters. The parameters are returned as an unmodifiable map.
  • getName
    Gets the name assigned to this object. This will either be the default name or one assigned by the c
  • getImageParams,
  • getName,
  • getRuntimeBaseClass,
  • getScript,
  • getScriptImageParams,
  • init,
  • parseScript,
  • reportMessages,
  • setName

Popular in Java

  • Parsing JSON documents to java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Collectors (java.util.stream)
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now