X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqPanel.java;h=f476d419dc11cb34f3b6a467c44ac3973e0d0e19;hb=f2d38aaebf121e49be29cb19ae01f1c6a36fe7e0;hp=cce2ee0880e97b4c68e6467b6da71e1da75748ed;hpb=8d44c38e7028bcce53c0370dec67baa5d8d209c9;p=jalview.git diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index cce2ee0..f476d41 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -21,6 +21,7 @@ package jalview.gui; import jalview.api.AlignViewportI; +import jalview.bin.Cache; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; import jalview.commands.EditCommand.Edit; @@ -54,11 +55,12 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; /** @@ -509,6 +511,7 @@ public class SeqPanel extends JPanel implements MouseListener, void insertNucAtCursor(boolean group, String nuc) { + // TODO not called - delete? groupEditing = group; startseq = seqCanvas.cursorY; lastres = seqCanvas.cursorX; @@ -599,7 +602,7 @@ public class SeqPanel extends JPanel implements MouseListener, { lastMousePress = evt.getPoint(); - if (javax.swing.SwingUtilities.isMiddleMouseButton(evt)) + if (SwingUtilities.isMiddleMouseButton(evt)) { mouseWheelPressed = true; return; @@ -822,6 +825,20 @@ public class SeqPanel extends JPanel implements MouseListener, String lastTooltip; /** + * set when the current UI interaction has resulted in a change that requires + * overview shading to be recalculated. this could be changed to something + * more expressive that indicates what actually has changed, so selective + * redraws can be applied + */ + private boolean needOverviewUpdate = false; // TODO: refactor to avcontroller + + /** + * set if av.getSelectionGroup() refers to a group that is defined on the + * alignment view, rather than a transient selection + */ + private boolean editingDefinedGroup = false; // TODO: refactor to avcontroller or viewModel + + /** * Set status message in alignment panel * * @param sequence @@ -840,7 +857,8 @@ public class SeqPanel extends JPanel implements MouseListener, * Sequence number (if known), and sequence name. */ String seqno = seq == -1 ? "" : " " + (seq + 1); - text.append("Sequence" + seqno + " ID: " + sequence.getName()); + text.append("Sequence").append(seqno).append(" ID: ") + .append(sequence.getName()); String residue = null; /* @@ -1171,8 +1189,7 @@ public class SeqPanel extends JPanel implements MouseListener, { for (int j = 0; j < startres - lastres; j++) { - if (!jalview.util.Comparison.isGap(groupSeqs[g] - .getCharAt(fixedRight - j))) + if (!Comparison.isGap(groupSeqs[g].getCharAt(fixedRight - j))) { blank = false; break; @@ -1234,7 +1251,7 @@ public class SeqPanel extends JPanel implements MouseListener, continue; } - if (!jalview.util.Comparison.isGap(groupSeqs[g].getCharAt(j))) + if (!Comparison.isGap(groupSeqs[g].getCharAt(j))) { // Not a gap, block edit not valid endEditing(); @@ -1366,7 +1383,7 @@ public class SeqPanel extends JPanel implements MouseListener, for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { - if (jalview.util.Comparison.isGap(seq[s].getCharAt(blankColumn))) + if (Comparison.isGap(seq[s].getCharAt(blankColumn))) { // Theres a space, so break and insert the gap break; @@ -1566,10 +1583,12 @@ public class SeqPanel extends JPanel implements MouseListener, && (res < stretchGroup.getEndRes())) { av.setSelectionGroup(stretchGroup); + editingDefinedGroup = true; } else { stretchGroup = null; + editingDefinedGroup = false; } } else if (!stretchGroup.getSequences(null).contains(sequence) @@ -1588,6 +1607,7 @@ public class SeqPanel extends JPanel implements MouseListener, && (allGroups[i].getEndRes() >= res)) { stretchGroup = allGroups[i]; + editingDefinedGroup = true; break; } } @@ -1597,24 +1617,24 @@ public class SeqPanel extends JPanel implements MouseListener, } - if (javax.swing.SwingUtilities.isRightMouseButton(evt)) + if (evt.isPopupTrigger()) { List allFeatures = ap.getFeatureRenderer() .findFeaturesAtRes(sequence.getDatasetSequence(), sequence.findPosition(res)); - Vector links = new Vector(); + List links = new ArrayList(); for (SequenceFeature sf : allFeatures) { if (sf.links != null) { - for (int j = 0; j < sf.links.size(); j++) + for (String link : sf.links) { - links.addElement(sf.links.elementAt(j)); + links.add(link); } } } - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null, links); + PopupMenu pop = new PopupMenu(ap, null, links); pop.show(this, evt.getX(), evt.getY()); return; } @@ -1637,7 +1657,7 @@ public class SeqPanel extends JPanel implements MouseListener, sg.setEndRes(res); sg.addSequence(sequence, false); av.setSelectionGroup(sg); - + editingDefinedGroup = false; stretchGroup = sg; if (av.getConservationSelected()) @@ -1680,9 +1700,10 @@ public class SeqPanel extends JPanel implements MouseListener, { return; } - - stretchGroup.recalcConservation(); // always do this - annotation has own - // state + // always do this - annotation has own state + // but defer colourscheme update until hidden sequences are passed in + boolean vischange = stretchGroup.recalcConservation(true); + needOverviewUpdate |= vischange && editingDefinedGroup; if (stretchGroup.cs != null) { stretchGroup.cs.alignmentChanged(stretchGroup, @@ -1700,8 +1721,9 @@ public class SeqPanel extends JPanel implements MouseListener, } } PaintRefresher.Refresh(this, av.getSequenceSetId()); - ap.paintAlignment(true); - + ap.paintAlignment(needOverviewUpdate); + needOverviewUpdate =false; + editingDefinedGroup = false; changeEndRes = false; changeStartRes = false; stretchGroup = null; @@ -1755,6 +1777,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (res > (stretchGroup.getStartRes() - 1)) { stretchGroup.setEndRes(res); + needOverviewUpdate |= editingDefinedGroup; } } else if (changeStartRes) @@ -1762,6 +1785,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (res < (stretchGroup.getEndRes() + 1)) { stretchGroup.setStartRes(res); + needOverviewUpdate |= editingDefinedGroup; } } @@ -1795,6 +1819,7 @@ public class SeqPanel extends JPanel implements MouseListener, if (stretchGroup.getSequences(null).contains(nextSeq)) { stretchGroup.deleteSequence(seq, false); + needOverviewUpdate |= editingDefinedGroup; } else { @@ -1804,6 +1829,7 @@ public class SeqPanel extends JPanel implements MouseListener, } stretchGroup.addSequence(nextSeq, false); + needOverviewUpdate |= editingDefinedGroup; } } @@ -1945,28 +1971,28 @@ public class SeqPanel extends JPanel implements MouseListener, // do we want to thread this ? (contention with seqsel and colsel locks, I // suspect) - // rules are: colsel is copied if there is a real intersection between - // sequence selection + /* + * only copy colsel if there is a real intersection between + * sequence selection and this panel's alignment + */ boolean repaint = false; - boolean copycolsel = true; + boolean copycolsel = false; SequenceGroup sgroup = null; if (seqsel != null && seqsel.getSize() > 0) { if (av.getAlignment() == null) { - jalview.bin.Cache.log.warn("alignviewport av SeqSetId=" + Cache.log.warn("alignviewport av SeqSetId=" + av.getSequenceSetId() + " ViewId=" + av.getViewId() + " 's alignment is NULL! returning immediately."); return; } sgroup = seqsel.intersect(av.getAlignment(), (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null); - if ((sgroup == null || sgroup.getSize() == 0) - || (colsel == null || colsel.isEmpty())) + if ((sgroup != null && sgroup.getSize() > 0)) { - // don't copy columns if the region didn't intersect. - copycolsel = false; + copycolsel = true; } } if (sgroup != null && sgroup.getSize() > 0) @@ -2059,7 +2085,6 @@ public class SeqPanel extends JPanel implements MouseListener, ColumnSelection cs = MappingUtils.mapColumnSelection(colsel, sourceAv, av); av.setColumnSelection(cs); - av.isColSelChanged(true); PaintRefresher.Refresh(this, av.getSequenceSetId());