Molecules

How a molecule gets added into the editor.
1. WidgetCreationTool -> mouseClicked -> instantiateWidget(FluencyModel, WidgetData);
2. This makes a new AddCommand with the widget data and executes it. This takes the XML representation and calls FluencyModel.addNewWidgetFromXML()
3. Here, now in FluencyModel, a ProtoTypeReader is made and used to parse the given XML into a widgetPrototype. IDs are assigned to harbors, and the <WidgetID, WidgetProtoType> are added to currentWidgets, and a refresh is made with the ID number.

As of now, the ProtoTypeReader is improperly loading a prototype from a Molecule XML, as it does not maintain a list of all harbors of all contained widgets, nor does it maintain a list of IDS for those widgets. A PrototypeWidget is the notion of an abstract, created widget that lives in a fluency App as the user placed it.
-JB

Understandings so far:
1. Molecule widgets are loaded using the MoleculeLoader class. Molecules are saved as <molecule_name>.molecule in user's fluency directory.
2. At present we are able to save the Molecule in (.molecule file) but while reading the file problems occur.
listing the problems
a. While reading the file , the name of the file is not passed properly. problem starts from the constructor in Molecule class. public Molecule(String location)
location = location.concat(".molecule"); This line should solve the problem for now. but thats a quick fix.

b. after the above problem is solved. we are having problem with parsing the .molecule file.

c. Molecules are loaded using "public static WidgetData getMolecule(String widget)" in WidgetDataExplorer class. No unit test cases are written for this function.
I think we will have to check whether this function works properly.

Work done till now.

1. Now you can save the molecule.
2. Once saved you can see the molecule in Fluency Editor Frame and in the WidgetFinder.

Problem that we have to solve

We are not able to create Widgets from the Molecule(xml) file.
While parsing the xml file for molecule we are facing problems.

Some things to look.
1. The molecule file contains version details.
<Properties id='Basic Fluency Editor' version='0.1.6' size='244.134' offset='92.102' name='check' desc='asdafdsfds'/>

where version is of the form version=MAJOR_NUM.MINOR_NUM.REVISION_NUM.

2. All the properties of Widget that are of String type are encoded as hexadecimal in the XML file. So while reading the xml file we will have to decode it.
we have the deoding logic in place. (TextProperty.java) function name decode().

Conclusion as of now : While decoding the String property of Widget for molecule, we are facing problem.
Doubt: Is there a backward compatibility in Fluency. (you can see that in the decode() function)

Some more insights

While loading any widget or molecule we use the createWidget() function in FluencyLoader.
The signature of this function is createWidget(String classNameForWidget, WidgetID newID).
But , in case of widgets that belong to a molecule, we dont have the class name, in the first parameter.
In case of molecule we have a string, like "Molecule:molecule_name".
Using molecule_name we get the file name of the molecule and then we continue further.

I know it sound wierd but thats hows it has been done.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 08, 2007

    whoknows says:

    backward compatibility would be nice to have, but it's too early to make that an...

    backward compatibility would be nice to have, but it's too early to make that any kind of constraint on what we do to develop a good beta. we have nothing without a beta to showcase the main idea. if fluency becomes useful to people then we can consider hard problems like maintaining backward compatibility.

    in the short term, what this means is that often work by the author will have to be redone. that's a pain and will limit fluency's uses, so it's an important problem, but considering that we don't even have molecules yet, what does it matter right now? first things first.
    gjer.

    ps. why not ask your questions of mark on the list???

  2. Nov 09, 2007

    whoknows says:

    based on your description of how one method (createWidget()) is asked to do two ...

    based on your description of how one method (createWidget()) is asked to do two different things (create atomic widgets or create atomic widgets for molecules given the molecule's name), i'd say that's a poorly written method. it should be two separate methods, one of which delegates to the other, once it's picked out the appropriate widget out of a particular molecule. then add a third method just to handle molecules, and it would delegate to the second method, which delegates to the first one---which is the only one that actually needs to create actual atomic widgets.
    gjer.

    ps. of course the above is based on my understanding of what you said above. if that's not accurate my advice is worthless.

  3. Nov 09, 2007

    Girish Subramanian says:

    I have checked it many times and it is done in the way I have explained. As of n...

    I have checked it many times and it is done in the way I have explained.

    As of now I am not changing the flow, I am trying to keep the flow of code as it is and trying to make Molecule work.

    once the molecule work , we can start changing the methods.

    1. Nov 09, 2007

      whoknows says:

      ok. gjer.

      ok.
      gjer.