X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignmentPanel.java;h=c74914f80f0f37e36f7ccca5ef91c258718a279d;hb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;hp=cd1d20aabbcfbc9d4152d33d636961e77b3c793e;hpb=23b954d9c84a16a7dc12ab331a01e44d5e0e5cd4;p=jalview.git diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index cd1d20a..c74914f 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -1,28 +1,44 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * 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. + * 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 . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.appletgui; -import java.awt.*; -import java.awt.event.*; - +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.Scrollbar; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; + +import jalview.analysis.AnnotationSorter; +import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; -import jalview.datamodel.*; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SearchResults; +import jalview.datamodel.SequenceI; import jalview.structure.StructureSelectionManager; public class AlignmentPanel extends Panel implements AdjustmentListener, @@ -86,7 +102,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH); alabels = new AnnotationLabels(this); - setAnnotationVisible(av.showAnnotation); + setAnnotationVisible(av.isShowAnnotation()); idPanelHolder.add(idPanel, BorderLayout.CENTER); idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); @@ -139,6 +155,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, }); } + @Override + public AlignViewportI getAlignViewport() + { + return av; + } public SequenceRenderer getSequenceRenderer() { return seqPanel.seqCanvas.sr; @@ -176,8 +197,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, idPanel.idCanvas.image = null; FontMetrics fm = getFontMetrics(av.getFont()); - scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent())); - idwidthAdjuster.setSize(new Dimension(10, av.charHeight + scalePanel.setSize(new Dimension(10, av.getCharHeight() + + fm.getDescent())); + idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight() + fm.getDescent())); av.updateSequenceIdColours(); annotationPanel.image = null; @@ -361,7 +383,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, { start = ostart; } - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { /* * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv = @@ -435,11 +457,16 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, public void setAnnotationVisible(boolean b) { - if (!av.wrapAlignment) + if (!av.getWrapAlignment()) { annotationSpaceFillerHolder.setVisible(b); annotationPanelHolder.setVisible(b); } + else + { + annotationSpaceFillerHolder.setVisible(false); + annotationPanelHolder.setVisible(false); + } validate(); repaint(); } @@ -454,7 +481,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, // this is called after loading new annotation onto alignment if (alignFrame.getSize().height == 0) { - System.out.println("NEEDS FIXING"); + System.out + .println("adjustAnnotationHeight frame size zero NEEDS FIXING"); } fontChanged(); validateAnnotationDimensions(true); @@ -487,10 +515,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, if (adjustPanelHeight) { - // NOTE: this logic is different in the application. Need a better algorithm to define behaviour + // NOTE: this logic is different in the application. Need a better + // algorithm to define behaviour // sets initial preferred height // try and set height according to alignment - float sscaling = (float) ((av.getCharHeight() * av.getAlignment().getHeight())/(1.0*mheight)); + float sscaling = (float) ((av.getCharHeight() * av.getAlignment() + .getHeight()) / (1.0 * mheight)); if (sscaling > 0.5) { // if the alignment is too big then @@ -499,7 +529,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } else { - // otherwise just set the panel so that one row of sequence is visible + // otherwise just set the panel so that one row of sequence is visible height = -av.getCharHeight() * 1 + (int) (seqandannot * (1 - sscaling)); } @@ -518,7 +548,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, alabels.setSize(new Dimension(e.width, height)); annotationSpaceFillerHolder.setSize(new Dimension(e.width, height)); annotationPanelHolder.setSize(new Dimension(d.width, height)); - seqPanelHolder.setSize(d.width, seqandannot - height); + // seqPanelHolder.setSize(d.width, seqandannot - height); seqPanel.seqCanvas .setSize(d.width, seqPanel.seqCanvas.getSize().height); int s = apvscroll.getValue(); @@ -527,8 +557,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, s = 0; } apvscroll.setValues(s, height, 0, mheight); - annotationPanel.setScrollOffset(apvscroll.getValue()); - alabels.setScrollOffset(apvscroll.getValue()); + annotationPanel.setScrollOffset(apvscroll.getValue(), false); + alabels.setScrollOffset(apvscroll.getValue(), false); } public void setWrapAlignment(boolean wrap) @@ -545,7 +575,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, annotationPanelHolder.setVisible(false); annotationSpaceFillerHolder.setVisible(false); } - else if (av.showAnnotation) + else if (av.isShowAnnotation()) { annotationPanelHolder.setVisible(true); annotationSpaceFillerHolder.setVisible(true); @@ -556,6 +586,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, fontChanged(); // This is so that the scalePanel is resized correctly validate(); + sequenceHolderPanel.validate(); repaint(); } @@ -626,8 +657,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } ; - hextent = seqPanel.seqCanvas.getSize().width / av.charWidth; - vextent = seqPanel.seqCanvas.getSize().height / av.charHeight; + hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth(); + vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight(); if (hextent > width) { @@ -672,7 +703,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, av.setEndSeq(endSeq); av.setStartRes(x); - av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) - 1); + av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av + .getCharWidth())) - 1); hscroll.setValues(x, hextent, 0, width); vscroll.setValues(y, vextent, 0, height); @@ -692,8 +724,8 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, if (evt == null || evt.getSource() == apvscroll) { - annotationPanel.setScrollOffset(apvscroll.getValue()); - alabels.setScrollOffset(apvscroll.getValue()); + annotationPanel.setScrollOffset(apvscroll.getValue(), false); + alabels.setScrollOffset(apvscroll.getValue(), false); // annotationPanel.image=null; // alabels.image=null; // alabels.repaint(); @@ -754,7 +786,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, seqPanel.seqCanvas.fastPaint(scrollX, scrollY); scalePanel.repaint(); - if (av.getShowAnnotation()) + if (av.isShowAnnotation()) { annotationPanel.fastPaint(av.getStartRes() - oldX); } @@ -770,8 +802,15 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, av.endSeq); } + /** + * Repaint the alignment and annotations, and, optionally, any overview window + */ public void paintAlignment(boolean updateOverview) { + final AnnotationSorter sorter = new AnnotationSorter(getAlignment(), + av.isShowAutocalculatedAbove()); + sorter.sort(getAlignment().getAlignmentAnnotation(), + av.getSortAnnotationsBy()); repaint(); if (updateOverview) @@ -823,12 +862,18 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, setScrollValues(av.getStartRes(), av.getStartSeq()); } - alabels.repaint(); - seqPanel.seqCanvas.repaint(); - scalePanel.repaint(); - annotationPanel.repaint(); idPanel.idCanvas.repaint(); + if (!av.getWrapAlignment()) + { + if (av.isShowAnnotation()) + { + alabels.repaint(); + annotationPanel.repaint(); + } + scalePanel.repaint(); + } + } protected Panel sequenceHolderPanel = new Panel(); @@ -955,6 +1000,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } @Override + public String getViewName() + { + return getName(); + } + + @Override public StructureSelectionManager getStructureSelectionManager() { return StructureSelectionManager