From: Jim Procter Date: Sat, 22 Oct 2022 11:40:35 +0000 (+0100) Subject: JAL-2349 JAL-3855 highlight residues associated with elements under mouse - Jmol... X-Git-Tag: Release_2_11_3_0~23^2~20 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=e70614203293e8f04d7640729851725a763ae130 JAL-2349 JAL-3855 highlight residues associated with elements under mouse - Jmol doesn’t like highlighting many residues at once this way. --- diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index e12cc3f..d31e52d 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -1097,14 +1097,16 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (clist != null) { ContactGeometry cgeom = new ContactGeometry(clist, ann.graphHeight); - ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset, - rowAndOffset); + ContactGeometry.contactInterval ci = cgeom.mapFor(rowAndOffset); ContactRange cr = clist.getRangeFor(ci.cStart, ci.cEnd); tooltip = "Contact from " + clist.getPosition() + ", [" + ci.cStart + " - " + ci.cEnd + "]" + "
Mean:" + cr.getMean(); - - // ap.getStructureSelectionManager().mouseOverSequence(ann.sequenceRef, - // new int[] {column, ci.cStart,ci.cEnd}, -1, null) + int col = ann.sequenceRef.findPosition(column); + ap.getStructureSelectionManager() + .highlightPositionsOn(ann.sequenceRef, new int[][] + { new int[] { col, col }, + new int[] + { ci.cStart, ci.cEnd } }, null); } } return tooltip; diff --git a/src/jalview/renderer/ContactGeometry.java b/src/jalview/renderer/ContactGeometry.java index 52581fb..4aef1d8 100644 --- a/src/jalview/renderer/ContactGeometry.java +++ b/src/jalview/renderer/ContactGeometry.java @@ -12,8 +12,11 @@ public class ContactGeometry final int contact_height; + final int graphHeight; + public ContactGeometry(ContactListI contacts, int graphHeight) { + this.graphHeight = graphHeight; contact_height = contacts.getContactHeight(); // fractional number of contacts covering each pixel contacts_per_pixel = (graphHeight < 1) ? contact_height @@ -71,6 +74,25 @@ public class ContactGeometry return ci; } + /** + * return the cell containing given pixel + * + * @param pCentre + * @return range for pCEntre + */ + public contactInterval mapFor(int pCentre) + { + int pStart = Math.max(pCentre - pixels_step, 0); + int pEnd = Math.min(pStart + pixels_step, graphHeight); + int cStart = (int) Math.floor(pStart * contacts_per_pixel); + contactInterval ci = new contactInterval(cStart, + (int) Math.min(contact_height, + Math.ceil(cStart + (pixels_step) * contacts_per_pixel)), + pStart, pEnd); + + return ci; + } + public Iterator iterateOverContactIntervals( int graphHeight) { diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index c8a846c..ba3ef71 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -874,6 +874,52 @@ public class StructureSelectionManager } /** + * hack to highlight a range of positions at once on any structure views + * + * @param sequenceRef + * @param is + * - series of int start-end ranges as positions on sequenceRef + * @param i + * @param object + */ + public void highlightPositionsOn(SequenceI sequenceRef, int[][] is, + Object source) + { + boolean hasSequenceListeners = handlingVamsasMo + || !seqmappings.isEmpty(); + SearchResultsI results = null; + ArrayList listOfPositions = new ArrayList(); + for (int[] s_e : is) + { + for (int p = s_e[0]; p <= s_e[1]; listOfPositions.add(p++)) + ; + } + int seqpos[] = new int[listOfPositions.size()]; + int i = 0; + for (Integer p : listOfPositions) + { + seqpos[i++] = p; + } + + for (i = 0; i < listeners.size(); i++) + { + Object listener = listeners.elementAt(i); + if (listener == source) + { + // TODO listener (e.g. SeqPanel) is never == source (AlignViewport) + // Temporary fudge with SequenceListener.getVamsasSource() + continue; + } + if (listener instanceof StructureListener) + { + highlightStructure((StructureListener) listener, sequenceRef, + seqpos); + } + + } + } + + /** * Propagate mouseover of a single position in a structure * * @param pdbResNum