Tabnine Logo
Jiffle.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
it.geosolutions.jaiext.jiffle.Jiffle
constructor

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

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

/**
 * Gets the Java run-time class code generated from the compiled script.
 *
 * @return the run-time source code
 *
 * @throws JiffleException if the script has not been set yet or if
 *         compilation errors occur
 */
public String getRuntimeSource() throws JiffleException {
  if (script == null) {
    throw new IllegalStateException("Jiffle script has not been set yet");
  }
  
  Jiffle jiffle = new Jiffle(script, imageParams);
  return jiffle.getRuntimeSource(Jiffle.RuntimeModel.DIRECT, true);
}
origin: geosolutions-it/jai-ext

/**
 * Gets the Java run-time class code generated from the compiled script.
 *
 * @return the run-time source code
 *
 * @throws JiffleException if the script has not been set yet or if
 *         compilation errors occur
 */
public String getRuntimeSource() throws JiffleException {
  if (script == null) {
    throw new IllegalStateException("Jiffle script has not been set yet");
  }
  
  Jiffle jiffle = new Jiffle(script, imageParams);
  return jiffle.getRuntimeSource(Jiffle.RuntimeModel.DIRECT, true);
}
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 passingEmptyScriptToConstructor() throws Exception {
  System.out.println("   Jiffle(script, imageParams) with empty script");
  
  String script = "";
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  jiffle = new Jiffle(script, imageParams);
}

origin: geosolutions-it/jai-ext

@Before
public void setup() {
  jiffle = new Jiffle();
  imageParams = new HashMap<>();
}

origin: geosolutions-it/jai-ext

private JiffleDirectRuntime getRuntimeWithImageParams() throws Exception {
  String script = "dest1 = src1; dest2 = src2; dest3 = src3;" ;
  Map<String, Jiffle.ImageRole> imageParams = new HashMap<>();
  imageParams.put("dest1", Jiffle.ImageRole.DEST);
  imageParams.put("dest2", Jiffle.ImageRole.DEST);
  imageParams.put("dest3", Jiffle.ImageRole.DEST);
  imageParams.put("src1", Jiffle.ImageRole.SOURCE);
  imageParams.put("src2", Jiffle.ImageRole.SOURCE);
  imageParams.put("src3", Jiffle.ImageRole.SOURCE);
  Jiffle jiffle = new Jiffle(script, imageParams);
  return jiffle.getRuntimeInstance();
}

origin: geosolutions-it/jai-ext

@Before
public void setup() {
  jiffle = new Jiffle();
  imageParams = new HashMap<>();
}

origin: geosolutions-it/jai-ext

/**
 * Compiles a script read from a file and submits it for execution.
 * 
 * @param scriptFile file containing the Jiffle script
 * @throws Exception on problems compiling the script
 */
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);
  JiffleDirectRuntime runtime = jiffle.getRuntimeInstance();
  
  WritableRenderedImage destImage = ImageUtilities.createConstantImage(WIDTH, HEIGHT, 0d);
  runtime.setDestinationImage("result", destImage);
  executor.submit(runtime, new NullProgressListener());
}
origin: geosolutions-it/jai-ext

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

origin: geosolutions-it/jai-ext

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

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

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

protected void testScript(String script, RenderedImage srcImg, Evaluator evaluator) throws Exception {
  imageParams = new HashMap<>();
  imageParams.put("dest", Jiffle.ImageRole.DEST);
  imageParams.put("src", Jiffle.ImageRole.SOURCE);
  // test the direct runtime
  Jiffle jiffle = new Jiffle(script, imageParams);
  directRuntimeInstance = jiffle.getRuntimeInstance();
  testDirectRuntime(srcImg, directRuntimeInstance, evaluator);
  
  // and now the indirect one
  indirectRuntimeInstance =
      (JiffleIndirectRuntime) jiffle.getRuntimeInstance(Jiffle.RuntimeModel.INDIRECT);
  evaluator.reset();
  testIndirectRuntime(srcImg, indirectRuntimeInstance, evaluator);
}
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

  private JiffleDirectRuntime getRuntime(String script) throws Exception {
    Jiffle jiffle = new Jiffle();
    jiffle.setScript(script);
    jiffle.compile();
    return jiffle.getRuntimeInstance();
  }
}
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.jiffleJiffle<init>

Javadoc

Creates a new instance.

Popular methods of Jiffle

  • compile
    Compiles the script into Java source for the runtime class.
  • 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

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • getContentResolver (Context)
  • startActivity (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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