/*
* Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
* Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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
+ * 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
+ *
+ * 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 <http://www.gnu.org/licenses/>.
*/
package jalview.gui;
import java.util.*;
+import java.util.List;
import java.awt.*;
import java.awt.event.*;
import jalview.commands.*;
import jalview.datamodel.*;
+import jalview.io.SequenceAnnotationReport;
import jalview.schemes.*;
import jalview.structure.*;
/**
* DOCUMENT ME!
- *
+ *
* @author $author$
* @version $Revision: 1.130 $
*/
StringBuffer keyboardNo2;
java.net.URL linkImageURL;
-
+ private final SequenceAnnotationReport seqARep;
StringBuffer tooltipText = new StringBuffer("<html>");
String tmpString;
/**
* Creates a new SeqPanel object.
- *
+ *
* @param avp
* DOCUMENT ME!
* @param p
public SeqPanel(AlignViewport av, AlignmentPanel ap)
{
linkImageURL = getClass().getResource("/images/link.gif");
+ seqARep=new SequenceAnnotationReport(linkImageURL.toString());
ToolTipManager.sharedInstance().registerComponent(this);
ToolTipManager.sharedInstance().setInitialDelay(0);
ToolTipManager.sharedInstance().setDismissDelay(10000);
void setCursorPosition()
{
- SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(
+ SequenceI sequence = av.getAlignment().getSequenceAt(
seqCanvas.cursorY);
seqCanvas.cursorX = sequence.findIndex(getKeyboardNo1() - 1);
void setSelectionAreaAtCursor(boolean topLeft)
{
- SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(
+ SequenceI sequence = av.getAlignment().getSequenceAt(
seqCanvas.cursorY);
if (av.getSelectionGroup() != null)
editSequence(false, false, seqCanvas.cursorX);
endEditing();
}
-
+
void insertNucAtCursor(boolean group,String nuc){
groupEditing = group;
startseq = seqCanvas.cursorY;
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseReleased(MouseEvent evt)
{
mouseDragging = false;
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mousePressed(MouseEvent evt)
{
lastMousePress = evt.getPoint();
String lastMessage;
+ @Override
public void mouseOverSequence(SequenceI sequence, int index, int pos)
{
String tmp = sequence.hashCode() + " " + index + " " + pos;
lastMessage = tmp;
}
+ @Override
public void highlightSequence(SearchResults results)
{
if (av.followHighlight)
seqCanvas.highlightSearchResults(results);
}
+ @Override
public void updateColours(SequenceI seq, int index)
{
System.out.println("update the seqPanel colours");
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseMoved(MouseEvent evt)
{
if (editingSeqs)
SequenceFeature[] features = findFeaturesAtRes(
sequence.getDatasetSequence(),
rpos = sequence.findPosition(res));
- appendFeatures(tooltipText, linkImageURL.toString(), rpos, features,
+ seqARep.appendFeatures(tooltipText, rpos, features,
this.ap.seqPanel.seqCanvas.fr.minmax);
}
if (tooltipText.length() == 6) // <html></html>
return lastp = p;
}
- /**
- * appends the features at rpos to the given stringbuffer ready for display in
- * a tooltip
- *
- * @param tooltipText2
- * @param linkImageURL
- * @param rpos
- * @param features
- * TODO refactor to Jalview 'utilities' somehow.
- */
- public void appendFeatures(StringBuffer tooltipText2,
- String linkImageURL, int rpos, SequenceFeature[] features)
- {
- appendFeatures(tooltipText2, linkImageURL, rpos, features, null);
- }
-
- public void appendFeatures(StringBuffer tooltipText2, String string,
- int rpos, SequenceFeature[] features, Hashtable minmax)
- {
- String tmpString;
- if (features != null)
- {
- for (int i = 0; i < features.length; i++)
- {
- if (features[i].getType().equals("disulfide bond"))
- {
- if (features[i].getBegin() == rpos
- || features[i].getEnd() == rpos)
- {
- if (tooltipText2.length() > 6)
- {
- tooltipText2.append("<br>");
- }
- tooltipText2.append("disulfide bond " + features[i].getBegin()
- + ":" + features[i].getEnd());
- if (features[i].links != null)
- {
- tooltipText2.append(" <img src=\"" + linkImageURL + "\">");
- }
- }
- }
- else
- {
- if (tooltipText2.length() > 6)
- {
- tooltipText2.append("<br>");
- }
- // TODO: remove this hack to display link only features
- boolean linkOnly = features[i].getValue("linkonly") != null;
- if (!linkOnly)
- {
- tooltipText2.append(features[i].getType() + " ");
- if (rpos != 0)
- {
- // we are marking a positional feature
- tooltipText2.append(features[i].begin);
- }
- if (features[i].begin != features[i].end)
- {
- tooltipText2.append(" " + features[i].end);
- }
-
- if (features[i].getDescription() != null
- && !features[i].description.equals(features[i]
- .getType()))
- {
- tmpString = features[i].getDescription();
- String tmp2up=tmpString.toUpperCase();
- int startTag = tmp2up.indexOf("<HTML>");
- if (startTag > -1)
- {
- tmpString = tmpString.substring(startTag + 6);
- tmp2up = tmp2up.substring(startTag+6);
- }
- int endTag = tmp2up.indexOf("</BODY>");
- if (endTag > -1)
- {
- tmpString = tmpString.substring(0, endTag);
- tmp2up = tmp2up.substring(0, endTag);
- }
- endTag = tmp2up.indexOf("</HTML>");
- if (endTag > -1)
- {
- tmpString = tmpString.substring(0, endTag);
- }
-
- if (startTag > -1)
- {
- tooltipText2.append("; " + tmpString);
- }
- else
- {
- if (tmpString.indexOf("<") > -1
- || tmpString.indexOf(">") > -1)
- {
- // The description does not specify html is to
- // be used, so we must remove < > symbols
- tmpString = tmpString.replaceAll("<", "<");
- tmpString = tmpString.replaceAll(">", ">");
-
- tooltipText2.append("; ");
- tooltipText2.append(tmpString);
-
- }
- else
- {
- tooltipText2.append("; " + tmpString);
- }
- }
- }
- // check score should be shown
- if (features[i].getScore() != Float.NaN)
- {
- float[][] rng = (minmax == null) ? null : ((float[][]) minmax
- .get(features[i].getType()));
- if (rng != null && rng[0] != null && rng[0][0] != rng[0][1])
- {
- tooltipText2.append(" Score=" + features[i].getScore());
- }
- }
- if (features[i].getValue("status") != null)
- {
- String status = features[i].getValue("status").toString();
- if (status.length() > 0)
- {
- tooltipText2.append("; (" + features[i].getValue("status")
- + ")");
- }
- }
- }
- if (features[i].links != null)
- {
- tooltipText2.append(" <img src=\"" + linkImageURL + "\">");
- }
-
- }
- }
- }
- }
String lastTooltip;
/**
* Set status message in alignment panel
- *
+ *
* @param sequence
* aligned sequence object
* @param res
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void mouseDragged(MouseEvent evt)
{
if (mouseWheelPressed)
// but the sequence represents a group
if (sg == null)
{
- if (av.isHiddenRepSequence(seq))
+ if (!av.isHiddenRepSequence(seq))
{
endEditing();
return;
if (groupEditing)
{
- Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
+ List<SequenceI> vseqs = sg.getSequences(av.getHiddenRepSequences());
int g, groupSize = vseqs.size();
SequenceI[] groupSeqs = new SequenceI[groupSize];
for (g = 0; g < groupSeqs.length; g++)
{
- groupSeqs[g] = (SequenceI) vseqs.elementAt(g);
+ groupSeqs[g] = vseqs.get(g);
}
// drag to right
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
+ @Override
public void mouseEntered(MouseEvent e)
{
if (oldSeq < 0)
/**
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
+ @Override
public void mouseExited(MouseEvent e)
{
if (av.getWrapAlignment())
}
}
+ @Override
public void mouseClicked(MouseEvent evt)
{
SequenceGroup sg = null;
}
}
+ @Override
public void mouseWheelMoved(MouseWheelEvent e)
{
e.consume();
if (e.getWheelRotation() > 0)
{
- ap.scrollUp(false);
+ if (e.isShiftDown())
+ {
+ ap.scrollRight(true);
+
+ } else {
+ ap.scrollUp(false);
+ }
}
else
{
- ap.scrollUp(true);
+ if (e.isShiftDown())
+ {
+ ap.scrollRight(false);
+ } else {
+ ap.scrollUp(true);
+ }
}
// TODO Update tooltip for new position.
}
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
return;
}
- SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq);
+ SequenceI sequence = av.getAlignment().getSequenceAt(seq);
if ((sequence == null) || (res > sequence.getLength()))
{
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
{
if (stretchGroup.cs instanceof ClustalxColourScheme)
{
- ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
- stretchGroup.getSequences(av.getHiddenRepSequences()),
- stretchGroup.getWidth());
+ ((ClustalxColourScheme) stretchGroup.cs).alignmentChanged(
+ stretchGroup,av.getHiddenRepSequences());
}
if (stretchGroup.cs.conservationApplied())
/**
* DOCUMENT ME!
- *
+ *
* @param evt
* DOCUMENT ME!
*/
running = false;
}
+ @Override
public void run()
{
running = true;
/**
* modify current selection according to a received message.
*/
+ @Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
SelectionSource source)
{