From e70614203293e8f04d7640729851725a763ae130 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sat, 22 Oct 2022 12:40:35 +0100 Subject: [PATCH] =?utf8?q?JAL-2349=20JAL-3855=20highlight=20residues=20assoc?= =?utf8?q?iated=20with=20elements=20under=20mouse=20-=20Jmol=20doesn=E2=80=99?= =?utf8?q?t=20like=20highlighting=20many=20residues=20at=20once=20this=20way?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/AnnotationPanel.java | 12 ++--- src/jalview/renderer/ContactGeometry.java | 22 ++++++++++ .../structure/StructureSelectionManager.java | 46 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 5 deletions(-) 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 -- 1.7.10.2