congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Jiffle.setScript
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using it.geosolutions.jaiext.jiffle.Jiffle.setScript (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

/**
 * 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

@Test
public void resetScript() throws Exception {
  System.out.println("   resetScript");
  
  String script1 = "dest = 42;";
  String script2 = "dest = foo;";
  
  jiffle.setScript(script1);
  jiffle.setScript(script2);
  
  String result = jiffle.getScript();
  assertFalse(result.contains(script1));
  assertTrue(result.contains(script2));
}

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
public void setScript() throws Exception {
  System.out.println("   set and get the script");
  
  String script = "dest = 42;";
  jiffle.setScript(script);
  
  String result = jiffle.getScript();
  assertTrue(result.contains(script));
}

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

  @Test(expected=JiffleException.class)
  public void getRuntimeBeforeCompiling() throws Exception {
    System.out.println("   getRuntimeInstance before compiling");
    
    String script = "dest = 42;";
    jiffle.setScript(script);
    
    imageParams.put("dest", Jiffle.ImageRole.DEST);
    jiffle.setImageParams(imageParams);
    
    JiffleRuntime runtime = jiffle.getRuntimeInstance();
  }    
}
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

  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 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

@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.jiffleJifflesetScript

Javadoc

Sets the script. Calling this method will clear any previous script and runtime objects.

Popular methods of Jiffle

  • <init>
    Creates a new instance by compiling the provided script. Using this constructor is equivalent to: J
  • 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
  • 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

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • Menu (java.awt)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Sublime Text for Python
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