X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignViewport.java;h=0dcd5435597d10490726874fdff848d8710912b8;hb=567c2595554096f10feab130153f97286f3f7d80;hp=2d3800879e1ddfef2a95c0a6b95b99978d1124f4;hpb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;p=jalview.git diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 2d38008..0dcd543 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -20,43 +20,39 @@ */ package jalview.appletgui; -import java.awt.Font; - -import jalview.analysis.NJTree; +import jalview.analysis.TreeModel; import jalview.api.AlignViewportI; +import jalview.api.FeatureSettingsModelI; import jalview.bin.JalviewLite; import jalview.commands.CommandI; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.renderer.ResidueShader; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; -import jalview.structure.CommandListener; import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.ViewportRanges; + +import java.awt.Font; public class AlignViewport extends AlignmentViewport implements - AlignViewportI, SelectionSource, VamsasSource, CommandListener + SelectionSource { - int startRes; - - int endRes; - - int startSeq; - - int endSeq; - boolean cursorMode = false; Font font = new Font("SansSerif", Font.PLAIN, 10); boolean validCharWidth = true; - NJTree currentTree = null; + TreeModel currentTree = null; public jalview.bin.JalviewLite applet; @@ -64,6 +60,7 @@ public class AlignViewport extends AlignmentViewport implements private AnnotationColumnChooser annotationColumnSelectionState; + @Override public void finalize() { applet = null; @@ -78,12 +75,10 @@ public class AlignViewport extends AlignmentViewport implements calculator = new jalview.workers.AlignCalcManager(); this.applet = applet; alignment = al; + ranges = new ViewportRanges(this.alignment); // we always pad gaps this.setPadGaps(true); - this.startRes = 0; - this.endRes = al.getWidth() - 1; - this.startSeq = 0; - this.endSeq = al.getHeight() - 1; + if (applet != null) { // get the width and height scaling factors if they were specified @@ -103,7 +98,7 @@ public class AlignViewport extends AlignmentViewport implements + widthScale + "). Ignoring."); widthScale = 1; } - if (applet.debug) + if (JalviewLite.debug) { System.err .println("Alignment character width scaling factor is now " @@ -126,7 +121,7 @@ public class AlignViewport extends AlignmentViewport implements + heightScale + "). Ignoring."); heightScale = 1; } - if (applet.debug) + if (JalviewLite.debug) { System.err .println("Alignment character height scaling factor is now " @@ -157,6 +152,9 @@ public class AlignViewport extends AlignmentViewport implements setShowUnconserved(applet.getDefaultParameter("showUnconserved", getShowUnconserved())); + setScaleProteinAsCdna(applet.getDefaultParameter( + "scaleProteinAsCdna", isScaleProteinAsCdna())); + String param = applet.getParameter("upperCase"); if (param != null) { @@ -167,9 +165,9 @@ public class AlignViewport extends AlignmentViewport implements } sortByTree = applet.getDefaultParameter("sortByTree", sortByTree); - followHighlight = applet.getDefaultParameter("automaticScrolling", - followHighlight); - followSelection = followHighlight; + setFollowHighlight(applet.getDefaultParameter("automaticScrolling", + isFollowHighlight())); + followSelection = isFollowHighlight(); showSequenceLogo = applet.getDefaultParameter("showSequenceLogo", showSequenceLogo); @@ -191,8 +189,13 @@ public class AlignViewport extends AlignmentViewport implements if (applet != null) { - String colour = applet.getParameter("defaultColour"); - + String colour = al.isNucleotide() ? applet + .getParameter("defaultColourNuc") : applet + .getParameter("defaultColourProt"); + if (colour == null) + { + colour = applet.getParameter("defaultColour"); + } if (colour == null) { colour = applet.getParameter("userDefinedColour"); @@ -204,18 +207,19 @@ public class AlignViewport extends AlignmentViewport implements if (colour != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - colour); - if (globalColourScheme != null) + residueShading = new ResidueShader( + ColourSchemeProperty.getColourScheme(alignment, colour)); + if (residueShading != null) { - globalColourScheme.setConsensus(hconsensus); + residueShading.setConsensus(hconsensus); } } if (applet.getParameter("userDefinedColour") != null) { - ((UserColourScheme) globalColourScheme).parseAppletParameter(applet - .getParameter("userDefinedColour")); + residueShading = new ResidueShader( + new UserColourScheme( + applet.getParameter("userDefinedColour"))); } } initAutoAnnotation(); @@ -259,64 +263,6 @@ public class AlignViewport extends AlignmentViewport implements return sq; } - public int getStartRes() - { - return startRes; - } - - public int getEndRes() - { - return endRes; - } - - public int getStartSeq() - { - return startSeq; - } - - public void setStartRes(int res) - { - this.startRes = res; - } - - public void setStartSeq(int seq) - { - this.startSeq = seq; - } - - public void setEndRes(int res) - { - if (res > alignment.getWidth() - 1) - { - // log.System.out.println(" Corrected res from " + res + " to maximum " + - // (alignment.getWidth()-1)); - res = alignment.getWidth() - 1; - } - if (res < 0) - { - res = 0; - } - this.endRes = res; - } - - public void setEndSeq(int seq) - { - if (seq > alignment.getHeight()) - { - seq = alignment.getHeight(); - } - if (seq < 0) - { - seq = 0; - } - this.endSeq = seq; - } - - public int getEndSeq() - { - return endSeq; - } - java.awt.Frame nullFrame; protected FeatureSettings featureSettings = null; @@ -349,23 +295,21 @@ public class AlignViewport extends AlignmentViewport implements return font; } - public void resetSeqLimits(int height) { - setEndSeq(height / getCharHeight()); + ranges.setEndSeq(height / getCharHeight()); } - public void setCurrentTree(NJTree tree) + public void setCurrentTree(TreeModel tree) { currentTree = tree; } - public NJTree getCurrentTree() + public TreeModel getCurrentTree() { return currentTree; } - boolean centreColumnLabels; public boolean getCentreColumnLabels() @@ -373,13 +317,6 @@ public class AlignViewport extends AlignmentViewport implements return centreColumnLabels; } - public boolean followHighlight = true; - - public boolean getFollowHighlight() - { - return followHighlight; - } - public boolean followSelection = true; /** @@ -391,11 +328,12 @@ public class AlignViewport extends AlignmentViewport implements return followSelection; } + @Override public void sendSelection() { getStructureSelectionManager().sendSelection( - new SequenceGroup(getSelectionGroup()), - new ColumnSelection(getColumnSelection()), this); + new SequenceGroup(getSelectionGroup()), + new ColumnSelection(getColumnSelection()), this); } /** @@ -411,39 +349,7 @@ public class AlignViewport extends AlignmentViewport implements .getStructureSelectionManager(applet); } - /** - * synthesize a column selection if none exists so it covers the given - * selection group. if wholewidth is false, no column selection is made if the - * selection group covers the whole alignment width. - * - * @param sg - * @param wholewidth - */ - public void expandColSelection(SequenceGroup sg, boolean wholewidth) - { - int sgs, sge; - if (sg != null - && (sgs = sg.getStartRes()) >= 0 - && sg.getStartRes() <= (sge = sg.getEndRes()) - && (colSel == null || colSel.getSelected() == null || colSel - .getSelected().size() == 0)) - { - if (!wholewidth && alignment.getWidth() == (1 + sge - sgs)) - { - // do nothing - return; - } - if (colSel == null) - { - colSel = new ColumnSelection(); - } - for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++) - { - colSel.addElement(cspos); - } - } - } - + @Override public boolean isNormaliseSequenceLogo() { return normaliseSequenceLogo; @@ -458,6 +364,7 @@ public class AlignViewport extends AlignmentViewport implements * * @return true if alignment characters should be displayed */ + @Override public boolean isValidCharWidth() { return validCharWidth; @@ -511,4 +418,43 @@ public class AlignViewport extends AlignmentViewport implements return this; } + /** + * If this viewport has a (Protein/cDNA) complement, then scroll the + * complementary alignment to match this one. + */ + public void scrollComplementaryAlignment(AlignmentPanel complementPanel) + { + if (complementPanel == null) + { + return; + } + + /* + * Populate a SearchResults object with the mapped location to scroll to. If + * there is no complement, or it is not following highlights, or no mapping + * is found, the result will be empty. + */ + SearchResultsI sr = new SearchResults(); + int seqOffset = findComplementScrollTarget(sr); + if (!sr.isEmpty()) + { + complementPanel.setFollowingComplementScroll(true); + complementPanel.scrollToCentre(sr, seqOffset); + } + } + + /** + * Applies the supplied feature settings descriptor to currently known + * features. This supports an 'initial configuration' of feature colouring + * based on a preset or user favourite. This may then be modified in the usual + * way using the Feature Settings dialogue. + * + * @param featureSettings + */ + @Override + public void applyFeaturesStyle(FeatureSettingsModelI featureSettings) + { + // TODO implement for applet + } + }