ChemAxon 3b366b17e5
10-07-2009 07:40:19
Hello,
I'm implementing support for multiple molecules in one record. It is usefull for example to show results of few chemical terms (e.g. conformormers). I use this code to show table:
TableSupport tableSupport = mvp.getTableSupport();
MDocument mdoc[] = new MDocument[mols.length];
for (int i = 0 ; i < mols.length ; i++) {
mdoc = new MDocument(mols);
}
tableSupport.start(new ArrayMDocSource(mdoc), ""); // NOI18N
It doesn't work if the component is visualized in JTable to show multiple records. Probably the main problem is that molecules are processed from MDocSource asynchronously. Is there any way how to process the molecules synchronously in AWT-EVENT-QEUE thread? The TableSupport.startNow method causes deadlock.
Thanks
Petr
User ef5e605ae6
16-07-2009 18:59:39
Hi,
No, there is no way. Since the startNow method starts and waits for new thread(s) in which calls like EventQueue.invokeAndWait can occur, it cannot be used from the AWT thread. Generally, it is not even a good idea to make GUI update wait for molecule loading. (even though it may be fast in your special case)
Peter
ChemAxon fa971619eb
20-08-2009 10:46:54
Here is a simple example exemplifying the problem (code attached):
Aim: to use MViewPane as TableCellRenderer and to have MViewPane displaying multiple cells withing the column of the JTable using the MViewPan.setM(index, mol) functionality.
Problem: structures are set to MViewPane component within the getTableCellRendererComponent() method, but the display of the structures is erratic.
Is there a solution to this?
Thanks
Tim
User ef5e605ae6
28-08-2009 07:36:40
Another proof that creating convenience methods is a mistake. Users tend to misuse them. To solve the current problem, I deprecated all asynchronous molecule setting methods in MViewPane. As of Marvin 5.2.5, setM(int, String), setM(int, String, String) and setM(int, File, String) are not recommended to use.
Attached a slightly modified version of your test application. Molecules are loaded using MolImporter, then set using a synchronous method, setM(int, Molecule).
ChemAxon fa971619eb
28-08-2009 08:04:28
Thanks for the example. It works fine.
So if I understand this correctly then setM(index, Molecule) is synchronous, while setM(index, String) is asynchronous?
If so, then I just see this as a problem in the javadocs that does not suggest this. I see no reason to remove (deprecate) the methods, just make it clear what they do and how to use them correctly.
Thanks
Tim
User ef5e605ae6
28-08-2009 13:06:01
ChemAxon fa971619eb
28-08-2009 13:09:30
Well, I've been programming with Marvin for about 8 years, and I didn't know the difference!
Tim
User ef5e605ae6
28-08-2009 13:27:19
tdudgeon wrote: |
Well, I've been programming with Marvin for about 8 years, and I didn't know the difference!
Tim
|
Usually there is no noticable difference.
The name of the asynchronous methods is also misleading, "startMolLoading" were better than setM. But the removal is even better.