X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fappletgui%2FAlignViewport.js;h=1d890fc88d9943490bab65175855fca3225fe247;hp=8ea8971638cae0d2138408724c48a91963d290d1;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/appletgui/AlignViewport.js b/bin/jalview/appletgui/AlignViewport.js index 8ea8971..1d890fc 100644 --- a/bin/jalview/appletgui/AlignViewport.js +++ b/bin/jalview/appletgui/AlignViewport.js @@ -1,229 +1,229 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.structure.CommandListener", "$.SelectionSource", "$.VamsasSource", "jalview.viewmodel.AlignmentViewport", "java.awt.Font"], "jalview.appletgui.AlignViewport", ["awt2swing.Frame", "jalview.api.AlignViewportI", "jalview.bin.JalviewLite", "jalview.datamodel.ColumnSelection", "$.SearchResults", "$.Sequence", "$.SequenceGroup", "jalview.schemes.ColourSchemeProperty", "jalview.structure.StructureSelectionManager", "jalview.util.Platform", "jalview.workers.AlignCalcManager", "java.lang.Float", "$.StringBuilder"], function () { -c$ = Clazz.decorateAsClass (function () { -this.cursorMode = false; -this.font = null; -this.validCharWidth = true; -this.currentTree = null; -this.applet = null; -this.MAC = false; -this.annotationColumnSelectionState = null; -this.nullFrame = null; -this.featureSettings = null; -this.heightScale = 1; -this.widthScale = 1; -this.centreColumnLabels = false; -this.followSelection = true; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AlignViewport", jalview.viewmodel.AlignmentViewport, [jalview.structure.SelectionSource, jalview.structure.VamsasSource, jalview.structure.CommandListener]); -Clazz.prepareFields (c$, function () { -this.font = new java.awt.Font ("SansSerif", 0, 10); -}); -Clazz.overrideMethod (c$, "finalize", -function () { -this.applet = null; -this.quality = null; -this.alignment = null; -this.colSel = null; -}); -Clazz.makeConstructor (c$, -function (al, applet) { -Clazz.superConstructor (this, jalview.appletgui.AlignViewport); -this.calculator = new jalview.workers.AlignCalcManager (); -this.applet = applet; -this.alignment = al; -this.setPadGaps (true); -this.startRes = 0; -this.endRes = al.getWidth () - 1; -this.startSeq = 0; -this.endSeq = al.getHeight () - 1; -if (applet != null) { -var param = applet.widthScale; -if (param != null) { -try { -this.widthScale = new Float (param).floatValue (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -if (this.widthScale <= 1.0) { -System.err.println ("Invalid alignment character width scaling factor (" + this.widthScale + "). Ignoring."); -this.widthScale = 1; -}if (jalview.bin.JalviewLite.debug) { -System.err.println ("Alignment character width scaling factor is now " + this.widthScale); -}}param = applet.heightScale; -if (param != null) { -try { -this.heightScale = new Float (param).floatValue (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -if (this.heightScale <= 1.0) { -System.err.println ("Invalid alignment character height scaling factor (" + this.heightScale + "). Ignoring."); -this.heightScale = 1; -}if (jalview.bin.JalviewLite.debug) { -System.err.println ("Alignment character height scaling factor is now " + this.heightScale); -}}}this.setFont (this.font); -this.MAC = jalview.util.Platform.isAMac (); -if (applet != null) { -this.setShowJVSuffix (applet.getDefaultParameter ("showFullId", this.getShowJVSuffix ())); -this.setShowAnnotation (applet.getDefaultParameter ("showAnnotation", this.isShowAnnotation ())); -this.showConservation = applet.getDefaultParameter ("showConservation", this.showConservation); -this.showQuality = applet.getDefaultParameter ("showQuality", this.showQuality); -this.showConsensus = applet.getDefaultParameter ("showConsensus", this.showConsensus); -this.setShowUnconserved (applet.getDefaultParameter ("showUnconserved", this.getShowUnconserved ())); -this.setScaleProteinAsCdna (applet.getDefaultParameter ("scaleProteinAsCdna", this.isScaleProteinAsCdna ())); -var param = applet.upperCase; -if (param != null) { -if (param.equalsIgnoreCase ("bold")) { -this.setUpperCasebold (true); -}}this.sortByTree = applet.getDefaultParameter ("sortByTree", this.sortByTree); -this.setFollowHighlight (applet.getDefaultParameter ("automaticScrolling", this.isFollowHighlight ())); -this.followSelection = this.isFollowHighlight (); -this.showSequenceLogo = applet.getDefaultParameter ("showSequenceLogo", this.showSequenceLogo); -this.normaliseSequenceLogo = applet.getDefaultParameter ("normaliseSequenceLogo", applet.getDefaultParameter ("normaliseLogo", this.normaliseSequenceLogo)); -this.showGroupConsensus = applet.getDefaultParameter ("showGroupConsensus", this.showGroupConsensus); -this.showGroupConservation = applet.getDefaultParameter ("showGroupConservation", this.showGroupConservation); -this.showConsensusHistogram = applet.getDefaultParameter ("showConsensusHistogram", this.showConsensusHistogram); -}if (applet != null) { -var colour = applet.defaultColour; -if (colour == null) { -colour = applet.userDefinedColour; -if (colour != null) { -colour = "User Defined"; -}}if (colour != null) { -this.globalColourScheme = jalview.schemes.ColourSchemeProperty.getColour (this.alignment, colour); -if (this.globalColourScheme != null) { -this.globalColourScheme.setConsensus (this.hconsensus); -}}if (applet.userDefinedColour != null) { -(this.globalColourScheme).parseAppletParameter (applet.userDefinedColour); -}}this.initAutoAnnotation (); -}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite"); -Clazz.defineMethod (c$, "getConsensusSeq", -function () { -if (this.consensus == null) { -this.updateConsensus (null); -}if (this.consensus == null) { -return null; -}var seqs = new StringBuilder (this.consensus.annotations.length); -for (var i = 0; i < this.consensus.annotations.length; i++) { -if (this.consensus.annotations[i] != null) { -if (this.consensus.annotations[i].description.charAt (0) == '[') { -seqs.append (this.consensus.annotations[i].description.charAt (1)); -} else { -seqs.append (this.consensus.annotations[i].displayCharacter); -}}} -var sq = new jalview.datamodel.Sequence ("Consensus", seqs.toString ()); -sq.setDescription ("Percentage Identity Consensus " + ((this.ignoreGapsInConsensusCalculation) ? " without gaps" : "")); -return sq; -}); -Clazz.defineMethod (c$, "setFont", -function (f) { -this.font = f; -if (this.nullFrame == null) { -this.nullFrame = new awt2swing.Frame (); -this.nullFrame.addNotify (); -this.nullFrame.setFont (this.font); -}var fm = this.nullFrame.getGraphics ().getFontMetrics (this.font); -this.setCharHeight (Clazz.floatToInt (this.heightScale * fm.getHeight ())); -this.setCharWidth (Clazz.floatToInt (this.widthScale * fm.charWidth ('M'))); -if (this.isUpperCasebold ()) { -var f2 = new java.awt.Font (f.getName (), 1, f.getSize ()); -fm = this.nullFrame.getGraphics ().getFontMetrics (f2); -this.setCharWidth (Clazz.floatToInt (this.widthScale * (Clazz.doubleToInt (fm.stringWidth ("MMMMMMMMMMM") / 10)))); -}}, "java.awt.Font"); -Clazz.defineMethod (c$, "getFont", -function () { -return this.font; -}); -Clazz.defineMethod (c$, "resetSeqLimits", -function (height) { -this.setEndSeq (Clazz.doubleToInt (height / this.getCharHeight ())); -}, "~N"); -Clazz.defineMethod (c$, "setCurrentTree", -function (tree) { -this.currentTree = tree; -}, "jalview.analysis.NJTree"); -Clazz.defineMethod (c$, "getCurrentTree", -function () { -return this.currentTree; -}); -Clazz.defineMethod (c$, "getCentreColumnLabels", -function () { -return this.centreColumnLabels; -}); -Clazz.defineMethod (c$, "getFollowSelection", -function () { -return this.followSelection; -}); -Clazz.overrideMethod (c$, "sendSelection", -function () { -this.getStructureSelectionManager ().sendSelection ( new jalview.datamodel.SequenceGroup (this.getSelectionGroup ()), new jalview.datamodel.ColumnSelection (this.getColumnSelection ()), this); -}); -Clazz.overrideMethod (c$, "getStructureSelectionManager", -function () { -return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.applet); -}); -Clazz.defineMethod (c$, "expandColSelection", -function (sg, wholewidth) { -var sgs; -var sge; -if (sg != null && (sgs = sg.getStartRes ()) >= 0 && sg.getStartRes () <= (sge = sg.getEndRes ()) && (this.colSel == null || this.colSel.getSelected () == null || this.colSel.getSelected ().size () == 0)) { -if (!wholewidth && this.alignment.getWidth () == (1 + sge - sgs)) { -return; -}if (this.colSel == null) { -this.colSel = new jalview.datamodel.ColumnSelection (); -}for (var cspos = sg.getStartRes (); cspos <= sg.getEndRes (); cspos++) { -this.colSel.addElement (cspos); -} -}}, "jalview.datamodel.SequenceGroup,~B"); -Clazz.overrideMethod (c$, "isNormaliseSequenceLogo", -function () { -return this.normaliseSequenceLogo; -}); -Clazz.defineMethod (c$, "setNormaliseSequenceLogo", -function (state) { -this.normaliseSequenceLogo = state; -}, "~B"); -Clazz.overrideMethod (c$, "isValidCharWidth", -function () { -return this.validCharWidth; -}); -Clazz.defineMethod (c$, "getAnnotationColumnSelectionState", -function () { -return this.annotationColumnSelectionState; -}); -Clazz.defineMethod (c$, "setAnnotationColumnSelectionState", -function (annotationColumnSelectionState) { -this.annotationColumnSelectionState = annotationColumnSelectionState; -}, "jalview.appletgui.AnnotationColumnChooser"); -Clazz.overrideMethod (c$, "mirrorCommand", -function (command, undo, ssm, source) { -if (Clazz.instanceOf (source, jalview.api.AlignViewportI) && (source).getCodingComplement () === this) { -} else { -return; -}var mappedCommand = ssm.mapCommand (command, undo, this.getAlignment (), this.getGapCharacter ()); -if (mappedCommand != null) { -mappedCommand.doCommand (null); -this.firePropertyChange ("alignment", null, this.getAlignment ().getSequences ()); -}}, "jalview.commands.CommandI,~B,jalview.structure.StructureSelectionManager,jalview.structure.VamsasSource"); -Clazz.overrideMethod (c$, "getVamsasSource", -function () { -return this; -}); -Clazz.defineMethod (c$, "scrollComplementaryAlignment", -function (complementPanel) { -if (complementPanel == null) { -return; -}var sr = new jalview.datamodel.SearchResults (); -var seqOffset = this.findComplementScrollTarget (sr); -if (!sr.isEmpty ()) { -complementPanel.setFollowingComplementScroll (true); -complementPanel.scrollToCentre (sr, seqOffset); -}}, "jalview.appletgui.AlignmentPanel"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.structure.CommandListener", "$.SelectionSource", "$.VamsasSource", "jalview.viewmodel.AlignmentViewport", "java.awt.Font"], "jalview.appletgui.AlignViewport", ["awt2swing.Frame", "jalview.api.AlignViewportI", "jalview.bin.JalviewLite", "jalview.datamodel.ColumnSelection", "$.SearchResults", "$.Sequence", "$.SequenceGroup", "jalview.schemes.ColourSchemeProperty", "jalview.structure.StructureSelectionManager", "jalview.util.Platform", "jalview.workers.AlignCalcManager", "java.lang.Float", "$.StringBuilder"], function () { +c$ = Clazz.decorateAsClass (function () { +this.cursorMode = false; +this.font = null; +this.validCharWidth = true; +this.currentTree = null; +this.applet = null; +this.MAC = false; +this.annotationColumnSelectionState = null; +this.nullFrame = null; +this.featureSettings = null; +this.heightScale = 1; +this.widthScale = 1; +this.centreColumnLabels = false; +this.followSelection = true; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AlignViewport", jalview.viewmodel.AlignmentViewport, [jalview.structure.SelectionSource, jalview.structure.VamsasSource, jalview.structure.CommandListener]); +Clazz.prepareFields (c$, function () { +this.font = new java.awt.Font ("SansSerif", 0, 10); +}); +Clazz.overrideMethod (c$, "finalize", +function () { +this.applet = null; +this.quality = null; +this.alignment = null; +this.colSel = null; +}); +Clazz.makeConstructor (c$, +function (al, applet) { +Clazz.superConstructor (this, jalview.appletgui.AlignViewport); +this.calculator = new jalview.workers.AlignCalcManager (); +this.applet = applet; +this.alignment = al; +this.setPadGaps (true); +this.startRes = 0; +this.endRes = al.getWidth () - 1; +this.startSeq = 0; +this.endSeq = al.getHeight () - 1; +if (applet != null) { +var param = applet.widthScale; +if (param != null) { +try { +this.widthScale = new Float (param).floatValue (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +if (this.widthScale <= 1.0) { +System.err.println ("Invalid alignment character width scaling factor (" + this.widthScale + "). Ignoring."); +this.widthScale = 1; +}if (jalview.bin.JalviewLite.debug) { +System.err.println ("Alignment character width scaling factor is now " + this.widthScale); +}}param = applet.heightScale; +if (param != null) { +try { +this.heightScale = new Float (param).floatValue (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +if (this.heightScale <= 1.0) { +System.err.println ("Invalid alignment character height scaling factor (" + this.heightScale + "). Ignoring."); +this.heightScale = 1; +}if (jalview.bin.JalviewLite.debug) { +System.err.println ("Alignment character height scaling factor is now " + this.heightScale); +}}}this.setFont (this.font); +this.MAC = jalview.util.Platform.isAMac (); +if (applet != null) { +this.setShowJVSuffix (applet.getDefaultParameter ("showFullId", this.getShowJVSuffix ())); +this.setShowAnnotation (applet.getDefaultParameter ("showAnnotation", this.isShowAnnotation ())); +this.showConservation = applet.getDefaultParameter ("showConservation", this.showConservation); +this.showQuality = applet.getDefaultParameter ("showQuality", this.showQuality); +this.showConsensus = applet.getDefaultParameter ("showConsensus", this.showConsensus); +this.setShowUnconserved (applet.getDefaultParameter ("showUnconserved", this.getShowUnconserved ())); +this.setScaleProteinAsCdna (applet.getDefaultParameter ("scaleProteinAsCdna", this.isScaleProteinAsCdna ())); +var param = applet.upperCase; +if (param != null) { +if (param.equalsIgnoreCase ("bold")) { +this.setUpperCasebold (true); +}}this.sortByTree = applet.getDefaultParameter ("sortByTree", this.sortByTree); +this.setFollowHighlight (applet.getDefaultParameter ("automaticScrolling", this.isFollowHighlight ())); +this.followSelection = this.isFollowHighlight (); +this.showSequenceLogo = applet.getDefaultParameter ("showSequenceLogo", this.showSequenceLogo); +this.normaliseSequenceLogo = applet.getDefaultParameter ("normaliseSequenceLogo", applet.getDefaultParameter ("normaliseLogo", this.normaliseSequenceLogo)); +this.showGroupConsensus = applet.getDefaultParameter ("showGroupConsensus", this.showGroupConsensus); +this.showGroupConservation = applet.getDefaultParameter ("showGroupConservation", this.showGroupConservation); +this.showConsensusHistogram = applet.getDefaultParameter ("showConsensusHistogram", this.showConsensusHistogram); +}if (applet != null) { +var colour = applet.defaultColour; +if (colour == null) { +colour = applet.userDefinedColour; +if (colour != null) { +colour = "User Defined"; +}}if (colour != null) { +this.globalColourScheme = jalview.schemes.ColourSchemeProperty.getColour (this.alignment, colour); +if (this.globalColourScheme != null) { +this.globalColourScheme.setConsensus (this.hconsensus); +}}if (applet.userDefinedColour != null) { +(this.globalColourScheme).parseAppletParameter (applet.userDefinedColour); +}}this.initAutoAnnotation (); +}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite"); +Clazz.defineMethod (c$, "getConsensusSeq", +function () { +if (this.consensus == null) { +this.updateConsensus (null); +}if (this.consensus == null) { +return null; +}var seqs = new StringBuilder (this.consensus.annotations.length); +for (var i = 0; i < this.consensus.annotations.length; i++) { +if (this.consensus.annotations[i] != null) { +if (this.consensus.annotations[i].description.charAt (0) == '[') { +seqs.append (this.consensus.annotations[i].description.charAt (1)); +} else { +seqs.append (this.consensus.annotations[i].displayCharacter); +}}} +var sq = new jalview.datamodel.Sequence ("Consensus", seqs.toString ()); +sq.setDescription ("Percentage Identity Consensus " + ((this.ignoreGapsInConsensusCalculation) ? " without gaps" : "")); +return sq; +}); +Clazz.defineMethod (c$, "setFont", +function (f) { +this.font = f; +if (this.nullFrame == null) { +this.nullFrame = new awt2swing.Frame (); +this.nullFrame.addNotify (); +this.nullFrame.setFont (this.font); +}var fm = this.nullFrame.getGraphics ().getFontMetrics (this.font); +this.setCharHeight (Clazz.floatToInt (this.heightScale * fm.getHeight ())); +this.setCharWidth (Clazz.floatToInt (this.widthScale * fm.charWidth ('M'))); +if (this.isUpperCasebold ()) { +var f2 = new java.awt.Font (f.getName (), 1, f.getSize ()); +fm = this.nullFrame.getGraphics ().getFontMetrics (f2); +this.setCharWidth (Clazz.floatToInt (this.widthScale * (Clazz.doubleToInt (fm.stringWidth ("MMMMMMMMMMM") / 10)))); +}}, "java.awt.Font"); +Clazz.defineMethod (c$, "getFont", +function () { +return this.font; +}); +Clazz.defineMethod (c$, "resetSeqLimits", +function (height) { +this.setEndSeq (Clazz.doubleToInt (height / this.getCharHeight ())); +}, "~N"); +Clazz.defineMethod (c$, "setCurrentTree", +function (tree) { +this.currentTree = tree; +}, "jalview.analysis.NJTree"); +Clazz.defineMethod (c$, "getCurrentTree", +function () { +return this.currentTree; +}); +Clazz.defineMethod (c$, "getCentreColumnLabels", +function () { +return this.centreColumnLabels; +}); +Clazz.defineMethod (c$, "getFollowSelection", +function () { +return this.followSelection; +}); +Clazz.overrideMethod (c$, "sendSelection", +function () { +this.getStructureSelectionManager ().sendSelection ( new jalview.datamodel.SequenceGroup (this.getSelectionGroup ()), new jalview.datamodel.ColumnSelection (this.getColumnSelection ()), this); +}); +Clazz.overrideMethod (c$, "getStructureSelectionManager", +function () { +return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.applet); +}); +Clazz.defineMethod (c$, "expandColSelection", +function (sg, wholewidth) { +var sgs; +var sge; +if (sg != null && (sgs = sg.getStartRes ()) >= 0 && sg.getStartRes () <= (sge = sg.getEndRes ()) && (this.colSel == null || this.colSel.getSelected () == null || this.colSel.getSelected ().size () == 0)) { +if (!wholewidth && this.alignment.getWidth () == (1 + sge - sgs)) { +return; +}if (this.colSel == null) { +this.colSel = new jalview.datamodel.ColumnSelection (); +}for (var cspos = sg.getStartRes (); cspos <= sg.getEndRes (); cspos++) { +this.colSel.addElement (cspos); +} +}}, "jalview.datamodel.SequenceGroup,~B"); +Clazz.overrideMethod (c$, "isNormaliseSequenceLogo", +function () { +return this.normaliseSequenceLogo; +}); +Clazz.defineMethod (c$, "setNormaliseSequenceLogo", +function (state) { +this.normaliseSequenceLogo = state; +}, "~B"); +Clazz.overrideMethod (c$, "isValidCharWidth", +function () { +return this.validCharWidth; +}); +Clazz.defineMethod (c$, "getAnnotationColumnSelectionState", +function () { +return this.annotationColumnSelectionState; +}); +Clazz.defineMethod (c$, "setAnnotationColumnSelectionState", +function (annotationColumnSelectionState) { +this.annotationColumnSelectionState = annotationColumnSelectionState; +}, "jalview.appletgui.AnnotationColumnChooser"); +Clazz.overrideMethod (c$, "mirrorCommand", +function (command, undo, ssm, source) { +if (Clazz.instanceOf (source, jalview.api.AlignViewportI) && (source).getCodingComplement () === this) { +} else { +return; +}var mappedCommand = ssm.mapCommand (command, undo, this.getAlignment (), this.getGapCharacter ()); +if (mappedCommand != null) { +mappedCommand.doCommand (null); +this.firePropertyChange ("alignment", null, this.getAlignment ().getSequences ()); +}}, "jalview.commands.CommandI,~B,jalview.structure.StructureSelectionManager,jalview.structure.VamsasSource"); +Clazz.overrideMethod (c$, "getVamsasSource", +function () { +return this; +}); +Clazz.defineMethod (c$, "scrollComplementaryAlignment", +function (complementPanel) { +if (complementPanel == null) { +return; +}var sr = new jalview.datamodel.SearchResults (); +var seqOffset = this.findComplementScrollTarget (sr); +if (!sr.isEmpty ()) { +complementPanel.setFollowingComplementScroll (true); +complementPanel.scrollToCentre (sr, seqOffset); +}}, "jalview.appletgui.AlignmentPanel"); +});