Short Description

Example on how to use the Math Operations Plugin in scripts.

Versions

  • Version 2 • Released on: 2013-09-20 15:39:47
    Download
    Description:

    * simpler code

    importClass(Packages.plugins.ylemontag.mathoperations.functors.Functor1)
    importClass(Packages.plugins.ylemontag.mathoperations.Expression)
    importClass(Packages.icy.gui.main.MainInterface)
    importClass(Packages.plugins.ylemontag.mathoperations.Functor)
    
    // get the sequence
    seq = getSequence()
    if (seq == null) throw "Please open a sequence first"
    
    // create the expression
    formula = "a ^ 2"
    
    // The Functor parses the formula, 
    // and apply() assigns its arguments to the variables of the formula.
    // Ex : Here, seq is assigned to "a".
    seqRes = Functor1.parse(formula).apply(seq)
    
    gui.addSequence(seqRes)
    
  • Version 1 • Released on: 2013-03-11 12:01:49
    Download
    Description:

    initial version

    importClass(Packages.icy.gui.main.MainInterface)
    importClass(Packages.plugins.ylemontag.mathoperations.Functor)
    importClass(Packages.plugins.ylemontag.mathoperationspp.Expression)
    
    // get the sequence
    seq = getSequence()
    if (seq == null) throw "Please open a sequence first"
    
    // create the expression
    formula = "seq ^ 2"
    
    // get the formula as a Function
    fn = Expression.parse(formula).getFunctor()
    
    // create an array of arguments
    args = [ seq ]
    
    // apply the Function to the arguments
    seq = fn["apply(icy.sequence.Sequence[])"](args)
    
    gui.addSequence(seq)
    

Leave a Review