+ SequenceRenderer sr = ((jalview.appletgui.AlignmentPanel) source)
+ .getSequenceRenderer();
+ FeatureRenderer fr = ((jalview.appletgui.AlignmentPanel) source).av
+ .isShowSequenceFeatures() ? new jalview.appletgui.FeatureRenderer(
+ ((jalview.appletgui.AlignmentPanel) source).av) : null;
+ if (fr != null)
+ {
+ ((jalview.appletgui.FeatureRenderer) fr)
+ .transferSettings(((jalview.appletgui.AlignmentPanel) source)
+ .getFeatureRenderer());
+ }
+ ;
+
+ // Form a colour command from the given alignment panel for each distinct
+ // structure
+ ArrayList<String[]> ccomands = new ArrayList<String[]>();
+ ArrayList<String> pdbfn = new ArrayList<String>();
+ StructureMappingcommandSet[] colcommands = JmolCommands
+ .getColourBySequenceCommand(ssm, modelSet, sequence, sr, fr,
+ ((AlignmentViewPanel) source).getAlignment());
+ if (colcommands == null)
+ {
+ return;
+ }
+ int sz = 0;
+ for (jalview.structure.StructureMappingcommandSet ccset : colcommands)
+ {
+ sz += ccset.commands.length;
+ ccomands.add(ccset.commands);
+ pdbfn.add(ccset.mapping);
+ }
+
+ String mclass, mhandle;
+ String ccomandset[] = new String[sz];
+ sz = 0;
+ for (String[] ccset : ccomands)
+ {
+ System.arraycopy(ccset, 0, ccomandset, sz, ccset.length);
+ sz += ccset.length;
+ }
+ if (jvlite.isJsMessageSetChanged(
+ mclass = "colourstruct",
+ mhandle = ((jalview.appletgui.AlignmentPanel) source).av
+ .getViewId(), ccomandset))
+ {
+ jvlite.setJsMessageSet(mclass, mhandle, ccomandset);
+ // and notify javascript handler
+ String st[] = new String[]
+ {
+ "colourstruct",
+ "" + ((jalview.appletgui.AlignmentPanel) source).av.getViewId(),
+ "" + ccomandset.length,
+ jvlite.arrayToSeparatorList(pdbfn.toArray(new String[pdbfn
+ .size()])) };
+ try
+ {
+ executeJavascriptFunction(true, _listenerfn, st);
+ } catch (Exception ex)
+ {
+ System.err.println("Couldn't execute callback with "
+ + _listenerfn + " using args { " + st[0] + ", " + st[1]
+ + ", " + st[2] + "," + st[3] + "}"); // + ","+st[4]+"\n");
+ ex.printStackTrace();
+
+ }
+ }
+ /*
+ * new Thread(new Runnable() { public void run() { // and send to
+ * javascript handler String st[] = new String[0]; int i = 0; for (String
+ * colcommand : colcommands) { // do sync execution for each chunk try {
+ * executeJavascriptFunction( false, _listenerfn, st = new String[] {
+ * "colourstruct", "" + ((jalview.appletgui.AlignmentPanel) source).av
+ * .getViewId(), handle, "" }); } catch (Exception ex) {
+ * System.err.println("Couldn't execute callback with " + _listenerfn +
+ * " using args { " + st[0] + ", " + st[1] + ", " + st[2] + "," + st[3] +
+ * "\n"); ex.printStackTrace();
+ *
+ * } } } }).start();
+ */
+ }