Adding Nodes with Javascript?

  • Robert

    Robert - 2004-09-22

    I am using TG Linkbrowser.

    Is it possible to add nodes through javascript?

    I would like to add notes interactively from results external webpages. I want to parse these pages and then add nodes accordingly. (Something like googlebrowser oder amazonbrowser, but lighter).

    Is there an interface to add nodes from outside the applet? E.g. javascript?

    Thank you


    • - 2004-09-22

      From what I gather, that would take java programming on LB itself. I'm wondering if an updated version is in the works.

      • Trejkaz

        Trejkaz - 2004-09-22

        Couldn't you just make your own Applet class and add whatever public methods you needed from the script?


 - 2004-09-22

          That's over my head, but if it happens, please tell!

          • Trejkaz

            Trejkaz - 2004-09-23

            The idea would be to do it yourself, like anything else which needs customisation.  It's really not that hard.

            Quick rundown...

            In the HTML page you would have something like...
            <script type="text/javascript">
            <applet id="myApplet" ... />
            <!-- or <object id="myApplet" .../> ... depending on the version of HTML. -->

            When this script tries to call myApplet.doIt(), it basically tries to call the doIt() method on the actual applet.  So all you need to add are whatever methods you need.

            public class ScriptableLinkBrowserApplet extends JApplet {
                private TGLinkBrowser tgLinkBrowser;

                public void init() {
                    getContentPane().setLayout(new BorderLayout());
                    tgLinkBrowser = new TGLinkBrowser(this, null);
                    getContentPane().add(tgLinkBrowser, BorderLayout.CENTER);

                public void setLocale(String nodeName) {

                public void addNode(String name) {

            The setLocale method was already there, and we've added the addNode method, which you can now use from Javascript as myApplet.addNode("blah").

            Actually, if you just put a method into the applet to return the TGLinkBrowser itself, you could effectively do whatever you want from the Javascript side, without needing to add any more code in the future.


     - 2004-09-23

              So, how hard would it be to click on a node and have new nodes and edges loaded from external souces? How can one go in and check to see if the nodes already exist? This might not be over my head, after all.

              PS: sorry to laxxx333 for hijacking the thread

              • Trejkaz

                Trejkaz - 2004-09-23

                That would be a different situation, most likely... you wouldn't want to use Javascript to do that at all, but you would want to write the loading code in Java.

                Incidentally, though... I thought LinkBrowser was already able to jump between XML graph files.  Wouldn't this be enough capabilities?  I've used this in a scenario where the XML graph files were automatically generated, and it was pretty decent.  Of course, we were on an intranet...


         - 2004-09-23

                  I have considered doing it this way (by pointing the xml link to a dynamic graph.xml.php), but it takes away from the funtionality of LB (adding nodes before subtracting them, etc).

                  I think it will end up easier for me to get _all_ of the data that I want into a static graph.xml. Zipped up, it shouldn't be too huge.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks