multiple labels in a single mView cell

User 37df300f74

29-01-2007 22:24:51

I would like to load several molecules in mViewPane class. In each cell, I plan to put a single molecule and several labels. I searched around and it seems that mViewPane.setL(int, String) can not do it. Any idea?

ChemAxon 7c2d26e5cf

31-01-2007 14:48:48

If there are several labels in a cell, use MViewPane.setL multiple times.


E.g. If there are 2 labels in each cells, call setL twice. In this case, the index of labels are (i*2) and (i*2)+1 where i is the (zero based) cell index.


Code:
viewPane.setParams("rows=2\n"+


                    "cols=2\n"+


                    "layout0=:3:1:M:1:0:1:1:c:b:1:1:L:0:0:1:1:c:n:0:1:L:2:0:1:1:c:n:0:1\n"+


                    "param0=:M:100:100:L:10b:L:10\n");


String[] molfiles = new String[]{


                    "mols-2d/caffeine.mol", "Caffeine",


                    "mols-2d/lysergide.csmol", "Lysergide",


                    "mols-2d/vitaminc.csmol", "Vitamin C",


                    "mols-2d/aspirin.csmol", "Aspirin" };


for(int i = 0; i < molfiles.length/2; i++) {


      viewPane.setM(i, molfiles[i*2]); // molecule in the cell


      viewPane.setL(i*2, new Integer(i+1).toString()); // first label in the cell


      viewPane.setL(i*2+1, molfiles[i*2+1]); // second label in the cell


}