Short Description

This script shows how to resolve an Ambiguous error raised by JavaScript.

Versions

  • Version 1 • Released on: 2013-03-11 13:57:38
    Download
    Description:

    initial version

    importClass(Packages.icy.gui.main.MainInterface)
    importClass(Packages.plugins.adufour.thresholder.Thresholder)
    
    seq = getSequence()
    
    /* 
     * The following method will not work, run it and look at the error 
     * message. Then, comment the following line.
     */
    result = Thresholder.threshold(seq, 1, [127], false)
    
    /*
     * In fact JavaScript doesn't know which function to call,
     * and therefore asks you to be more specific.
     * JavaScript lets you choose between two calls:
     * 	- class icy.sequence.Sequence threshold(icy.sequence.Sequence,int,double[],boolean)
     *	- class icy.sequence.Sequence threshold(icy.sequence.Sequence,int,double[][],boolean)
     *  
     * Copy only the method without the "class" and the return type, 
     * and write the following:
     */
    result = Thresholder["threshold(icy.sequence.Sequence,int,double[],boolean)"](seq, 1, [127], false)
    
    // in [], as a string, there is the specific call you want to use
    // However, you still have to give the parameters
    
    gui.addSequence(result)

Leave a Review