From: jprocter Date: Mon, 15 Aug 2011 13:28:38 +0000 (+0100) Subject: JAL-904 added scrollToRow and scrollToColumn methods to javascript API and reintroduc... X-Git-Tag: Release_2_7~111 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9e3e20c98eae9498a68bb0a770359564797a12ef;p=jalview.git JAL-904 added scrollToRow and scrollToColumn methods to javascript API and reintroduced getSequenceSetId to retrieve the unique ID for an alignment. --- diff --git a/examples/jalviewLiteJs.html b/examples/jalviewLiteJs.html index 434d1a7..2a90393 100644 --- a/examples/jalviewLiteJs.html +++ b/examples/jalviewLiteJs.html @@ -304,6 +304,14 @@ public boolean addPdbFile(AlignFrame alFrame, // the given location the top left hand corner for given current view (v2.7) public void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn) +// adjust horizontal scroll in alf to the make +// the given location the left hand corner for given current view (v2.7) +public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn) + +// adjust horizontal/vertical scroll in alf to the make +// the given location the top row for given current view (v2.7) +public void scrollViewToRowIn(AlignFrame alf, String topRow) + // return separator separated list of feature groups // on the current alignment diff --git a/examples/javascript/jalview.js b/examples/javascript/jalview.js index 4cc613e..66c5a3e 100644 --- a/examples/javascript/jalview.js +++ b/examples/javascript/jalview.js @@ -17,11 +17,11 @@ function getDestinationFrms(source, frames) { var frid = ""; for (frm in frames) { try { - frid = (("" + source.getDatasetId()) == ("" + frames[frm] - .getDatasetId())); + frid = (source!=null) && (("" + source.getSequenceSetId()) == ("" + frames[frm].currentAlignFrame + .getSequenceSetId())); } catch (q) { - } - ; + }; + if (!frames[frm].equals(source) && !frid && !frames[frm].currentAlignFrame.equals(source)) { frms[frms.length] = frames[frm]; @@ -108,6 +108,7 @@ function linkJvJmol(applet, jmolView, modeltofiles) { // try { applet.setViewListener("viewlist"); } catch (err) {}; if (jmolView) { + var sep = applet.getSeparator(); var oldjm=jmolView; // recover full id of Jmol applet jmolView=_jmolGetApplet(jmolView).id; @@ -129,14 +130,15 @@ function linkJvJmol(applet, jmolView, modeltofiles) { mtf=""; var dbase = document.baseURI.substring(0,document.baseURI.lastIndexOf("/")+1); for (m in jmbinding._modelstofiles) - { mtf+=jmbinding._modelstofiles[m]; + { if (m>0) { mtf+=sep; } + mtf+=jmbinding._modelstofiles[m]; if (jmbinding._modelstofiles[m].indexOf("//")==-1) - { jmbinding._fullmpath[m] = dbase+jmbinding._modelstofiles[m]; } - jmbinding._filetonum.put(jmbinding._modelstofiles[m], m); - jmbinding._filetonum.put(jmbinding._fullmpath[m], m); + { jmbinding._fullmpath[m] = dbase+((jmbinding._modelstofiles[m].indexOf("/")==0) ? jmbinding._modelstofiles[m].substring(1) : jmbinding._modelstofiles[m]); } + jmbinding._filetonum.put(jmbinding._modelstofiles[m], m+1); + jmbinding._filetonum.put(jmbinding._fullmpath[m], m+1); - if (m>0) { mtf+=sep; }} - jvfollower.setStructureListener("_structure", mtf); + } + applet.setStructureListener("_structure", mtf); } } @@ -265,10 +267,11 @@ function _jmolhover(jmid, atomlabel, atomidx) { // relaxed third parameter - may be null or a model number for multi model // views atomlabel = ("" + atomlabel) - .match(/\[(.+)\](\d+):(.)\.(\S+)\s*(\/\d+\.|).+/); + .match(/\[(.+)\](\d+):(.)\.([^\/]+)(\/\d+\.|).+/); atomidx = "" + atomidx; if (atomlabel[5]) { atomlabel[5] = atomlabel[5].match(/\/(.+)\./)[1]; + atomlabel[5] = parseInt(atomlabel[5])-1; } else { // default - first model atomlabel[5] = 0; @@ -278,7 +281,8 @@ function _jmolhover(jmid, atomlabel, atomidx) { _jvapps[ap].mouseOverStructure(atomlabel[2], atomlabel[3], document.baseURI .substring(0, document.baseURI.lastIndexOf('/')) - + "/" + modeltofiles[atomlabel[5]]); + + "/" + + modeltofiles[atomlabel[5]]); msg = _jmolhovermsg; } } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 8f8ac5a..d2b04f9 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -3543,4 +3543,18 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { alignPanel.seqPanel.scrollTo(row, column); } + public void scrollToRow(int row) + { + alignPanel.seqPanel.scrollToRow(row); + } + public void scrollToColumn(int column) + { + alignPanel.seqPanel.scrollToColumn(column); + } + /** + * @return the alignments unique ID. + */ + public String getSequenceSetId() { + return viewport.getSequenceSetId(); + } } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index ade0afd..cce8c23 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1774,8 +1774,8 @@ public class SeqPanel extends Panel implements MouseMotionListener, } if (repaint) { + ap.scalePanelHolder.repaint(); ap.repaint(); - //ap.paintAlignment(false); } } @@ -1791,5 +1791,25 @@ public class SeqPanel extends Panel implements MouseMotionListener, column = column<0 ? ap.av.startRes : column; ap.scrollTo(row, row, column, true, true); } + /** + * scroll to the given row - or nearest visible location + * @param row + */ + public void scrollToRow(int row) + { + + row = row<0 ? ap.av.startSeq : row; + ap.scrollTo(row, row, ap.av.startRes, true, true); + } + /** + * scroll to the given column - or nearest visible location + * @param column + */ + public void scrollToColumn(int column) + { + + column = column<0 ? ap.av.startRes : column; + ap.scrollTo(ap.av.startRes, ap.av.startRes, column, true, true); + } } diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 24f3351..25c907d 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -69,6 +69,10 @@ import netscape.javascript.JSObject; public class JalviewLite extends Applet implements StructureSelectionManagerProvider, JalviewLiteJsApi { + public StructureSelectionManager getStructureSelectionManager() + { + return StructureSelectionManager.getStructureSelectionManager(this); + } // ///////////////////////////////////////// // The following public methods maybe called // externally, eg via javascript in HTML page @@ -934,11 +938,44 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv } catch (Exception ex) { - System.err.println("Couldn't parse integer arguments (topRow='"+topRow+"' and leftHandColumn='"+leftHandColumn+"'"); + System.err.println("Couldn't parse integer arguments (topRow='"+topRow+"' and leftHandColumn='"+leftHandColumn+"')"); + ex.printStackTrace(); + } + } + + /* (non-Javadoc) + * @see jalview.javascript.JalviewLiteJsApi#scrollViewToRowIn(jalview.appletgui.AlignFrame, java.lang.String) + */ + @Override + public void scrollViewToRowIn(AlignFrame alf, String topRow) + { + try { + alf.scrollToRow(new Integer(topRow).intValue()); + + } catch (Exception ex) + { + System.err.println("Couldn't parse integer arguments (topRow='"+topRow+"')"); ex.printStackTrace(); } } + /* (non-Javadoc) + * @see jalview.javascript.JalviewLiteJsApi#scrollViewToColumnIn(jalview.appletgui.AlignFrame, java.lang.String) + */ + @Override + public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn) + { + + try { + alf.scrollToColumn(new Integer(leftHandColumn).intValue()); + + } catch (Exception ex) + { + System.err.println("Couldn't parse integer arguments (leftHandColumn='"+leftHandColumn+"')"); + ex.printStackTrace(); + } + } + // ////////////////////////////////////////////// // ////////////////////////////////////////////// diff --git a/src/jalview/javascript/JalviewLiteJsApi.java b/src/jalview/javascript/JalviewLiteJsApi.java index a7255b0..19b74ca 100644 --- a/src/jalview/javascript/JalviewLiteJsApi.java +++ b/src/jalview/javascript/JalviewLiteJsApi.java @@ -400,7 +400,7 @@ public interface JalviewLiteJsApi String pdbEntryString, String pdbFile); /** - * adjust horizontal/vertical scroll to the make the given location the top left hand corner for given current view + * adjust horizontal/vertical scroll to make the given location the top left hand corner for the given view * * @param alf * @param topRow @@ -408,6 +408,20 @@ public interface JalviewLiteJsApi */ public abstract void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn); + /** + * adjust vertical scroll to make the given row the top one for given view + * + * @param alf + * @param topRow + */ + public abstract void scrollViewToRowIn(AlignFrame alf, String topRow); + /** + * adjust horizontal scroll to make the given column the left one in the given view + * + * @param alf + * @param leftHandColumn + */ + public abstract void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn); /** *