From: janengelhardt Date: Wed, 20 Jul 2011 12:30:09 +0000 (+0200) Subject: JAL-842; Implement transmitting of Jalview Sequence highlights to X-Git-Tag: Jalview_2_9~576^2~24 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a0a45f042ee77368a0ff6c82caccb1b93d9e0f72;p=jalview.git JAL-842; Implement transmitting of Jalview Sequence highlights to Varna Change-Id: I8e1fbc375cdcec6cf36a46cdac56800740c42180 --- diff --git a/src/jalview/gui/AppVarna.java b/src/jalview/gui/AppVarna.java index 81ea76c..7617574 100644 --- a/src/jalview/gui/AppVarna.java +++ b/src/jalview/gui/AppVarna.java @@ -19,6 +19,7 @@ package jalview.gui; import java.util.*; import java.awt.*; + import javax.swing.*; import javax.swing.event.*; @@ -38,12 +39,13 @@ import fr.orsay.lri.varna.exceptions.ExceptionNonEqualLength; import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses; import fr.orsay.lri.varna.interfaces.InterfaceVARNAListener; import fr.orsay.lri.varna.models.VARNAConfig; +import fr.orsay.lri.varna.models.annotations.HighlightRegionAnnotation; import fr.orsay.lri.varna.models.rna.ModeleBaseNucleotide; import fr.orsay.lri.varna.models.rna.ModeleStyleBP; import fr.orsay.lri.varna.models.rna.RNA; -public class AppVarna extends JInternalFrame implements InterfaceVARNAListener// implements Runnable,SequenceStructureBinding, ViewSetProvider +public class AppVarna extends JInternalFrame implements InterfaceVARNAListener,SecondaryStructureListener// implements Runnable,SequenceStructureBinding, ViewSetProvider { AppVarnaBinding vab; @@ -52,12 +54,14 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener// public String name; + public StructureSelectionManager ssm; + /*public AppVarna(){ vab = new AppVarnaBinding(); initVarna(); }*/ - public AppVarna(String seq,String struc,String name){ + public AppVarna(String seq,String struc,String name,AlignmentPanel ap){ ArrayList rnaList = new ArrayList(); RNA rna1 = new RNA(name); try { @@ -76,7 +80,9 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener// //vab = new AppVarnaBinding(seq,struc); //System.out.println("Hallo: "+name); this.name=name; - initVarna(); + initVarna(); + ssm = ap.getStructureSelectionManager(); + ssm.addStructureViewerListener(this); } public void initVarna(){ @@ -167,7 +173,6 @@ public void onLayoutChanged() { @Override public void onUINewStructure(VARNAConfig v, RNA r) { - //TODO _rnaList.add(v, r,"",true); // TODO Auto-generated method stub } @@ -177,6 +182,30 @@ public void onWarningEmitted(String s) { // TODO Auto-generated method stub } - +/** + * If a mouseOver event from the AlignmentPanel + * is noticed the currently selected RNA in the + * VARNA window is highlighted at the specific position. + * To be able to remove it before the next highlight + * it is saved in _lastHighlight + */ +private HighlightRegionAnnotation _lastHighlight; +@Override +public void mouseOverSequence(SequenceI sequence, int index) { + // TODO Auto-generated method stub + RNA rna=vab.getSelectedRNA(); + rna.removeHighlightRegion(_lastHighlight); + + HighlightRegionAnnotation highlight = new HighlightRegionAnnotation(rna.getBasesBetween(index,index)); + rna.addHighlightRegion(highlight); + _lastHighlight=highlight; + vab.updateSelectedRNA(rna); +} + +@Override +public void mouseOverStructure(int atomIndex, String strInfo) { + // TODO Auto-generated method stub + +} } diff --git a/src/jalview/gui/AppVarnaBinding.java b/src/jalview/gui/AppVarnaBinding.java index c235fc1..51819fa 100644 --- a/src/jalview/gui/AppVarnaBinding.java +++ b/src/jalview/gui/AppVarnaBinding.java @@ -221,7 +221,6 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple } } }); - _rnaList = new BackupHolder(dlm,_sideList); try { @@ -334,6 +333,23 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple public JPanel getListPanel(){ return _listPanel; } + + /** + * TODO: Is it effective to transfer the whole RNA? + * @return Currently selected RNA + */ + public RNA getSelectedRNA(){ + return _rnaList.getElementAt(_sideList.getSelectedIndex()).rna; + } + + /** + * Substitute currently selected RNA with the edited one + * @param rnaEdit + */ + public void updateSelectedRNA(RNA rnaEdit){ + vp.repaint(); + vp.showRNA(rnaEdit); + } /* private void RNAPanelDemoInit() diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index a4808cf..82ce835 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -282,7 +282,7 @@ public class PopupMenu extends JPopupMenu { System.out.println("Call Varna "+seq.getSequenceAsString()+" "+seq.getName()); //TODO: VARNA does'nt print gaps in the sequence - new AppVarna(seq.getSequenceAsString(),rnastrucF,seq.getName()); + new AppVarna(seq.getSequenceAsString(),rnastrucF,seq.getName(),ap); } }); viewStructureMenu.add(menuItem); diff --git a/src/jalview/structure/SecondaryStructureListener.java b/src/jalview/structure/SecondaryStructureListener.java new file mode 100644 index 0000000..fe546e4 --- /dev/null +++ b/src/jalview/structure/SecondaryStructureListener.java @@ -0,0 +1,27 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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 . + */ +package jalview.structure; + +import jalview.datamodel.*; + +public interface SecondaryStructureListener +{ + public void mouseOverSequence(SequenceI sequence, int index); + public void mouseOverStructure(int atomIndex, String strInfo); + +} diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index c4dda8b..880f72a 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -509,6 +509,9 @@ public class StructureSelectionManager ((VamsasListener) listeners.elementAt(i)).mouseOver(seq, indexpos, source); } + else if(listeners.elementAt(i) instanceof SecondaryStructureListener){ + ((SecondaryStructureListener) listeners.elementAt(i)).mouseOverSequence(seq,indexpos); + } } } }