Pages

19 June, 2011

Export FreeMind mind map as Java Applet

FreeMind is a free mind-mapping software written in Java. In this post I will show how to export FreeMind mind maps as Java Applet, describe issues which you can encounter during this process and give some hints on a how to better package exported mind maps.

Let’s start with creating a test mind map. Suppose we have the following mind map:

Test Mind Map

FreeMind has plenty of options for exporting mind maps. For example the image which you see above was created using Export as PNG option (File -> Export -> As PNG…). Your next question might be: Why to export mind maps as Java Applet if there are so many other options? Here is the answer. Even if FreeMind has many options for exporting mind maps, most of them are not suitable for publishing on the Internet (especially for big mind maps). Starting with FreeMind 0.9.0 two new export options were added: Flash and Java Applet. These two options can be used to bring mind maps into the Internet.

The difference between these two is that Java Applet looks exactly like maps on the screen of FreeMind but needs longer to be loaded (This can be fixed by deploying the Java Applet using Java Web Start technology. I will describe how it can be done below.). Flash application is very fast but it has a totally different look and feel and doesn’t support rich formatted text. You can see here how it looks like:

Test Mind Map exported as Flash

There a two ways for exporting mind maps as Java Applet:

  • Using FreeMind export menu. Go to File -> Export -> As Java Applet… and choose the destination file name, let’s say Test.html. After clicking OK go to the directory where you saved the file. You will see the Test.html file and a Test.html_files directory. Here, there is a small issue, at least in my case. In order to make it work, you have to edit Test.html file and specify the page title. Replace the tag <title/> with <title>Test Mind Map</title>. That’s it, save the file and open it in the browser. Now the applet should start. You will find quickly that images which are used in the mind map itself (inserted using option Insert -> Image…) are not displayed by the applet. This is because images were not exported together with the map. In order to fix this you have to follow the following rules:
    1. Store all the images used inside your mind map in one directory (e.g. files or images) which is located in the same directory with mind map file (*.mm). This will ensure that all the paths to images are relative (e.g. files/image1.png).
    2. After the export, manually copy the directory with all the images used in your mind map to same location where mind map file (*.mm) resides. In our case Test.html_files.
  • Manually. As you can see from the previous option, there are many manual steps to do in order to make it work. Due to this you can consider to configure the FreeMind Browser Applet manually. This is not complicated at all. You can find preconfigured templates at $FREEMIND_HOME/browse where $FREEMIND_HOME is the home directory of FreeMind. The only thing you have to change is the following line:
    <param name="browsemode_initial_map" value="./freemind.mm">
    
    Put your mind map file instead of freemind.mm and you are done. Also don’t forget about images. In case you are using images inside your mind map the procedure is the same one as described in previous topic.

Now it’s time to deploy the Applet on Internet. First problem which you will encounter trying to deploy the Applet is what to do with the images. It’s not very comfortable to carry all these images one by one and upload them. In order to solve this problem, we can package our mind map file (*.mm) together with all the images as one jar file. Run the following command inside the directory where mind map file is located (we assume that directory with images is located also there):

jar –cvf test-mm-freemind.jar *

After this, change the HTML applet tag as follows:

<applet code="freemind.main.FreeMindApplet.class" width="100%" height="100%"
    archive="https://sites.google.com/site/azagorneanu/freemind/freemind-browser.jar,https://sites.google.com/site/azagorneanu/mm/test/test-mm-freemind.jar">
  <param name="type" value="application/x-java-applet;version=1.4">
  <param name="scriptable" value="false">
  <param name="modes" value="freemind.modes.browsemode.BrowseMode">
  <param name="browsemode_initial_map" value="jar:https://sites.google.com/site/azagorneanu/mm/test/test-mm-freemind.jar!/test.mm">
  <param name="initial_mode" value="Browse">
  <param name="selection_method" value="selection_method_direct"> 
  <p style="text-align:center;font-weight:bold;text-decoration:underline;">
    FreeMind Browser Java Applet. You have to install Java Plug-in in order to see it.
  </p>
</applet>

For including an Applet into a Google Sites page you can use Embed Gadget (Insert -> More Gadgets -> Featured -> Embed Gadget) and paste the above snippet into.

As I mentioned above it is possible to deploy FreeMind Browser Applet using Java Web Start. This can give you a speed boost in case you are experiencing problems with Applets. Doing this is very easy and requires only the configuration of one XML file with JNLP (Java Network Launching Protocol) extension. Below you can see how test-mm-freemind.jnlp file looks like:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="https://sites.google.com/site/azagorneanu/mm/test/" href="test-mm-freemind.jnlp">
  <information>
    <title>Test FreeMind MindMap</title>
    <vendor>FreeMind & Andrei Zagorneanu</vendor>
    <description>Test MindMap by Andrei Zagorneanu</description>
    <description kind="short">
            Test FreeMind MindMap [http://freemind.sourceforge.net/]
            prepared by Andrei Zagorneanu [http://azagorneanu.blogspot.com/]
    </description>
    <homepage href="http://azagorneanu.blogspot.com/"/>
    <icon href="https://sites.google.com/site/azagorneanu/freemind/freemind-icon.png" width="128" height="128"/>
  </information>
  <resources>
    <j2se version="1.4+" />
      <jar href="https://sites.google.com/site/azagorneanu/freemind/freemind-browser.jar" />
      <jar href="https://sites.google.com/site/azagorneanu/mm/test/test-mm-freemind.jar" />
  </resources>
  <applet-desc name="FreeMind Browser" width="1200" height="700" main-class="freemind.main.FreeMindApplet">
    <param name="type" value="application/x-java-applet;version=1.4" />
    <param name="scriptable" value="false" />
    <param name="modes" value="freemind.modes.browsemode.BrowseMode" />
    <param name="browsemode_initial_map" value="jar:https://sites.google.com/site/azagorneanu/mm/test/test-mm-freemind.jar!/test.mm" />
    <param name="initial_mode" value="Browse" />
    <param name="selection_method" value="selection_method_direct" />
  </applet-desc>
</jnlp>

Next, this file has to be uploaded along with other jar files and then used inside a link (anchor) as follows:

<a href="/site/azagorneanu/mm/test/test-mm-freemind.jnlp">Browse using Java Web Start</a>

After clicking on link, choose Open option or save the file to your computer and then open it. The FreeMind browser should start.

Here https://sites.google.com/site/azagorneanu/mm/test you can find deployed both versions (Applet and Java Web Start) of our Test mind map.

You can browse Test Mind Map using one of the following:

Java Applet   Java Web Start

Make sure that you have installed Java Plug-in for your browser. In case your browser is 32-bit (x86) you have to install a version of Java also for 32-bit. For example for Firefox 4 you have to install a 32-bit version of Java. For a 64-bit browser you will need a 64-bit java. You can download latest java from http://java.com/.

3 comments:

  1. Man, I love you for your advice how to solve problem with "not showing" the pictures.. Thank you very much!

    ReplyDelete
  2. Thanks for the detailed information. and also most of the times both 32 bit and 64 bit works as these expect in some cases where if there are any machine specific calls are called. 32 bit takes 4 bytes long,64 bit takes 8 bytes of size, so 32 bit takes less size compared to 64 bit machines.
    To find out the 32 bit or 64 bit 32 bit or 64 bit

    ReplyDelete
  3. Gosto muito dos artigos de ótima qualidade do seu Blog. Quando for possível dá uma passadinha para ver nosso Curso de Informática Online. Lucas

    ReplyDelete