Menu

Scripting API doc for non-developers?

Phil
2009-11-01
2012-10-07
  • Phil

    Phil - 2009-11-01

    Hi there,

    First of all: thanks to the developers for doing all this work, and also for
    the work previously put into Freemind, of which I became a heavy user, and on
    which I currently depend.

    I'd love to switch to Freeplane, but there's one hindrance: I need scripting
    for doing my work, but I am not able to port my scripts without assistance.
    Bad combination. I'd need to get text from nodes, have access to child nodes,
    change fonts, change colors, check for presence and value of attributes,
    programmatically center the viewport on some node, all that.

    It would be absolutely terrific if someone with more ability could spend the
    time to make a port of a helpful script that can be found on the Freemind
    pages:

    I dare asking for this because I am sure having some rudimentary scripting API
    documentation would help many users.

    Thanks for reading
    Phil

    : http://freemind.sourceforge.net/wiki/index.php/Example_scripts#Daves_massiv
    ly_cheezy_Api_Generator

     
  • Ryan Wesley

    Ryan Wesley - 2009-11-01

    Hi Phil,

    Thanks for your interest. Due to the extensive refactoring, the API has been
    in flux. The changes to the code should have settled down now we're in beta.

    Hopefully we can put some documentation together soon, and I will get back to
    you.

    Regards,
    Ryan

     
  • Phil

    Phil - 2009-11-02

    Thanks, Ryan!

    Looking forward to that!
    IMHO a transparent and (more or less) invariant scripting interface, and
    ideally a simple way to register a script as a custom menu item would probably
    be beneficial to the project. A larger crowd of users with less profound
    programming skills (including me) would be enabled to contribute without the
    need to understand the whole architecture of the software.

     
  • Dimitry Polivaev

    Hi Phil,

    for making the doc you requested I need some assistance from you because we
    have quite different backgrounds. I almost never use scripting facilities.

    1. I looked at the script you reference, I run it in FreeMind and I still do not understand its purpose. Couldn't you explain it to me?
    2. Register your account at http://freeplane.sourceforge.net/wiki/index.php/Main_Page, create a new page for script doc and ask your questions, ideally in a structured form. Explain what you need and let me give you examples how to achieve it in Freeplane.
    3. I think that there could be extra API for scripting making sure that is is compatible with undo. For this purpose we need a proxy object with the most frequently used node/map operations. I think it is not a new feature but just a new API and I could integrate it in the current release. But I need better understanding of what the scripts are good for to create such solution.

    Dimitry

     
  • Phil

    Phil - 2009-11-02

    Hi Dimitry,

    I'll do as you say and open that script doc page.
    Here I quickly respond to your question concerning the "cheezy object
    reference" script from the Freemind page. As I experienced it, it will
    just take one of the preset objects "c" or "node"
    (whichever line you uncomment at the bottom of the script) and create new
    nodes as children of the node containing the script. These contain return
    type, method name and parameter list of the methods of "c" or
    "node".
    I found this quite convenient, because the method names are mostly self
    explanatory.
    When I see a node like

    public void setColor(Color)
    void
    class java.awt.Color
    Comments

    for the "node" object and

    public MindMapNode getSelected()
    freemind.modes.MindMapNode
    none
    Comments
    for the "c" object, then I can guess I should call
    c.getSelected().setColor(Color.WHITE) to turn the currently selected node
    white. In this sense I found the "cheezy" script quite useful...

    Regards
    Phil

     
  • Dimitry Polivaev

    Scripting API is still to be developed. It depends only on the community when
    it happens. Look at http://freeplane.sourceforge.net/mediawiki-1.14.1/index.p
    hp/Scripting_documentation
    and make your suggestions. Once we have the
    specification it shall be implemented.

    Dimitry

     
  • Dimitry Polivaev

    John, your API is looks like C API, not like a object oriented one.
    I do not like to think about node IDs, I prefer to deal with node objects.

    Also something like node.atributes.count() or node.attibutes.get(1).value = "text"

    I take MS Visual Basic for Applications (MS Office) as an example.

    Dimitry

     
    👍
    1
  • Phil

    Phil - 2009-11-15

    Hello again,

    I finally found the time to think and just added an API draft to the Talk page
    opened by John, which should be closer to the style imagined by Dimitry. It
    hopefully can serve as a basis for discussion.

    Regards
    Phil

     
  • Dimitry Polivaev

    I commented in Wiki. Dimitry

     
  • Phil

    Phil - 2009-11-15

    Read your comment and slightly extended the "API" draft. Guess it's time to
    close this thread here and ultimately migrate it to the Wiki page

    Regards, Phil

    : http://freeplane.sourceforge.net/mediawiki-1.14.1/index.php/Talk:Scripting_
    documentation

     
  • Dimitry Polivaev

    Hello,

    1. I am already working on implementing the specified API .
    2. I have one problem There are some cases where some style property like font size is not set on the object itself but comes from the map's default. And it applies to the most style properties including properties of the edges, clouds, nodes, connectors and so on. It means that in addition to getProperty() and setProperty(property) there is a need of boolean isPropertySet() and void resetProperty(). So I have to implement four methods per property, not only the two, right?

    Dimitry

     
  • Phil

    Phil - 2009-11-21

    Hello,
    to be honest, I see no much better solution. One alternative would be to have
    a dummy property object "mapDefault" of some class "DefaultProperty" extending
    Object, and to overload each setProperty(property) with
    setProperty(DefaultProperty mapDefault) to do the same as resetProperty()
    would do. This would save all the specialized resetProperty() methods. Is that
    more elegant ? I don't know. It's up to you.

    Phil

     
  • Dimitry Polivaev

    I have implemented API and put the details in Wiki.
    The new code is submitted to bazaar.
    It is not tested yet.

    Dimitry