X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=b8f575f56f0729d65e9d32de1815b7de8fa94884;hb=c03d2649512cdc491a46dda1d1370273241b5253;hp=c168b7b8d527fd2cbb312bbba417b3e9ef70e85c;hpb=d053a3c980cf4318b9a19a255f9fc870e74de989;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index c168b7b..b8f575f 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,19 +1,22 @@ /* - * 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 + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 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. */ /* * Jalview - A Sequence Alignment Editor and Viewer @@ -35,29 +38,33 @@ */ package jalview.gui; -import java.util.*; - -import java.awt.*; - -import jalview.analysis.*; -import jalview.api.AlignCalcManagerI; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.analysis.NJTree; import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.api.OOMHandlerI; - -import jalview.bin.*; - -import jalview.datamodel.*; - -import jalview.schemes.*; +import jalview.bin.Cache; +import jalview.commands.CommandI; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.schemes.ColourSchemeProperty; +import jalview.schemes.UserColourScheme; import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.viewmodel.AlignmentViewport; -import jalview.workers.AlignCalcManager; -import jalview.workers.ConsensusThread; -import jalview.workers.ConservationThread; -import jalview.workers.StrucConsensusThread; +import jalview.ws.params.AutoCalcSetting; + +import java.awt.Color; +import java.awt.Container; +import java.awt.Font; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Stack; +import java.util.Vector; /** * DOCUMENT ME! @@ -65,10 +72,9 @@ import jalview.workers.StrucConsensusThread; * @author $author$ * @version $Revision: 1.141 $ */ -public class AlignViewport extends AlignmentViewport implements SelectionSource, VamsasSource, AlignViewportI +public class AlignViewport extends AlignmentViewport implements + SelectionSource, VamsasSource, AlignViewportI { - private static final int RIGHT_JUSTIFY = 1; - int startRes; int endRes; @@ -89,15 +95,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, boolean renderGaps = true; - boolean showSequenceFeatures = false; - - boolean showAnnotation = true; - - boolean colourAppliesToAllGroups = true; - - boolean conservationColourSelected = false; - - boolean abovePIDThreshold = false; + SequenceAnnotationOrder sortAnnotationsBy = null; int charHeight; @@ -111,10 +109,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, boolean seqNameItalics; - int threshold; - - int increment; - NJTree currentTree = null; boolean scaleAboveWrapped = false; @@ -127,15 +121,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, boolean cursorMode = false; - /** - * Keys are the feature types which are currently visible. Note: Values are - * not used! - */ - Hashtable featuresDisplayed = null; - - - boolean isDataset = false; - boolean antiAlias = false; Rectangle explodedPosition; @@ -144,20 +129,18 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, boolean gatherViewsHere = false; - Stack historyList = new Stack(); - - Stack redoList = new Stack(); + Stack historyList = new Stack(); - Hashtable sequenceColours; + Stack redoList = new Stack(); int thresholdTextColour = 0; Color textColour = Color.black; Color textColour2 = Color.white; + private boolean rightAlignIds = false; - boolean rightAlignIds = false; - + private AnnotationColumnChooser annotationColumnSelectionState; /** * Creates a new AlignViewport object. * @@ -293,9 +276,9 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, antiAlias = Cache.getDefault("ANTI_ALIAS", false); showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); - showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); + setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true)); - rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false); + setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false)); centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false); autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true); @@ -331,68 +314,20 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, { if (!alignment.isNucleotide()) { - conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than " + getConsPercGaps() - + "% gaps", new Annotation[1], 0f, 11f, - AlignmentAnnotation.BAR_GRAPH); - conservation.hasText = true; - conservation.autoCalculated = true; - - if (Cache.getDefault("SHOW_CONSERVATION", true)) - { - alignment.addAnnotation(conservation); - } - - if (Cache.getDefault("SHOW_QUALITY", true)) - { - quality = new AlignmentAnnotation("Quality", - "Alignment Quality based on Blosum62 scores", - new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH); - quality.hasText = true; - quality.autoCalculated = true; - - alignment.addAnnotation(quality); - } + showConservation = Cache.getDefault("SHOW_CONSERVATION", true); + showQuality = Cache.getDefault("SHOW_QUALITY", true); showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION", false); - - { - - } } showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true); showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false); - normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO", false); + normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO", + false); showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false); - // TODO: add menu option action that nulls or creates consensus object - // depending on if the user wants to see the annotation or not in a - // specific alignment - consensus = new AlignmentAnnotation("Consensus", "PID", - new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); - consensus.hasText = true; - consensus.autoCalculated = true; - - if (alignment.isNucleotide() && alignment.hasRNAStructure()) - { - strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID", - new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); - strucConsensus.hasText = true; - strucConsensus.autoCalculated = true; - } - - if (Cache.getDefault("SHOW_IDENTITY", true)) - { - alignment.addAnnotation(consensus); - // TODO: Make own if for structure - if (alignment.isNucleotide() && alignment.hasRNAStructure()) - { - alignment.addAnnotation(strucConsensus); - } - } - + showConsensus = Cache.getDefault("SHOW_IDENTITY", true); } - + initAutoAnnotation(); if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) { globalColourScheme = ColourSchemeProperty.getColour(alignment, @@ -411,28 +346,15 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, } } - wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false); - showUnconserved = jalview.bin.Cache.getDefault("SHOW_UNCONSERVED", - false); - sortByTree = jalview.bin.Cache.getDefault("SORT_BY_TREE", false); - followSelection = jalview.bin.Cache.getDefault("FOLLOW_SELECTIONS", - true); - } - - /** - * set the flag - * - * @param b - * features are displayed if true - */ - public void setShowSequenceFeatures(boolean b) - { - showSequenceFeatures = b; - } - - public boolean getShowSequenceFeatures() - { - return showSequenceFeatures; + wrapAlignment = Cache.getDefault("WRAP_ALIGNMENT", false); + showUnconserved = Cache.getDefault("SHOW_UNCONSERVED", false); + sortByTree = Cache.getDefault("SORT_BY_TREE", false); + followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true); + sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault( + Preferences.SORT_ANNOTATIONS, + SequenceAnnotationOrder.NONE.name())); + showAutocalculatedAbove = Cache.getDefault( + Preferences.SHOW_AUTOCALC_ABOVE, false); } /** @@ -485,50 +407,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, return sq; } - - /** - * GUI state - * - * @return true if conservation based shading is enabled - */ - public boolean getConservationSelected() - { - return conservationColourSelected; - } - - /** - * GUI state - * - * @param b - * enable conservation based shading - */ - public void setConservationSelected(boolean b) - { - conservationColourSelected = b; - } - - /** - * GUI state - * - * @return true if percent identity threshold is applied to shading - */ - public boolean getAbovePIDThreshold() - { - return abovePIDThreshold; - } - - /** - * GUI state - * - * - * @param b - * indicate if percent identity threshold is applied to shading - */ - public void setAbovePIDThreshold(boolean b) - { - abovePIDThreshold = b; - } - /** * DOCUMENT ME! * @@ -750,7 +628,7 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, Desktop.instance).removeMappings(alignment.getCodonFrames()); } this.alignment = align; - if (alignment!=null && alignment.getCodonFrames() != null) + if (alignment != null && alignment.getCodonFrames() != null) { StructureSelectionManager.getStructureSelectionManager( Desktop.instance).addMappings(alignment.getCodonFrames()); @@ -879,48 +757,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, /** * DOCUMENT ME! * - * @param thresh - * DOCUMENT ME! - */ - public void setThreshold(int thresh) - { - threshold = thresh; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getThreshold() - { - return threshold; - } - - /** - * DOCUMENT ME! - * - * @param inc - * DOCUMENT ME! - */ - public void setIncrement(int inc) - { - increment = inc; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getIncrement() - { - return increment; - } - - /** - * DOCUMENT ME! - * * @return DOCUMENT ME! */ public ColumnSelection getColumnSelection() @@ -952,27 +788,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, /** * DOCUMENT ME! * - * @param b - * DOCUMENT ME! - */ - public void setColourAppliesToAllGroups(boolean b) - { - colourAppliesToAllGroups = b; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public boolean getColourAppliesToAllGroups() - { - return colourAppliesToAllGroups; - } - - /** - * DOCUMENT ME! - * * @return DOCUMENT ME! */ public boolean getShowJVSuffix() @@ -996,27 +811,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, * * @return DOCUMENT ME! */ - public boolean getShowAnnotation() - { - return showAnnotation; - } - - /** - * DOCUMENT ME! - * - * @param b - * DOCUMENT ME! - */ - public void setShowAnnotation(boolean b) - { - showAnnotation = b; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ public boolean getScaleAboveWrapped() { return scaleAboveWrapped; @@ -1075,7 +869,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, scaleRightWrapped = b; } - public void setDataset(boolean b) { isDataset = b; @@ -1086,8 +879,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, return isDataset; } - - public boolean getShowHiddenMarkers() { return showHiddenMarkers; @@ -1098,35 +889,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, showHiddenMarkers = show; } - public Color getSequenceColour(SequenceI seq) - { - if (sequenceColours == null || !sequenceColours.containsKey(seq)) - { - return Color.white; - } - else - { - return (Color) sequenceColours.get(seq); - } - } - - public void setSequenceColour(SequenceI seq, Color col) - { - if (sequenceColours == null) - { - sequenceColours = new Hashtable(); - } - - if (col == null) - { - sequenceColours.remove(seq); - } - else - { - sequenceColours.put(seq, col); - } - } - /** * returns the visible column regions of the alignment * @@ -1159,9 +921,12 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, */ public long[] getUndoRedoHash() { + // TODO: JAL-1126 if (historyList == null || redoList == null) + { return new long[] { -1, -1 }; + } return new long[] { historyList.hashCode(), this.redoList.hashCode() }; } @@ -1207,27 +972,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, centreColumnLabels = centrecolumnlabels; } - public void updateSequenceIdColours() - { - Vector groups = alignment.getGroups(); - if (sequenceColours == null) - { - sequenceColours = new Hashtable(); - } - for (int ig = 0, igSize = groups.size(); ig < igSize; ig++) - { - SequenceGroup sg = (SequenceGroup) groups.elementAt(ig); - if (sg.idColour != null) - { - Vector sqs = sg.getSequences(getHiddenRepSequences()); - for (int s = 0, sSize = sqs.size(); s < sSize; s++) - { - sequenceColours.put(sqs.elementAt(s), sg.idColour); - } - } - } - } - /** * enable or disable the display of Database Cross References in the sequence * ID tooltip @@ -1310,8 +1054,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, return followSelection; } - boolean showSeqFeaturesHeight; - public void sendSelection() { jalview.structure.StructureSelectionManager @@ -1320,16 +1062,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, new ColumnSelection(getColumnSelection()), this); } - public void setShowSequenceFeaturesHeight(boolean selected) - { - showSeqFeaturesHeight = selected; - } - - public boolean getShowSequenceFeaturesHeight() - { - return showSeqFeaturesHeight; - } - /** * return the alignPanel containing the given viewport. Use this to get the * components currently handling the given viewport. @@ -1419,7 +1151,9 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, Vector pdbs = alignment.getSequenceAt(i).getDatasetSequence() .getPDBId(); if (pdbs == null) + { continue; + } SequenceI sq; for (int p = 0; p < pdbs.size(); p++) { @@ -1427,7 +1161,9 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, if (p1.getId().equals(pdb.getId())) { if (!seqs.contains(sq = alignment.getSequenceAt(i))) + { seqs.add(sq); + } continue; } @@ -1438,7 +1174,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, return seqvectors.toArray(new SequenceI[seqvectors.size()][]); } - public boolean isNormaliseSequenceLogo() { return normaliseSequenceLogo; @@ -1449,13 +1184,81 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource, normaliseSequenceLogo = state; } - /** * - * @return true if alignment characters should be displayed + * @return true if alignment characters should be displayed */ public boolean isValidCharWidth() { return validCharWidth; } + + private Hashtable calcIdParams = new Hashtable(); + + private boolean showAutocalculatedAbove; + + public AutoCalcSetting getCalcIdSettingsFor(String calcId) + { + return calcIdParams.get(calcId); + } + + public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings, + boolean needsUpdate) + { + calcIdParams.put(calcId, settings); + // TODO: create a restart list to trigger any calculations that need to be + // restarted after load + // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass()) + if (needsUpdate) + { + Cache.log.debug("trigger update for " + calcId); + } + } + + protected SequenceAnnotationOrder getSortAnnotationsBy() + { + return sortAnnotationsBy; + } + + protected void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy) + { + this.sortAnnotationsBy = sortAnnotationsBy; + } + + protected boolean isShowAutocalculatedAbove() + { + return showAutocalculatedAbove; + } + + protected void setShowAutocalculatedAbove(boolean showAutocalculatedAbove) + { + this.showAutocalculatedAbove = showAutocalculatedAbove; + } + + + public boolean isShowAnnotation() + { + return super.isShowAnnotation(); + } + + public boolean isRightAlignIds() + { + return rightAlignIds; + } + + public void setRightAlignIds(boolean rightAlignIds) + { + this.rightAlignIds = rightAlignIds; + } + + public AnnotationColumnChooser getAnnotationColumnSelectionState() + { + return annotationColumnSelectionState; + } + + public void setAnnotationColumnSelectionState( + AnnotationColumnChooser currentAnnotationColumnSelectionState) + { + this.annotationColumnSelectionState = currentAnnotationColumnSelectionState; + } }