+/*******************************************************************************
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
package jalview.javascript;\r
\r
import java.awt.Color;\r
+import java.util.ArrayList;\r
+\r
import jalview.api.AlignmentViewPanel;\r
import jalview.api.FeatureRenderer;\r
import jalview.api.SequenceRenderer;\r
import jalview.ext.jmol.JmolCommands;\r
import jalview.structure.StructureListener;\r
import jalview.structure.StructureMapping;\r
+import jalview.structure.StructureMappingcommandSet;\r
import jalview.structure.StructureSelectionManager;\r
\r
/**\r
}\r
;\r
\r
- // Form a colour command for the given alignment panel\r
- final String[] colcommands = JmolCommands.getColourBySequenceCommand(\r
+ \r
+ // Form a colour command from the given alignment panel for each distinct structure \r
+ ArrayList<String[]> ccomands=new ArrayList<String[]>();\r
+ ArrayList<String> pdbfn=new ArrayList<String>();\r
+ StructureMappingcommandSet[] colcommands=JmolCommands.getColourBySequenceCommand(\r
ssm, modelSet, sequence, sr, fr,\r
((AlignmentViewPanel) source).getAlignment());\r
- if (colcommands==null)\r
- {\r
- // \r
+ if (colcommands==null) {\r
return;\r
}\r
+ int sz=0;\r
+ for (jalview.structure.StructureMappingcommandSet ccset: colcommands) {\r
+ sz+=ccset.commands.length;\r
+ ccomands.add(ccset.commands);\r
+ pdbfn.add(ccset.mapping);\r
+ }\r
+ \r
String mclass,mhandle;\r
+ String ccomandset[] = new String[sz];\r
+ sz=0;\r
+ for (String[] ccset: ccomands) {\r
+ System.arraycopy(ccset, 0, ccomandset, sz, ccset.length);\r
+ sz+=ccset.length;\r
+ }\r
if (jvlite.isJsMessageSetChanged(mclass="colourstruct",mhandle=((jalview.appletgui.AlignmentPanel) source).av\r
- .getViewId(), colcommands)) {\r
- jvlite.setJsMessageSet(mclass, mhandle , colcommands);\r
+ .getViewId(), ccomandset)) {\r
+ jvlite.setJsMessageSet(mclass, mhandle , ccomandset);\r
// and notify javascript handler\r
String st[] = new String[]\r
{\r
"colourstruct",\r
""\r
+ ((jalview.appletgui.AlignmentPanel) source).av\r
- .getViewId(), ""+colcommands.length, ""+(colcommands[0]!=null ? colcommands[0].length() : 0)};\r
+ .getViewId(), ""+ccomandset.length, jvlite.arrayToSeparatorList(pdbfn.toArray(new String[pdbfn.size()]))\r
+ };\r
try\r
{\r
executeJavascriptFunction(\r
{\r
System.err.println("Couldn't execute callback with "\r
+ _listenerfn + " using args { " + st[0] + ", "\r
- + st[1] + ", " + st[2] + "," + st[3] + "\n");\r
+ + st[1] + ", " + st[2] + "," + st[3]+"}"); // + ","+st[4]+"\n");\r
ex.printStackTrace();\r
\r
}\r